Posts for SineSwiper

Post subject: AI in search of a TAS goal
Experienced Forum User
Joined: 4/16/2013
Posts: 8
So, I've been modifying and tweaking this MarIO script for the past two weeks just to see how far I can take it. In that time, I've learned how it works and what its weak points are. Unlike past experiments I've seen with making something generic to handle any game or the original MarIO's "millions of years of evolution" model, I have no reservations with installing lots and lots of Super Mario World specific logic into the Lua scripts to get it to go where I want it to go. It requires a lot of babysitting to prod it in the right directions (via scripts, never manually), but I can at least push it far enough to get past a few levels. Currently, it's stuck on 1-3, because the level is pretty high up, and there's some yellow switch blocks keeping it alive, so it never wants to turn around and go up. I have an idea on how to fix it (dead zones), but it made me pause and think about exactly what I want to do with this thing. So, what should I do with these dumb little bots? Create the first fully-automated SMW run. This was my original approach. The MarIO video looks at a few levels, but never actually goes all the way. It would take a lot of custom code for certain levels, but I think it's possible to have them go all the way through the castles and beat Bowser. The big question here is: Would this be worth a video? The bots aren't TASers. They aren't even speed runners. I can't see them beating any of the SMW times already posted on this site. As a concept, it would be neat, but it would more or less look like a typical person running through a course. I dunno. Maybe I'm underselling it, and people would be interested in this concept. Try to beat one of the TAS goals. Yeah, I don't really see this happening. Way too many tricks and long-term strategies for a bot to process. I might be able to code some of these tricks as inputs, but it would be running them at random, without any sort of strategy. SMW's popularity means I'm able to acquire so much memory map information, which is nice, but that also means the runs are that much more competitive. Switch to a different game with less information to process. The bots might not be able to beat a TASer at SMW, but maybe something else with less combinations of input and outcomes. Maybe Punchout? There's only so many actions the boxer can do and so many outcomes of that action. Or Tetris? Would that even be an entertaining video? Are there any options I'm not thinking of?
Post subject: lsnes: Input movies and save states within Lua
Experienced Forum User
Joined: 4/16/2013
Posts: 8
The save state support in lsnes for Lua is a strange beast. The movie.* section has
Language: lua

movie.unsafe_rewind( movie.to_rewind(filename) )
to be able to load a save state, but nothing to save a save state. It has INPUTMOVIE to read/write/edit input movies, but you can't actually load them into the active state, as they are just input files. The UNSAFEREWIND class's only function appears to be sending it to unsafe_rewind. Funny, there's actually a ZIPWRITER class, but I don't think Lua has enough access to all of the save state files to roll your own state writer. Yes, I know about the
Language: lua

exec("save-state " .. filename)
command, which is what I'm using now, but that seems like an API of last resort. Are there plans to fill in these gaps? Am I missing some new functions or something obvious?
Experienced Forum User
Joined: 4/16/2013
Posts: 8
Okay, good, thanks. I thought I tried that already, but loading the movie seems to work. The input log is being saved in the auto-generated savestate files. At least I can use the functions I've got to bleet out some warnings.
Experienced Forum User
Joined: 4/16/2013
Posts: 8
I dunno... I figured BizHawk was the recommended emulator for most everything, and I really like the interface. I guess I'll write my own input writer. The file format doesn't seem all that hard to emulate.
Post subject: Manipulation of movies/input logs through Lua
Experienced Forum User
Joined: 4/16/2013
Posts: 8
I've been hacking away at the MarI/O code (quite extensively, actually), and have it working with multiple save state files. It basically creates 60 frames of a genome run during each new generation, so that every bot isn't starting at the beginning all of the time. My problem is that I don't see a lot of functionality in BizHawk's Lua interface for movie manipulation. I have a save state with an InputLog (I checked the zip), but loading this file doesn't actually tell BizHawk to keep recording the inputs. I also don't see anything in the movie functions for loading a movie or restarting the recording. I can save and stop the movie, and get a bunch of statuses, but I'm missing something here. If it's not in movie category, can I get the savestates to record and retain the input log? Do I have to roll my own logger and then splice it together when I'm ready to produce a movie? (And pray that it actually works...)
Experienced Forum User
Joined: 4/16/2013
Posts: 8
Patashu wrote:
Just to make sure - if you're talking about improving this bot or BisqBot, have you fully read the research paper here? http://www.cs.cmu.edu/~tom7/mario/mario.pdf
Partially. Still skimming through it. I'm mostly talking about BisqBot, though. Still trying to get it to compile (bisqbot-mario.cc) without much luck. Not sure how it interacts with the emulator, either.
Experienced Forum User
Joined: 4/16/2013
Posts: 8
Bobo the King wrote:
I was thinking of something along the lines of "trajectories", by which I mean, "If I were to execute the following button combinations over these frames, how would I expect relevant RAM values to change?" This would allow the bot to peer into the future predictively and relatively efficiently. In principle, it shouldn't be too difficult and should closely model human play. In practice... I'm in over my head.
Well, that's exactly what "save state prediction" is. It's actually asking that very question by doing some random button presses, and then checking RAM values. It's predicting the future by playing the future and then reverting back. But, I guess both you and I are looking for something that is less random in its button presses. Something that wouldn't require a mammoth amount prediction cycles to play through the game. Another technique to consider is Maze solving algorithms. If a set of actions leads to a "dead end", like reducing in size or dying, chop off that branch and move to the next set. I don't know if that gives you much in savings, though, and it gives stuff like size reduction an infinitely negative weight. (This would be appropriate for death, but you might actually have a use for purposely getting hit.)
Experienced Forum User
Joined: 4/16/2013
Posts: 8
Hmmm, after looking at that and some older post about BisqBot, I wonder if the BisqBot concept can be taken to a more extreme level. Call it the DeepBlue of TASing. Some ideas of improvements: 1. Make it really think ahead, like 10 seconds ahead. 2. Give it more (weighted) variables as to what is considered "better". Make things like losing bigness a negative. 3. Have some form of smaller loops that save good inputs, so that the full 10 seconds isn't completely random. For example, as soon as it kills a Goompa, consider that input pattern to be a "good one" and keep duplicating that for a while. I guess item #3 would be explained as almost like some sort of multi-looped binary division: 10 second loop --> 2 5s loops --> 4 2.5s loops --> etc. I'm sure there is some form of genetic programming that would help out here, too.