9 ms·
Show HN: Space invaders, but the invaders evolve with genetic algorithm
- nacs 8y agoLive demo here: https://victorribeiro.com/invaderz/ https://victorribeiro.com/invaderz/ I'm finding that I can barely last 7 generations to be able to see it 'evolving'. Handicapping the player by waiting for the previous shot to hit before firing again and making the move speed ridiculously slow makes this game too hard even before the genetic algorithm makes an impact. Also, because the player's move speed is so slow, the easy tactic for the algorithm to head towards is to simply push each enemy to opposite ends of the screen -- ie: hug the wall. If you're clearing one side, the player won't be able to reach the other end of the board even if you move as fast as possible. TLDR: Interesting concept but to really demo this concept you need to make the game a little easier for the player / don't handicap so much.
- atum47 8y agoThey evolve each generation. What happens after the 7 generation is that if no one could kill you until now, make a new wave of Invaders while keeping the best one from past generations.
- deleted 8y ago[deleted]
- krisroadruck 8y agoI'm confused, I was able to get to generation 9 in my first go and that was with it taking me 2 rounds before I figured out I could use the keyboard to move and shoot instead of the mouse...
- deleted 8y ago[deleted]
- atum47 8y agoI will put a welcome informing the controls
- shawnz 8y agoAgreed, this is a very cool concept but it's too hard for the player. As a workaround, run this in the console to double the player's speed and allow you to re-shoot the bullet while it's in motion. Player.prototype.shoot = function shoot() { this.bullet = {x: this.x+this.s/2, y: this.y, s: 3}; this.isShooting = true }; Player.prototype.update = function update() { if (this.x > 0 && this.isMovingLeft) { this.x -= 0.02 * dt; }; if (this.x < w/4-this.s && this.isMovingRight) { this.x += 0.02 * dt; }; if (this.isShooting) { this.bullet.y -= 0.1 * dt; if (this.bullet.y < 0) { this.isShooting = false; this.bullet = {}; } } }
- atum47 8y agoNice, haha.
- MauranKilom 8y agoI had no trouble getting to wave 30+, and I certainly didn't grow up with this kind of game. Using PC keyboard though - are you on mobile? In any case, the real problem here is that either the player is good enough to last a long time (in which case most waves are probably killed very quickly, thus randomness dominating the fitness function and you won't see evolution) or the game won't last long enough to see a lot of evolution happening.
- nacs 8y agoThe author made the speed of the player much faster a few hours after my comment was posted so my concerns regarding speed/difficulty are no longer relevant. The max speed of the player was barely the speed of the enemies before the change. I’ve also tried it on my iPhone and it’s easily playable too.
- NickBusey 8y agoWhile 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.
- atum47 8y agoYes, 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.
- NickBusey 8y agoNo, 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.
- atum47 8y agoNo, 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.
- torvald 8y agoIt would have been interesting to see an evolving agent playing against these evolving invaders. Cool project!
- atum47 8y agoI'm thinking about using a NN I made a while back to play it. =)
- spicytunacone 8y agoI really liked how you justified the gameplay with story re: "When a InvaderZ dies, they upload their progress to the mothership, so it can generate more InvaderZ like the ones who did well before." The evolving enemy concept made me look up an old boss-rushing shooter that selected the next boss's upgrades based on your performance[1]. Is this something you're interested in refining further? [1]: https://en.wikipedia.org/wiki/Warning_Forever https://en.wikipedia.org/wiki/Warning_Forever
- atum47 8y agoThe idea began with me wanting to generate space Invaders character design using genetic algorithm, so I thought, what the heck: if I do that I might as well do a sort of game play to justify they design. That's how this project was borned. Who knows what it becomes? But very nice of you to comment and leave a link.
- zimpenfish 8y agoCrossing the streams with the Valve/Proton thread of yesterday, Warning Forever still works a dream on Windows 10 and is an exceptionally fun game. Well worth finding and downloading.
- ValleyOfTheMtns 8y agoOh man, I remember that game. It was THE shit.
- rambojazz 8y agoIs there a playable demo?
- cpeterso 8y agoLive demo here: https://victorribeiro.com/invaderz/ https://victorribeiro.com/invaderz/
- O_H_E 8y agoNot working for me "victorribeiro.com’s server IP address could not be found"
- atum47 8y agoHere's fine.
- O_H_E 8y agoI am in Kazakhstan, if that helps
- atum47 8y agoI don't have a server; I pay a hosting service, it's what I can afford right now, and I called them and asked for more resource, cause it's been receiving a lot of visitors. Maybe it went down for a moment.
- mikekchar 8y agoIt's just static data, so you can host it on Github's servers using Github Pages: https://pages.github.com/ https://pages.github.com/ Gitlab even goes one better and allows you a build step if you ever wanted to use webpack, etc...
- atum47 8y agoI just increased the player's speed, after a lot of requests.
- atum47 8y agothe manifest.appcache should take care of the update; but if it don't, clear the storage and visit victorribeiro.com/invaderz again
- deleted 8y ago[deleted]
- dbg31415 8y agoCute, but way too slow to be fun.
- hellbanner 8y agoCool stuff. Check out Quantum Pilot where the enemies literally mirror your previously recorded actions. Steam / Android / iOS
- chaoticmass 8y agoI tried the game you mentioned. Surprisingly hard!
- mywittyname 8y agoSuggestion: support 'a' for left and 'd' for right.
- laurent123456 8y agoThe problem if you use "a" and "d" is that it will only work with qwerty keyboards. In azerty for instance the equivalent would be "q" and "d". So for a small demo it's probably better to just use arrows as this will work everywhere, and there won't be a need to support all keyboard layouts out there.
- why_only_15 8y agoBe real - what percent of people are using azerty, even on HN?
- pierrec 8y agoShow HN: Space Invaders, but it doesn't work for French people
- Insanity 8y agoAt least the majority of France / Belgium. I switched to qwerty about 2 years ago, but almost everyone I know uses azerty here (as software engineers). Personally, I don't expect it to be supported though. But it should at least have a fallback like the arrow keys.
- pluma 8y agoAh, yes, the "fuck internationalisation, we're all living in America anyway" argument. EDIT: Data point of 1: I'm German and use a QWERTZ layout because it's a hassle to type umlauts on QWERTY even with a compose key. If I were French that'd mean I'd be using AZERTY.
- pierrec 8y agoThat's not the argument. They just seem to believe that it's a nerdy alternative layout like Dvorak ("...even on HN"). Not everyone is familiar with international layouts.
- Insanity 8y agoReally cool idea! Went to wave 32, had a lot of fun with it actually. But, knowing the algorithm, I tried to shoot the hard ones first and wait as long as I could to shoot the easy ones by just letting them descent :)
- jonathankoren 8y agoI played through 70+ generations before I stopped, and it certainly seemed like they were getting more jiggly as it went on, albeit, very slowly. It would be nice if there was genome display or something, so you could see how the population was evolving. Towards the generations that were multiples of 7, it would look like the population started to converge. So some sort of display information about that would be interesting. It would negatively effect gameplay because it would be essentially a cheat for the human, but it would be an interesting visualization none the less.
- atum47 8y agoThe design of the InvaderZ is his genome and the way it behaves. It as vector of size 16 with zeros or ones. If it's a one it draws a "pixel". So you have to think of it as a 4x4 Matrix ```[ 0,0,1,1, 0,0,1,1, 1,1,1,1, 0,1,1,1 ]```
- jonathankoren 8y agoYeah I get that, but I’d like more insight into the the semantics. Like “horizontal speed 16”, “move fequency 11” etc.
- clusmore 8y agoThis made me think that it'd be interesting to see a variant on Space Invaders where you play as the invaders - you would write a little program that takes the state of the world and determines the next move for each invader and play against an AI cannon. Does anybody know if something like this already exists?
- d0m 8y agoWhat if: - kill the "hard ones" first - wait for the easier one to get very close to atmosphere, and then kill it. - will the algorithm learn to evolve toward easy ones?
- newnewpdro 8y ago63 generations later, I didn't get the impression the invaders were getting any better. Not consistently anyways, they would kind of vascillate between moving a lot and not much at all. It's an interesting idea, but I think the implementation needs more tuning.
- disqard 8y agoThis is very cool work! I particularly like the idea of a "human in the loop" as objective function for the GA. Yes, it's slow and I didn't end up playing more than a few rounds, but the core idea is a Good One. Thank you for making and sharing!
- mhb 8y agoSpace Evaders?
- donald21333 8y agoA magazine published earlier this month says between March and now, the percentage of the population having a perfect score has increased by 28% I know why, many of them have been paying to get it fixed. YES try to consolidate your credit so everything can be on a perfect stand with a golden score(i am talking at least 795) in three days. ALL CHANGES ARE PERMANENT. This can only be done with the concentration and smartness by Notablespy who has assisted so many individuals,i just got saved by him too.he can be trusted. I got my credit score increase up to 820 and from then my whole story change, i had enough money to stand on my own, i had my very big dream come though right now my family and i live in a house of our own and i already have two other house along side this year 2018. This is an achievement ever. Although what i paid can't be compared to the good work i received from him out of his kindness. Contact directly email(SYNCHACKTECHCREDITREPAIR@MAIL.COM or 8646570231)