News for hackers. Stuff that matters.
Re:Show HN: Space invaders, but the invaders evolve with gen... by NickBusey on Tuesday October 30, 2018 @02:46PM (#18340059)
While this is very cool, using the distance each invader survives as the fitness score seems like maybe not the best choice for this scenario.

With so many invaders spawning at the same time, and the 'bullet' you shoot moving so slow, the last invader to be destroyed seems to me to be a result of random choice (which one did you get around to shooting last) rather than it being any 'healthier' than the other invaders.

I don't really have a suggestion on how to improve it other than maybe slow down the vertical progress of the invaders and speed up the bullet so that distance made vertically is actually tied more closely to it's ability to evade your shots.

Re:Show HN: Space invaders, but the invaders evolve with gen... by tgirod on Wednesday October 31, 2018 @03:58AM (#18343987)
I agree with you. When I play, the "best" invaders tend to be the easy targets that have drifted to one side of the screen.

Here is a proposal for another fitness score: everytime a bullet is shot, raise the score of every survivor, weighted by the distance between the survivor and the bullet. The closer the bullet the better the fitness.

Intuitively, I think this would select for better dodgers.

Re:Show HN: Space invaders, but the invaders evolve with gen... by Hei1Fuya on Wednesday October 31, 2018 @08:31AM (#18345082)
But dodging is just a subgoal and margin is not all that relevant. The actual goal is to defeat the player, if dodging by a slim margin happens to be the best strategy then that should not be penalized.
Re:Show HN: Space invaders, but the invaders evolve with gen... by Someone on Tuesday October 30, 2018 @04:54PM (#18341200)
”the last invader to be destroyed seems to me to be a result of random choice”

There’s a simple strategy that guarantees you won’t be the first to die: hide behind the back of your biggest buddy.

I think that would be my strategy, plus “if a bullet that’s going to kill your ‘shield’ is on its way, figure out whether you can find a new shield; if not, make a run for it.

The existence of such a strategy shows the result isn’t completely random.

(Of course, there also is a prisoner’s dilemma here: if everybody follows that strategy, the swarm would run away from you, and nobody would gain any fitness)

Re:Show HN: Space invaders, but the invaders evolve with gen... by atum47 on Tuesday October 30, 2018 @02:57PM (#18340166)
Yes, and the last one who survived moved in a way that helped it survive. It's not the best one the ones who reproduce, they all can reproduce, the ones who got closer or went through have more chance.
Re:Show HN: Space invaders, but the invaders evolve with gen... by NickBusey on Tuesday October 30, 2018 @03:04PM (#18340248)
No, I'm saying even if they didn't move, there would still be a last one to survive, just based on the time it takes to shoot them.
Re:Show HN: Space invaders, but the invaders evolve with gen... by atum47 on Tuesday October 30, 2018 @03:12PM (#18340315)
No, their fit score is how close they got to crossing the finish line. If they don't move, they got no score. If they move in a straight line and still manage to win, hey, that's life. I've observed that the ones who jiggle around are the ones that wins the most.
Re:Show HN: Space invaders, but the invaders evolve with gen... by NickBusey on Tuesday October 30, 2018 @03:23PM (#18340419)
If they didn't move left to right I mean.
Re:Show HN: Space invaders, but the invaders evolve with gen... by atum47 on Tuesday October 30, 2018 @03:30PM (#18340487)
But do you agree that if they don't move, they will the ones easier to shoot? So, unless you are sparing them, they won't go very far and will have less chance of reproduction.
Re:Show HN: Space invaders, but the invaders evolve with gen... by NickBusey on Tuesday October 30, 2018 @03:37PM (#18340560)
Of course, but I'm just saying there are so many of them and they are so hard to shoot due to the slow bullet time and only one bullet, that the left to right movement is not making as big of an impact as it could.

I would say just give a try at slowing down the vertical progress, remove the one bullet at a time restriction, and see how that goes.

Not trying to be negative at all, I think it's a great project and the code looks to be very clean. Nice work.

Re:Show HN: Space invaders, but the invaders evolve with gen... by atum47 on Tuesday October 30, 2018 @04:32PM (#18341022)
I'm inserted in a context that I don't have anyone to discuss this kind thing, so you don't have to be apologetic. It was very that you liked the project. I've been receiving many suggestions and I'll look into them with care. Thanks a lot.
Re:Show HN: Space invaders, but the invaders evolve with gen... by mrtnmcc on Tuesday October 30, 2018 @03:46PM (#18340636)
On average, over many plays, the random aspects of the scoring you are concerned about will average away and the useful traits will be reinforced. Just like evolution.
Re:Show HN: Space invaders, but the invaders evolve with gen... by NickBusey on Tuesday October 30, 2018 @03:56PM (#18340726)
Over many plays, sure, but how long should one person have to sit there to see results? As far as I can tell, there is no persistence between sessions. I'm saying making the game 'easier' for the player would decrease both the number of plays needed to get better evolutionary results and also decrease the time between each evolutionary cycle.
Re:Show HN: Space invaders, but the invaders evolve with gen... by tenken on Tuesday October 30, 2018 @05:10PM (#18341302)
Who said evolution was fast?! ... Or easy?! :D

I've used GAs before in school. One example way to do even session-less evolution faster would be a distributed client/server model where the indivual survivors across all game instances who are lasting the longest are crossbred but that would take longer to code ....

Re:Show HN: Space invaders, but the invaders evolve with gen... by Kiro on Wednesday October 31, 2018 @07:29AM (#18344801)
The problem is that "over many plays" would be like thousands at this tempo. I played up until generation 20 or something and it was still completely random who I decided to kill last.
Re:Show HN: Space invaders, but the invaders evolve with gen... by dwringer on Wednesday October 31, 2018 @08:47AM (#18345187)
I tried to kill the ones on the sides and/or that moved around more first, which did seem to lead after ~10 generations to lots of static/slow opponents coming down in an easily-dispatched cluster that could be easily mopped up at the end of each round. Conversely I'd imagine prioritizing the slow ones would lead to enemies that tend to move around a lot.
Re:Show HN: Space invaders, but the invaders evolve with gen... by ReverseCold on Tuesday October 30, 2018 @05:20PM (#18341381)
Yup, it seems like you can game it by looking for the easiest one and waiting till the very end to hit it.
Re:Show HN: Space invaders, but the invaders evolve with gen... by caf on Wednesday October 31, 2018 @01:06AM (#18343488)
Isn't that part of the... game?
Re:Show HN: Space invaders, but the invaders evolve with gen... by drivers99 on Wednesday October 31, 2018 @07:10AM (#18344714)
In other words, AI domestication. Interesting concept! (Allowing it to live longer being the equivalent of breeding.)
Re:Show HN: Space invaders, but the invaders evolve with gen... by middleman90 on Wednesday October 31, 2018 @12:02PM (#18346839)
Well... they could learn to look "stupid" and be smart at the very end of the game
Re:Show HN: Space invaders, but the invaders evolve with gen... by thaumasiotes on Tuesday October 30, 2018 @04:40PM (#18341096)
> using the distance each invader survives as the fitness score seems like maybe not the best choice for this scenario

> With so many invaders spawning at the same time, and the 'bullet' you shoot moving so slow, the last invader to be destroyed seems to me to be a result of random choice (which one did you get around to shooting last) rather than it being any 'healthier' than the other invaders.

I couldn't disagree more. The fitness score is correct, because the invader wins by covering distance.

What happens by chance early will happen by design late -- that is nearly the entire concept of evolutionary approaches. They always improve on their fitness function, and what matters is that you chose the right one. In this case, improving on the distance invaders travel is the point of being an invader, and the point of the game, so that distance is very obviously the correct fitness function.

Re:Show HN: Space invaders, but the invaders evolve with gen... by flashman on Tuesday October 30, 2018 @06:17PM (#18341742)
> the invader wins by covering distance

The invader wins by crossing the baseline. This fitness function lets me use evolution against the invaders by letting the dumbest ones approach the baseline before killing them, making future waves easier than if I killed the easiest invaders first.

Perhaps the fitness score could include the number of projectiles that passed nearby without impacting, as a measure of difficulty to hit.

Re:Show HN: Space invaders, but the invaders evolve with gen... by thaumasiotes on Wednesday October 31, 2018 @02:09AM (#18343671)
>> the invader wins by covering distance

> The invader wins by crossing the baseline.

Both are true, but covering distance is a better fitness function because it is continuous and crossing the baseline is discrete (and not just discrete -- binary). Your strategy can make the difficulty rise more slowly than otherwise, but it can't make the difficulty plateau or drop.

Re:Show HN: Space invaders, but the invaders evolve with gen... by NickBusey on Tuesday October 30, 2018 @05:19PM (#18341371)
I said 'for this scenario', I suppose I should have been more clear. In my post I go on to list ways to change the scenario so it does fit the fitness function. I do agree the fitness function is probably correct, but the rest of the implementation doesn't match it.