Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Source code here: http://pastebin.com/M2GCDuEE
- Time to start work on the first experiment of my first genetic algorithm experiments.
- Here's my setup:
- Gridworld critters
- Four genomes:
- G1: Atk 1, Def 1, Con 1
- G2: Atk 2, Def 1, Con 1
- G3: Atk 1, Def 2, Con 1
- G4: Atk 1, Def 1, Con 2
- Attack is amount of damage, defence is how much damage is negated when attacked, regenerates 1 point of def every (two?) steps. Con is how many hitpoints it has. Regenerates 1 HP per step if not attacking. Whoever gets to their step first will regen first, tough luck if a genome isn't regened when it gets attacked. Def regeneration isn't cumulative, a genome must spend two full turns regernating one point of Def.
- All genomes attack each other.
- If another genome is within range (1 square) of another it determines randomly, at this point, which to attack. Then attacks, it gets first strike, so it does its' damage first then the other genome does its' damage.
- First experiment, only four bugs with genomes.
- I think that one of the 3 stronger ones are going to prevail simply because they have higher stats at this point. Of those three, I would have to say that G2 is probably going to win because of how hard it hits.
- Problems
- First problem I've run into is that processActors returns actors and not GenomeBases, so I need to figure out how to turn an Actor into it's GenomeBase.
- I believe I've figured it out, and the answer surprised me. If you loop through the actors in processActors and then check if they're an instanceof GenomeBase it actually counts it as a GenomeBase. And yes, it does return the GenomeBase of Actor. That's excellent.
- Result
- It takes a lot longer than I thought it would for them to actually die, even G1. But they do die, mostly.
- In the end, after letting the simulation run for around a minute or so, G2 and G4 were the two left. It makes sense once I think about it because G4 can absorb 3 points of damage, and it regens all of that in two steps.
- I think that defence should take longer to regen, or maybe health should take longer, not sure exactly.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement