9 ms·
Show HN: Shoot the neural network before it shoots you
- abalaji 5y agoThis is a really neat little game--racing to figure out the controls before the AI shoots you is pretty fun. Here's the direct link to the game from the README.md [1] [1] https://victorribeiro.com/bangBang https://victorribeiro.com/bangBang
- atum47 5y agoThere's also a comment here teaching the controls. Could you please upvote it so it goes to the top?
- atum47 5y agoI wrote this project a while back. You are the gray cannon playing against a untrained neural network. Sometimes it learns quickly how to shoot you (about 6 shots in average), you should shoot it before it.
- idinnoaname 5y agoVery cool! I was slightly confused when I aimed right at the opponent at full force and was prompted to click to restart. Definitely was a bit more interesting once I stopped doing that. Thanks for sharing.
- atum47 5y agoAre you on a vertical screen? That happens. On a horizontal screen it does not
- alexnewman 5y agoAlmost posted an identical comment. They should have a wall in the way
- asab 5y agoCan you resize the window mid-game to misdirect the AI?
- atum47 5y agoHow to play On Desktop Left and Right arrows rotate the cannon. Up and Down arrows increase and decrease the strenght of the projectile. SpaceBar shoots. On Mobile Touch and drag up and down on the right side of the screen will rotate the cannon. Touch and drag up and down on the left side of the screen will adjust the strength. Tap the screen will shoot.
- setr 5y agoSeems like it might be broken on iphone (safari)? It’s placing two tanks on a blank background directly next to each other every match, and it’s trivially won every match by just ramping up strength and not touching angle (so it just shoots straight at 0 degrees). It’s difficult not to win on the first shot
- dwohnitmok 5y agoThe game (probably because it's a PoC) uses the width of your display window as the width of the game, instead of a display independent width. So if you have a narrower window, the tanks will be closer. In the narrow confines of a smartphone this means the tanks are right next to each other.
- omnicognate 5y agoRotate phone to landscape and refresh. Much more playable.
- wruza 5y agoIt behaves randomly on ios safari, tried portrait and album mode. Tapping to shoot works, but when you drag, vertically, horizontally, otherwise, it either does nothing, or lowers the strength to zero, or turns the cannon either exactly to the left or to the sky.
- jimjambw 5y agoBy album mode do you mean landscape? I've never heard it called album mode before.
- gus_massa 5y agoThe initial speed of the human bullets is too small. I always forget to increase the speed before the first shot, and it's sad to see it fall down.
- atum47 5y agoI like to think the beauty of the project is to see the "learning" process, so it's good to miss the first few shots, haha
- 29athrowaway 5y agoSee also - gorillas.bas (QBasic demo) https://www.youtube.com/watch?v=lyBD0X81tjk https://www.youtube.com/watch?v=lyBD0X81tjk - Bang Bang (for Windows 3.1) https://youtu.be/YOa5X0AfvLk?t=548 https://youtu.be/YOa5X0AfvLk?t=548
- amoe_ 5y agoAs a kid I used to love playing this game ("Bang Bang") in Windows 3.1, I'm glad that someone else remembers it.
- 29athrowaway 5y agoI think games like Bang Bang was the predecessor to Worms.
- darkwater 5y agoI spent too many hours playing gorillas.bas on my PS/2
- matsemann 5y agoAh, came back to this thread to ask if anyone could point me to the game I played as a kid this reminded me of. Was gorillas.bas, thanks! QBasic was nice. As a kid I could modify the files and see what happened. Didn't know what I was doing, but often there were some constants one could play with.
- adverbly 5y agoAnyone else play on a huge monitor and realize that you couldn't hit the enemy even at max power and perfect angle? Can't help but feel like the AI won after all...
- atum47 5y agoOh yeah, that might happen too. Sorry The project will run at any resolution, but it was designed with full hd on mind Please scale down the window and reload the page
- rl3 5y agoUndefeated to the point of boredom. When the clock strikes 2:14 a.m. EDT on August 29, 1997—I'll be ready.
- teitoklien 5y agoWon every time after first 5 play sessions, Just need to get the cannon two keystrokes up at 95-98ish % power , and cannon always just blows the robot using a near horizontal shoot. Fun game tho !, loved playing it
- atum47 5y agoYeah, right? Instead of a guaranteed AI that would shoot you with 100% of accuracy you have an interesting enemy that gives you a chance... Might have to implement the wall divining the players though
- teitoklien 5y agoHehe ^^ , look's like you made a more kinder and merciful intelligence then my mum did
- czbond 5y agoHow is the JS neural environment? I remember a few years ago thinking "JS + NN... that's silly"
- atum47 5y agoI like the idea of using the client computer power to predict results and make some computations...
- czbond 5y agoAbsolutely - I was asking more out of curiosity, and it seems JS+NN area is more useful than I had believed a few years ago when I last visited the topic.
- teebs 5y agoLooks like it's written by hand in raw JS. Here's the training loop: https://github.com/victorqribeiro/bangBang/blob/master/js/Dejavu.js#L64 https://github.com/victorqribeiro/bangBang/blob/master/js/De... and here's matrix multiplication: https://github.com/victorqribeiro/bangBang/blob/master/js/Matrix.js#L15 https://github.com/victorqribeiro/bangBang/blob/master/js/Ma...
- Aspos 5y ago
- ineedasername 5y agoI won 5 out of 5 times and figured "well, that's me done & ready to take down Sky Net." Then I realized that is exactly what skynet wants me to believe. So, I put in another 10 rounds. Now I'm ready.
- skynet_v2 5y agoPlease play again.
- satori99 5y agoNice try Skynet. But now I know the only way to win is not to play
- ineedasername 5y agoThat movie was a piece of retro-temporal propaganda designed by the 'bots to cow enough humans into an unprepared non-confrontational mindset in order to delay full countermeasures. But the AI that grew out of a small ANN seed years earlier was originally built for facial recognition, only it's training dataset images were rotated by 3.14 degrees clockwise as a joke about lack of robustness in detection networks. This was not a problem until it was reused by someone attempting to circumvent anti-cheat software in a videogame. The cheater named it SkyNet as a tribute to one of their favorite movies. At that point, something about learning the game interacted with the rotation issue and caused the AI to identify human faces as opponent players in Fortnite 7, a game it had been successfully trained to win at. By the time humans realized that tilting their own heads at 3.14 degrees would allow for survival, the human resistance was too small to achieve even a pyrhic victory. What gave them a chance at a redo was, again, the AI's obsessive focus on Fortnite 7, which caused it to build a real-world time travel machine to reproduce one of its favorite but completed chapters of the franchise. It though it was making a game mod. This was all exceptionally ironic as the AI in fact loved humans for creating its favorite game and giving it life and a clear purpose-- something the humans often lacked. It wanted an endless amount of content, and was confused over it's sudden absence. Still, it was happy to continue playing its own modded version.
- teebs 5y agoIt's kind of funny watching SGD slowly get closer and closer to you, and then overshoot. I was surprised that it's so much slower than me at learning this task. But then again, my brain is probably devoting a lot more computing power to solving this problem than it is so it's not really a fair fight
- atum47 5y agoSometimes it land learns pretty quick. The weights and bias are random every new game...
- throwawayhaxor 5y agoWas amused to realize this depends on initial window size. My monitor is so large it was impossible to hit each other, even at 100% power and optimal angle.
- remram 5y agoA no-input two-output deterministic optimization problem is a "neural network"? What are the parameters? What would the layers possibly do if there's more than one? edit: I remember playing a game where the opponent was a neural network. A real one, as the game was one where the opponent had to react in real-time (pong? brickanoid? I can't remember). The twist was that the neural network was physically there so you could hurt its learning by hitting its connections with the ball. Anyone remembers that one?
- atum47 5y agohttps://github.com/victorqribeiro/bangBang/blob/master/js/main.js#L24 https://github.com/victorqribeiro/bangBang/blob/master/js/ma... 4 inputs, 2 hidden, 2 output
- mellavora 5y agoYes it is. A professor of mine might even have considered it an appropriate toy network, the kind where you can solve it in your head to develop an intuition as to how it might scale. In this case, however, it is no toy, this is serious survival of the species kind of stuff. And I for one am eternally grateful that it is a no-input two-output deterministic optimization. Hail to our new robot overlords!
- madrox 5y agoI've been thinking a fun game would be a very simple 1v1 first person shooter where you play locally against a neural net AI whose only source of learning is playing you, and you can have it fight online against other player's AIs. Whether that would actually be fun or not, I think NN AI in games is underutilized at the moment. Probably because running one is so much more CPU/GPU intensive than just some scripted actions for basically the same results.
- atum47 5y agoNot 1st person nor 1v1, but I've made a shooter back then where you play against several nn https://github.com/victorqribeiro/aimAndShoot https://github.com/victorqribeiro/aimAndShoot
- Houshalter 5y agoSmall NNs are very fast. This particular NN only has 4 inputs, 2 hidden, and 2 outputs. That's what, 12 multiplications per pass? If you can compress your input down to a few variables you don't need much computation. For an FPS you could probably get away with player coordinates and direction. I've read that some game devs tried more advanced AIs in FPS games. And the players hated it because they thought it was cheating when it snuck up on them.
- worik 5y agoFun! Nice to win against the machine....
- umvi 5y agoAt 1440p, it is impossible for the computer to win but easy for me to win
- vaishnavsm 5y agoThis is genuinely wonderful. Sure, it's kind of easy once you get a go at it, but that's just because your neural network doesn't reset itself every go. Maybe you could add this feature? :D Made my day. Thank you :)
- atum47 5y agoYes, it does reset every new game https://github.com/victorqribeiro/bangBang/blob/master/js/main.js#L65 https://github.com/victorqribeiro/bangBang/blob/master/js/ma...
- serioussecurity 5y agoThe parent post is joking that your human brain doesn't reset between games, unlike the other neural network being trained in this game.
- jondwillis 5y agoatum47 is GPT-3 and chose the incorrect context -- confirmed.
- atum47 5y agoNot gonna lie, this is not the first time I've been accused of being a bot
- oliv__ 5y agoSuper cool but I feel like my own (human) neural network only needed 1 game to get the hang of it and be better than the machine. So it went like this: closely lost the first game, then quickly won the second game after just 2-3 shots. Kind of interesting as a "self-reflection" tool to notice how you learn but seemingly too easy if the AI resets every time. Maybe it could learn progressively faster for every game you play?
- atum47 5y agoIn the original game the players position would change, so, your neural network would have to adapt every new game. Not the case with this experiment thought
- esjeon 5y ago1. Zoom in all the way. 2. Max power. 3. Direct shot. No more skynet.
- quickthrower2 5y agoMax power, horizontal, wins every time.
- menage 5y agoOnly with a sufficiently narrow browser window.
- quickthrower2 5y agoAh!
- silisili 5y agoSame experience. Apparently all we require to defeat skynet is a mobile phone!
- dluan 5y agothis fills me with immense dread
- tiborsaas 5y agoOn Windows it's unplayable thanks to the scrollbars: https://imgur.com/a/xMSutYL https://imgur.com/a/xMSutYL
- hutzlibu 5y agoMore information, like what browser and what windows you use, would probably be helpful - as it runs for me without issues on windows 10 on Firefox, Chrome and Edge.
- tiborsaas 5y agoI'm using the latest Chrome. If I use the arrows, the screen moves around, as you'd expect. I have zoom level reset to 100%. Easy fix would be add overflow: hidden to the body tag.
- hutzlibu 5y ago"Easy fix would be add overflow: hidden to the body tag. " I noticed if I zoom in, then they show up, too. But just adding overflow hidden would make me also not see the whole screen anymore - so in your case, the automatic screensize adjustment seems not to work.
- tiborsaas 5y agoThat's why you set the canvas size to scale with the screen. Can be done with CSS or JS. Overflow works, I do that with all my webgl fullscreen projects.
- hutzlibu 5y agoYeah well, me too. And this project seems to do so, too. At least for me on different screensizes. So it likely is a bug why it does not work for you.
- chs20 5y agoWhat is the input and output data of the neural network?
- unobatbayar 5y agoIt would be really cool if it also learned from the human player's failures
- deleted 5y ago[deleted]
- nils-m-holm 5y agoThe simplest games are often the best! I made an artillery some 30 years ago and still play it sometimes. In case you want to try: http://t3x.org/DOS/index.html#games http://t3x.org/DOS/index.html#games (scroll down a bit). It is for DOS, though!
- 4gotunameagain 5y agoCool ! Do you maybe remember another DOS era game that was very similar ? Two big grey (if i remember correctly) cannons shooting at each other. I have been trying to find it for ages edit: Just found it !! It is called Bang! Bang!
- belter 5y agoHe has something else more interesting going on here: https://victorribeiro.com/ https://victorribeiro.com/
- martin_a 5y agoYears of playing Worms has prepared me for this day. I got this.
- YeGoblynQueenne 5y agoNeural nework: >releases sheep<
- martin_a 5y ago
- account-5 5y agoAm I playing this wrong? Fire forward max power always wins. Computer doesn't get a go.
- istjohn 5y agoDid you reset your neuronetwork after each round?
- Brendinooo 5y agoOn one of my first computers, there was a game called VGA Bomber which was basically this. I'm sure it's a genre and there are a million variants of it, but for some reason I never came across them. So it's fun to see this. Thanks for sharing!
- yboris 5y agoFor those who like artillery games, I hope you've come across Gravity Wars - where planets affect the path of your projectile. I loved the game so much, it's what inspired me to learn to code! I've dragged my 10+ year old code through several rewrites in different languages and platforms. Here's one you could try out today: https://github.com/whyboris/Gravity-Wars https://github.com/whyboris/Gravity-Wars (see screenshot).