Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Shoot the neural network before it shoots you (github.com/victorqribeiro)
146 points by atum47 on Jan 24, 2022 | hide | past | favorite | 88 comments


I 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.


Please play again.


Nice try Skynet. But now I know the only way to win is not to play


That 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.


How 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.


Seems 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


The 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.


Rotate phone to landscape and refresh. Much more playable.


It 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.


By album mode do you mean landscape? I've never heard it called album mode before.


Yeah, landscape. It was translated to my language (russian) as “album orientation” long ago in winword and I make this mistake from time to time. Portrait sounds like “book-ish orientation” btw. I believe that’s because books are usually portrait-like and albums tend to have wider pages. https://www.google.ru/search?q=%D0%B0%D0%BB%D1%8C%D0%B1%D0%B...


This 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 :)



The parent post is joking that your human brain doesn't reset between games, unlike the other neural network being trained in this game.


atum47 is GPT-3 and chose the incorrect context -- confirmed.


Not gonna lie, this is not the first time I've been accused of being a bot


He has something else more interesting going on here: https://victorribeiro.com/


Anyone 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...


Oh 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


It's also too fast on 144 hz display.


Good to know, I could limit the fps


requestAnimationFrame


A 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?



Yes 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!


Undefeated to the point of boredom. When the clock strikes 2:14 a.m. EDT on August 29, 1997—I'll be ready.


It'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


Sometimes it land learns pretty quick. The weights and bias are random every new game...


I'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.


Small 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.


Not 1st person nor 1v1, but I've made a shooter back then where you play against several nn

https://github.com/victorqribeiro/aimAndShoot


Years of playing Worms has prepared me for this day. I got this.


Neural nework: >releases sheep<


See also

- gorillas.bas (QBasic demo) https://www.youtube.com/watch?v=lyBD0X81tjk

- Bang Bang (for Windows 3.1) https://youtu.be/YOa5X0AfvLk?t=548


Ah, 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.


As a kid I used to love playing this game ("Bang Bang") in Windows 3.1, I'm glad that someone else remembers it.


I think games like Bang Bang was the predecessor to Worms.


I spent too many hours playing gorillas.bas on my PS/2


This 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


There's also a comment here teaching the controls. Could you please upvote it so it goes to the top?


The 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 (scroll down a bit). It is for DOS, though!


Cool !

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!


For 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 (see screenshot).


I 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.


Very 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.


Are you on a vertical screen? That happens. On a horizontal screen it does not


Almost posted an identical comment. They should have a wall in the way


Good suggestion


Maybe allow projectiles to bounce off the screen edges?

Being able to destroy the environment (eg. craters in the ground) would be cool too.


Can you resize the window mid-game to misdirect the AI?


Won 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


Yeah, 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


Hehe ^^ , look's like you made a more kinder and merciful intelligence then my mum did


Super 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?


In 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


Was 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.


OTOH, on a smartphone in portrait (vertical) mode, aiming straight and going full power is an easy win on the first shot.


Yeah, I kinda droped the ball there


The 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.


I 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


On 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!


At 1440p, it is impossible for the computer to win but easy for me to win


On Windows it's unplayable thanks to the scrollbars: https://imgur.com/a/xMSutYL


More 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.


I'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.


"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.


That'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.


Yeah 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.


How is the JS neural environment? I remember a few years ago thinking "JS + NN... that's silly"


Looks like it's written by hand in raw JS. Here's the training loop: https://github.com/victorqribeiro/bangBang/blob/master/js/De... and here's matrix multiplication: https://github.com/victorqribeiro/bangBang/blob/master/js/Ma...


Yep, dejavu is my toy neural network that I use for small and experimental projects like this


Nicely done on implementation though...


thank you


I use both brain.js and tensorflow.js.

Former is way simpler and starts faster. The latter is more powerful, of course, and can infer using heavier models trained on a powerful machine.

Ran a few tests and found that on the server side python+tensorflow performance is practically identical to node+tensorflow.


@Aspos - wow, thanks for that comment.

Your finding is astounding to me. Great to hear - I'm floored by hearing they're in the same ballpark.


I like the idea of using the client computer power to predict results and make some computations...


Absolutely - 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.


Max power, horizontal, wins every time.


Only with a sufficiently narrow browser window.


Ah!


Same experience. Apparently all we require to defeat skynet is a mobile phone!


Am I playing this wrong? Fire forward max power always wins. Computer doesn't get a go.


Did you reset your neuronetwork after each round?


It would be really cool if it also learned from the human player's failures


What is the input and output data of the neural network?


Fun!

Nice to win against the machine....


1. Zoom in all the way.

2. Max power.

3. Direct shot.

No more skynet.


this fills me with immense dread




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: