-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble with env initialization, can't access Times Trials properly ? #98
Comments
Hi @AdrianValente13 , apologies for the delayed response. I have not actively worked on this project in a few years. The behavior is odd, and your theory is basically what I was thinking too. It seems that the button presses are happening too quickly. The way it is supposed to work is that it waits a certain number of frames for the emulator to step through the necessary frames to where the menu begins to 'listen' for button presses, and then send the appropriate controller buttons to do the navigation. I wonder if the ROM you have is different. Can you confirm the MarioKart64 ROM file has an MD5 checksum of Also, if I remember correctly, I only ever had this running on Python2 and never got it upgraded to Python3 (see #81). Perhaps there is some issue there causing the frame synchronization issue. Otherwise, I wonder if the mupen64plus emulator may have been upgraded and the number of frames has changed in some way. Is this the Dockerfile you are using? I notice that you have a different base Ubuntu image, which could install a different version of mupen64plus. Off the top of my head, those are the three things that come to mind. I can't commit to spending any time on this right now, but if I happen to get the chance to try it, I will certainly update you. |
For reference, here's the code that handles the menu navigation: gym-mupen64plus/gym_mupen64plus/envs/MarioKart64/mario_kart_env.py Lines 252 to 274 in 61228ff
and the game select navigation (grand prix vs time trials): gym-mupen64plus/gym_mupen64plus/envs/MarioKart64/mario_kart_env.py Lines 276 to 292 in 61228ff
There are a couple other methods like those that handle other aspects (player & map selection), all nearby in that file. |
Rewatching your video using the "example script", it appears to me that you have the 4 components running in docker-compose, and that the emulator is up already ( I suspect you actually have two emulators running (one in its own container, and one embedded in the agent), both connected to the same controller server, and both requesting the controls. The controller server (i.e. the agent) believes it has progressed through the frames because two emulators have both asked for the state of the controller. It is basically causing it to progress through the frames at twice the rate than it normally would, and each emulator is only receiving half the controller button pushes than it needs. Here's the code that checks the env var and chooses to start the embedded emulator or not: gym-mupen64plus/gym_mupen64plus/envs/mupen64plus_env.py Lines 81 to 90 in 61228ff
I would suggest troubleshooting why the agent is starting its own emulator. If you can ensure only one instance is started, it should work better 🤞 |
Hello @bzier, thank you for your responses :D ! -Indeed, i've checked the MD5 (with Mupen64++, i haven't other tools to check that) and the hash is different : -I use the DockerFile you've linked yeah ! That was base of one i found in this repo but... if the base image is different, maybe it's adapted to newer Python version ? -Thanks for the references about the navigation, i tried to edit some values here but it was not constantly solved the problem :') So, the "solution" i've found for now, is to generate a savestate file with Mupen64plus (outside the project, i have not the code to generate savestate and there is no code about that in this repo') when the game load the race i will and load the savestate in the agent container (in docker-compose), like : About the multiples emulators, maybe i have trouble with that yeah, i'll check about that ! My initial goal was to implement A3C Agent with that structure. The first attempt i made is to create multiple Agent in the code (for loop, multiple processes with Pytorch) but... when there is multiple environnement on GymMupen64plus, there is some problems with port and ip adresses. I didn't know how to adapt... Is there a way to be sure that the port and IP are different for all initialization of servers ? So what i tried after, is to create a structure of multiple agent with Docker, like here (with a container that contain Master Agent, and others containers Agent that i can initialize with --scale). So yeah, i think the main problem i have is about multiple instances of the env, maybe there is something i can't catch about that. |
This was how I had done A3C training on Mario Kart years ago: mario-kart-agent. (I'm not sure what condition the repo is in. I had forked the openai/universe-starter-agent repo and that one was deprecated a while ago.) It implemented the A3C algorithm, and used multiple worker processes to train. I dockerized them so each worker could run in its own container. Importantly, each one is not using If you want to just run a single agent, the docker-compose file in this repo is a clean way to do that and to separate the different processes. However, if you want to run multiple independent agents (i.e. not multiplayer, but multiple separate emulators), it is probably easiest to leave it embedded without using Hope that is somewhat helpful. Let me know if I can clarify any of that further. |
Ow i see ! Thank you very much for your message ! :D |
Hello !
I have a trouble with Gym-mupen64plus environnement and i don't know what to do.
When i start my project with Docker Container, the game doesn't go in Times Trials mode after the env initialization.
When i tested it with my agent script, it often bring me to the menu and my train code is executed there, which gives random behavior, like this video shows :
https://youtu.be/khSQw54nHMc
I tried to run the example script too (in case it's my code who has trouble), but it brings me all the time in GrandPrix and i have an incorrect HUD :/ Like this video shows :
https://youtu.be/phmREvLZGM0
I have the good version of Gym (0.7.4) and the other librairies (i used the DockerFile of this repo as a base), and my DockerFile set up the 3.7.9 Python Version.
What i wonder is... where is the problem ? Seems the env initailization (like the buttons presess for navigate through menu) doesn't work properly for me, is this a problem of frames ? It looks like that the script execute button too faster for the game, if we look at the container logs in the vids ?
Thanks in advance for your responses, have a nice day !
The text was updated successfully, but these errors were encountered: