Write a Bot/AI that can play SNES

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
bugger
Rookie
Posts: 19
Joined: Sat Mar 20, 2010 5:27 am

Write a Bot/AI that can play SNES

Post by bugger »

Hi,

i am interessting if anything like that has been tried before, search came up with no results :(

Is there any know method to read the game state out of ZSNES?

Per Example we want the AI to play Tetris. How can we get the position of each block?
Best option would be to directly read it out of the memory, but where?
Sending input to ZSNES is not that hard.
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Re: Write a Bot/AI that can play SNES

Post by grinvader »

SNES9x has lua scripting support that lets you do something like that. ZSNES currently has no support for it.
As to writing the bot itself, it's game-dependant. If noone already did the work for you, you'll have to read the game code yourself to see what's where and so on.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
bugger
Rookie
Posts: 19
Joined: Sat Mar 20, 2010 5:27 am

Re: Write a Bot/AI that can play SNES

Post by bugger »

ah ok thats good news! thank you ;)

what i found so far:

http://tasvideos.org/forum/viewtopic.php?t=6539 Snex9X v1.43+ v11 beta + lua 0.06
http://dehacked.2y.net/snes9x-lua.html function library for Snex9X
should me get starting ;)

but is there a unix version with lua? or best multi platform?
mz
Rookie
Posts: 21
Joined: Sun Aug 05, 2007 9:18 pm
Location: Argentina
Contact:

Re: Write a Bot/AI that can play SNES

Post by mz »

bugger wrote:http://tasvideos.org/forum/viewtopic.php?t=6539 Snex9X v1.43+ v11 beta + lua 0.06
http://dehacked.2y.net/snes9x-lua.html function library for Snex9X
That version is really, really old. Get it from here instead: http://code.google.com/p/snes9x-rr/

You may want to read this too: http://code.google.com/p/snes9x-rr/wiki ... gFunctions
paulguy
Zealot
Posts: 1076
Joined: Sat Jul 02, 2005 2:01 am
Contact:

Re: Write a Bot/AI that can play SNES

Post by paulguy »

Wouldn't you want an AI to visually inspect the screen?
Maybe these people were born without that part of their brain that lets you try different things to see if they work better. --Retsupurae
odditude
Official tech support dood
Posts: 2118
Joined: Wed Jan 25, 2006 7:57 am

Re: Write a Bot/AI that can play SNES

Post by odditude »

bugger wrote:Best option would be to directly read it out of the memory
OP said it best.
Why yes, my shift key *IS* broken.
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Re: Write a Bot/AI that can play SNES

Post by grinvader »

paulguy wrote:Wouldn't you want an AI to visually inspect the screen?
Clunky and slow as hell, and will still require game-specific code. If you have to do some custom source reading, better work on the internal arrays representing the layouts, not their video result (guaranteed horror to work with).
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
paulguy
Zealot
Posts: 1076
Joined: Sat Jul 02, 2005 2:01 am
Contact:

Re: Write a Bot/AI that can play SNES

Post by paulguy »

That's true, I just think that if you're making an AI for a specific game, it would be interesting to try to figure it out visually, as a human wouldd do.

If one is to write a bot for tetris, though, why build off of an emulatedd version? May as well work off an open source tetris source. Maybe take one that could use a vs computer mode and add an AI to that.
Maybe these people were born without that part of their brain that lets you try different things to see if they work better. --Retsupurae
Johan_H
Starzinger Addict
Posts: 998
Joined: Tue Aug 17, 2004 1:14 pm
Location: Sweden
Contact:

Re: Write a Bot/AI that can play SNES

Post by Johan_H »

bugger
Rookie
Posts: 19
Joined: Sat Mar 20, 2010 5:27 am

Re: Write a Bot/AI that can play SNES

Post by bugger »

mz wrote:
bugger wrote:http://tasvideos.org/forum/viewtopic.php?t=6539 Snex9X v1.43+ v11 beta + lua 0.06
http://dehacked.2y.net/snes9x-lua.html function library for Snex9X
That version is really, really old. Get it from here instead: http://code.google.com/p/snes9x-rr/

You may want to read this too: http://code.google.com/p/snes9x-rr/wiki ... gFunctions
yeah :) thats good! thanks mz

Lets see if i get anything done.
Gonna let u guys know, thx so far!
paulguy
Zealot
Posts: 1076
Joined: Sat Jul 02, 2005 2:01 am
Contact:

Re: Write a Bot/AI that can play SNES

Post by paulguy »

Johan_H wrote:Relevant
I had the live wallpaper on my phone for that one. It killed my battery pretty good, though.
Maybe these people were born without that part of their brain that lets you try different things to see if they work better. --Retsupurae
bugger
Rookie
Posts: 19
Joined: Sat Mar 20, 2010 5:27 am

Re: Write a Bot/AI that can play SNES

Post by bugger »

Whats the easiest way to analyze the memory?
I tried Cheat Engine... Opened the snes9x.exe and looked at RAM addresses 0x7e0000-0x7fffff but only zeros :(
ok snes9x has a ram watcher ;) pretty nice! but somehow snes9x crashes sometimes really annoying...
The OS (Windows 7) protects the memory from being read by other processes?!. ;(
Last edited by bugger on Tue Jan 24, 2012 11:33 pm, edited 3 times in total.
bugger
Rookie
Posts: 19
Joined: Sat Mar 20, 2010 5:27 am

Re: Write a Bot/AI that can play SNES

Post by bugger »

Also is there a way to open snex9x with some parameters that it runs the game and loads saved game state in slot 1?!
Post Reply