gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Bot Programming an Original Cartridge Game

#175126 - nimblehack - Sun Sep 12, 2010 8:18 pm

Basically the idea is to make a bot program for a standard rpg game (i.e. zelda, pokemon). i want the program to basically press buttons, and read the text. i know that the instructions for the program would have to be written by me. The catch is i dont want to do it for an emulator but rather for an actual cartridge game.

-Now the question-

does any one know of a way to to directly hook up the gba, or even just the cartridge in such a way that i would be able to run a program off my computer that would allow me to simulate a human player while a commerical game is in use?

im pretty sure i would need to start my bot, then have the program recieve the data from gameboy, and have a way to initiate output?

e.i. of what the program would contain
tun on/ off
press 'up'
press 'A'
if text says 'press a' // ha, i would need a way for the computer to read the text first.
then 'press a'
// there would be a save which would be like press start, down down, a

its important to understand that i want to in no way change or clone my cartridge game. i want the cartridge to remain funtional. i just want to run my side program.

p.s. kinda new at this. i plan on the actual programming of the bot to be alot of what takes up my time. i just need help getting a connection between my computer/program and the gba.

#175127 - Dwedit - Sun Sep 12, 2010 8:33 pm

Reading the contents of the screen is completely out of the question.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#175128 - nimblehack - Sun Sep 12, 2010 8:37 pm

when it comes to reading the sceen, i know how to do that... i just dont know how to interact with the actual game. i was wondering if anyone knows how to literally load a game with a computer, or connect it to a gba while the gba is on and interact with it.

#175129 - nimblehack - Mon Sep 13, 2010 3:03 am

let me rephrase that. i know of a way i could do that. im just uncertain on how i would go about running a program that would be able to interact with just the hardware?

#175130 - nimblehack - Mon Sep 13, 2010 3:29 am

is there a way to code a program, if ran from my computer or from a modded gba, code which would only affect the hardware. while of course still playing a commercial game.

#175131 - nimblehack - Mon Sep 13, 2010 3:39 am

or is ther a way to run a preprogram like a gameshark would in terms of start my preprogram, then run game...

#175134 - Dwedit - Mon Sep 13, 2010 1:02 pm

If you're trying to mess around with PC games, there are tons of ways to do it, OllyDbg, Win32 Game Wizard, etc...

But running your own program and running an unmodified commercial GBA cartridge at the same time is very hard to do. Sure, it's possible to send multiboot programs to a GBA through a parallel cable and execute small binaries (256k or smaller). But there is no operating system or protected memory that will stop the game from clobbering your code when the game clears or overwrites the RAM. You would need to have a way to stop the game from clearing your code out of RAM, and stop it from installing its own interrupt handler, all kinds of stuff. In order to put in code to simulate joypad presses from the link port, you'd need to patch the game and run it off a flash cartridge, so it's not the original cartridge anymore (but is still an original GBA system).

Sounds like you'd be better off with some kind of robot.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#175135 - nimblehack - Mon Sep 13, 2010 2:02 pm

k, thank you for your help

#175136 - gauauu - Mon Sep 13, 2010 3:14 pm

Are you allowed to rip apart the gba in the process? The easiest way to control it might be to solder in extra lines at the all the switches for the controller, and run them to something like an arduino that would be easily controllable from a computer.

A standard arduino runs at 5v and the gba 3.3, I believe, but I'm pretty sure you can get arduinos that run at 3.3v. Or if you know your electronics well, you could use something else (if you knew what you were doing, you could easily skip the microcontroller and just control it from the serial or parallel ports, but that might be a little tricker if you are an electronics newbie like I am).

I agree with Dwedit, though, that reading the screen will be the hardest part (if you are trying to run off an actual commercial game)

#175139 - nimblehack - Mon Sep 13, 2010 4:16 pm

to read the screen you take a camera, have it programmed to detect key points. it would be able to, in some games, figure out when the text stop due to the little key in the corner when it pauses. i bet i could get it to read health bars and such then to.

ya hard, not impossible. definitely last on the list of things to figure out. ha, im still working on basic input/output.

i guess i should have posted this under harware.


Last edited by nimblehack on Mon Sep 13, 2010 4:41 pm; edited 1 time in total

#175140 - nimblehack - Mon Sep 13, 2010 4:40 pm

my brother just brought up the point, for pokemon, that things like critical hits would effect the program and like the random pkm stuff like that.

Last edited by nimblehack on Tue Sep 14, 2010 3:48 pm; edited 1 time in total

#175142 - elhobbs - Mon Sep 13, 2010 7:13 pm

have you every seen the movie Terminator 2? I think you need to create something like a terminator - just do not make it want to destroy all humans. I think the T-1000 would be better at playing games than the original terminator model. Do not even attept to make a T-X model - that would be just too hard.

#175143 - nimblehack - Mon Sep 13, 2010 9:33 pm

ha, make a govenator thats better at playing a game then running a state.

#175144 - wintermute - Mon Sep 13, 2010 11:45 pm

sometimes you lot really scare me :p
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#175145 - elhobbs - Mon Sep 13, 2010 11:47 pm

nimblehack wrote:
ha, make a govenator thats better at playing a game then running a state.
not saying that he is making it better or worse - but I think that hole was pretty deep when he got in it...

#175147 - nimblehack - Tue Sep 14, 2010 4:29 am

ya i dont know. thats just how awsome i want my project to end up. ha now to just get it done.

#175151 - headspin - Tue Sep 14, 2010 11:55 am

A bot that plays the GBA for you. So you can go outside and get some sun instead. Great idea!
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#175152 - nimblehack - Tue Sep 14, 2010 3:47 pm

yep hopefully it'll teach me alot about hardware and software.

#175169 - Exophase - Mon Sep 20, 2010 7:49 pm

You can rig hardware that snoops the address bus and gets a hook into some frequently executed location in order to install your own handler. You can do this to read back the controls over some interface.

Cheat devices do this trick. They require a pre-defined location per game, but with some heuristics you could make the device learn a location pretty well, but only after it has executed several times.

If the full bus is visible on the cartridge port and if internal I/O accesses appear on the bus then you should also be able to snoop when the game reads the controls. By this point it'll be too late to do anything about it, but you'll probably be able to narrow down the instruction that caused it by looking at most recent bus accesses into the ROM (prefetching could make this tricky)

You'd need some pretty smart hardware for this. Doing it statically like the cheat devices is a lot simpler. But like has been said, you'd may as well just modify the game.

I think doing any kind of decent AI based on image processing is going to be extremely difficult though, completely dwarfs the challenge of writing the controls..

#175175 - keldon - Tue Sep 21, 2010 12:23 pm

Exophase wrote:
I think doing any kind of decent AI based on image processing is going to be extremely difficult though, completely dwarfs the challenge of writing the controls..


Just thought I'd point out that your sprites and tiles will be in VRAM, and you need only look at the OAM, scroll values and tile memory to know where you are in the level and where objects are positioned - nothing elaborate needed for that ...

... just saying.

#175199 - sgeos - Wed Sep 29, 2010 8:49 pm

Lego Mindstorms?

#175201 - wintermute - Thu Sep 30, 2010 3:13 pm

Robots! Made from Lego!

http://mindstorms.lego.com
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#175203 - sgeos - Sat Oct 02, 2010 2:01 am

Now all we need to do is get a Lego robot to play the GBA! They have cameras and can use the buttons. It would be like a person playing the GBA, only... it's a bot! What could be cooler than that?