Live data from Hacker News

Street Fighter II's AI Engine

sf2platinum.wordpress.com

21–30 of 88 posts

Re: Street Fighter II's AI Engine

#21
post #15
post #8

Earlier quoted context omitted.

You can do it using the techniques employed here: https://github.com/aikorea/strikersii_ai/tree/master/genetic Demo: https://www.youtube.com/watch?v=k6Ir8yd9iOk In terms of FGs, you would store the relevant game state as inputs and build a reward function around health, time, damage done etc. A relatively simple (and useful!) SFII AI would be one that tries to win by only using crouching medium kick, sweep and throw.

I just meant straight up using the scripting language described in the article to hand-code an AI.

Aah in that case if you're willing to forego the limitation of using the original AI instruction scheme, you can use the technique I recently used to build a training dummy. It's just a state machine that reacts differently depending on the state of various game variables (the same idea used by the original SFII code). The scripting language is Lua, and it's basically lines of code that go:

    if (distanceBetweenChars() 
etc...

Here's a demo of one that reads the distance between characters and either dashes in and does a low attack, or attempts to throw you.

https://www.youtube.com/watch?v=R9THKU63viM

It's pretty simple to have this script run for Player 1 and Player 2.

In a competitive environment (ie. when you have AI vs AI) the players involved would need to agree on certain limitations, otherwise it would be pretty simple to build an AI that reacts "instantly" to stimuli.

Re: Street Fighter II's AI Engine

#22
post #12
post #7

Earlier quoted context omitted.

'learning to fight against you, sort of like a human would' is a lot more fun than 'literally cheating and perfectly countering you'

Since humans are not infallible, let's leave it at 'learning to fight against you, sort of like a superhuman would'. It would make for a formidable opponent since you can still defeat it (with a good dose of luck).

If you forced the AI to work with a substantial input lag, it could be quite complex yet still possible to defeat.

Re: Street Fighter II's AI Engine

#23
post #3

I wonder if knowing the different strategies would make pro-humans better at playing the game. I feel like they might already have internalized the different strategies the computer uses, but still pretty surprising to see how simple the source code is. Also cool to think about would be AI-vs-AI street fighter competitions. Or SF AI that learns from live matches currently being played online.

> AI-vs-AI street fighter competitions

http://www.saltybet.com/ does just that.

Re: Street Fighter II's AI Engine

#24
post #16

I wonder if one can create an invincible AI for Street Fighter II. One that obviously makes the right choice always and can counter every possible human attack. (kind of think that it was also possible even back in the 90s, but never implemented; what would have been the point?)

Depends on what the input to it is. There is an invincible AI for StreetFighter V that reads the other player's inputs from the network stream and simply chooses the perfect attack with which to counter. Much more interesting to me would be machine vision that can recognize what's happening on screen. I'd be fine with it getting frames via direct HDMI connection rather than with a camera and similarly inputting moves by sending USB packets down the wire, rather than physically pressing buttons.

Re: Street Fighter II's AI Engine

#25
post #3

I wonder if knowing the different strategies would make pro-humans better at playing the game. I feel like they might already have internalized the different strategies the computer uses, but still pretty surprising to see how simple the source code is. Also cool to think about would be AI-vs-AI street fighter competitions. Or SF AI that learns from live matches currently being played online.

The key to making an fighting game AI API interesting is enforcing the same reaction delays humans have, from decision making to input, which is roughly 250-300ms, if I remember correctly (your nervous system from brain to fingers has pretty high latency).

That delay time is what well-made fighting games are designed and balanced around. If you forced the AI to create inputs that would get processed however many milliseconds later they would actually have to start predicting their opponents, seeking hit confirms, etc.

If you don't enforce any sort of delay, making an unbeatable AI should be trivial.

Re: Street Fighter II's AI Engine

#26
post #16

I wonder if one can create an invincible AI for Street Fighter II. One that obviously makes the right choice always and can counter every possible human attack. (kind of think that it was also possible even back in the 90s, but never implemented; what would have been the point?)

Absolutely. All fighting games are basically a mashup of rock-paper-scissors with a bit of real-time chess mixed in. If you have instant reaction time and perfect understanding of what's happening on screen (no mistaking the early animation of one move for another) an unbeatable AI should be trivial, because you'll always win the rock-paper-scissors part.

Re: Street Fighter II's AI Engine

#27
post #16

I wonder if one can create an invincible AI for Street Fighter II. One that obviously makes the right choice always and can counter every possible human attack. (kind of think that it was also possible even back in the 90s, but never implemented; what would have been the point?)

People have kind of tried this with Mugen, I think.

Yep. SpriteClub.tv, a mugen stream, showcases a bunch of these kinds of characters with hilarious results.
Post reply on HN