Coder Social home page Coder Social logo

mametoolkit's Introduction

The MAME RL Algorithm Training Toolkit

About

This Python library will allow you to train your reinforcement learning algorithm on almost any arcade game. It is currently available on Linux systems and works as a wrapper around MAME. The toolkit allows your algorithm to step through gameplay while recieving the frame data and internal memory address values for tracking the games state, along with sending actions to interact with the game.

Requirements:

  • Operating system: Vast majority of desktop and server Linux distributions
  • Instruction set: amd64 (this includes intel CPUs)
  • Python version: 3.6 or greater

NOTE: If you are using an uncommon linux distribution or a CPU with a different instruction set, see section Compiling custom MAME.

Installation

You can use pip to install the library, just run:

pip install MAMEToolkit

DISCLAIMER: We are unable to provide you with any game ROMs. It is the users own legal responsibility to acquire a game ROM for emulation. This library should only be used for non-commercial research purposes.

There are some free ROMs available at: https://www.mamedev.org/roms/

Sponsorship & Future Development ❤️

I have just joined the Github Sponsors program and would appreciate any donations towards future development on this project. There are a plans to extend and improve upon this library, and with your help we can make this happen. If you would like to show your appreciation or request a new game environment/feature be added, feel free to go to https://github.com/sponsors/M-J-Murray and become a sponsor today!

The sponsor page also outlines future plans and optimisations which will help improve the library for everyone.

Street Fighter Random Agent Demo

The toolkit has currently been applied to Street Fighter III Third Strike: Fight for the Future (Japan 990608, NO CD), but can modified for any game available on MAME. The following demonstrates how a random agent can be written for a street fighter environment.

import random
from MAMEToolkit.sf_environment import Environment

roms_path = "roms/"  # Replace this with the path to your ROMs
env = Environment("env1", roms_path)
env.start()
while True:
    move_action = random.randint(0, 8)
    attack_action = random.randint(0, 9)
    frames, reward, round_done, stage_done, game_done = env.step(move_action, attack_action)
    if game_done:
        env.new_game()
    elif stage_done:
        env.next_stage()
    elif round_done:
        env.next_round()

The toolkit also supports hogwild training:

from multiprocessing import Process
import random
from MAMEToolkit.sf_environment import Environment


def run_env(worker_id, roms_path):
    env = Environment(f"env{worker_id}", roms_path)
    env.start()
    while True:
        move_action = random.randint(0, 8)
        attack_action = random.randint(0, 9)
        frames, reward, round_done, stage_done, game_done = env.step(move_action, attack_action)
        if game_done:
            env.new_game()
        elif stage_done:
            env.next_stage()
        elif round_done:
            env.next_round()


workers = 8
# Environments must be created outside of the threads
roms_path = "roms/"  # Replace this with the path to your ROMs
threads = [Process(target=run_env, args=(i, roms_path)) for i in range(workers)]
[thread.start() for thread in threads]

Setting Up Your Own Game Environment

Game ID's
To create an emulation of the game you must first have the ROM for the game you are emulating and know the game ID used by MAME, for example for this version of street fighter it is 'sfiii3n'. The id of your game can be found by running:

from src.MAMEToolkit.emulator import see_games
see_games()

This will bring up the MAME emulator. You can search through the list of games to find the one you want. The id of the game is always in brackets at the end of the game title.

Memory Addresses
It doesn't take much to interact with the emulator itself using the toolkit, however the challenge comes from finding the memory address values associated with the internal state you care about, and tracking said state with your environment class. The internal memory states of a game can be tracked using the MAME Cheat Debugger, which allows you to track how the memory address values of the game change over time.

The cheat debugger can be run using the following:

from src.MAMEToolkit.emulator import run_cheat_debugger
roms_path = "roms/" # Replace this with the path to your ROMs
game_id = "sfiii3n"
run_cheat_debugger(roms_path, game_id)

For information about using the debugger, see the Memory dump section of the following tutorial

Once you have determined the memory addresses you wish to track you can start the emulation using:

from src.MAMEToolkit.emulator import Emulator
from src.MAMEToolkit.emulator import Address

roms_path = "roms/"  # Replace this with the path to your ROMs
game_id = "sfiii3n"
memory_addresses = {
        "fighting": Address('0x0200EE44', 'u8'),
        "winsP1": Address('0x02011383', 'u8'),
        "winsP2": Address('0x02011385', 'u8'),
        "healthP1": Address('0x02068D0B', 's8'),
        "healthP2": Address('0x020691A3', 's8')
    }
    
emulator = Emulator("env1", roms_path, game_id, memory_addresses)

This will immediately start the emulation and halt it when the toolkit has linked to the emulator process.

Stepping the emulator
Once the toolkit is linked, you can step the emulator along using the step function:

data = emulator.step([])

frame = data["frame"]
is_fighting = data["fighting"]
player1_wins = data["winsP1"]
player2_wins = data["winsP2"]
player1_health = data["healthP1"]
player2_health = data["healthP2"]

The step function returns the frame data as a NumPy matrix, along with all of the memory address integer values from that timestep.

Sending inputs To send actions to the emulator you also need to determine which input ports and fields the game supports. For example, with street fighter to insert a coin the following code is required:

from src.MAMEToolkit.emulator import Action

insert_coin = Action(':INPUTS', 'Coin 1')
data = emulator.step([insert_coin])

To identify which ports are availble use the list actions command:

from src.MAMEToolkit.emulator import list_actions

roms_path = "roms/"  # Replace this with the path to your ROMs
game_id = "sfiii3n"
print(list_actions(roms_path, game_id))

which for street fighter returns the list with all the ports and fields available for sending actions to the step function:

[
    {'port': ':scsi:1:cdrom:SCSI_ID', 'field': 'SCSI ID'}, 
    {'port': ':INPUTS', 'field': 'P2 Jab Punch'}, 
    {'port': ':INPUTS', 'field': 'P1 Left'}, 
    {'port': ':INPUTS', 'field': 'P2 Fierce Punch'}, 
    {'port': ':INPUTS', 'field': 'P1 Down'}, 
    {'port': ':INPUTS', 'field': 'P2 Down'}, 
    {'port': ':INPUTS', 'field': 'P2 Roundhouse Kick'}, 
    {'port': ':INPUTS', 'field': 'P2 Strong Punch'}, 
    {'port': ':INPUTS', 'field': 'P1 Strong Punch'}, 
    {'port': ':INPUTS', 'field': '2 Players Start'}, 
    {'port': ':INPUTS', 'field': 'Coin 1'}, 
    {'port': ':INPUTS', 'field': '1 Player Start'}, 
    {'port': ':INPUTS', 'field': 'P2 Right'}, 
    {'port': ':INPUTS', 'field': 'Service 1'}, 
    {'port': ':INPUTS', 'field': 'Coin 2'}, 
    {'port': ':INPUTS', 'field': 'P1 Jab Punch'}, 
    {'port': ':INPUTS', 'field': 'P2 Up'}, 
    {'port': ':INPUTS', 'field': 'P1 Up'}, 
    {'port': ':INPUTS', 'field': 'P1 Right'}, 
    {'port': ':INPUTS', 'field': 'Service Mode'}, 
    {'port': ':INPUTS', 'field': 'P1 Fierce Punch'}, 
    {'port': ':INPUTS', 'field': 'P2 Left'}, 
    {'port': ':EXTRA', 'field': 'P2 Short Kick'}, 
    {'port': ':EXTRA', 'field': 'P2 Forward Kick'}, 
    {'port': ':EXTRA', 'field': 'P1 Forward Kick'}, 
    {'port': ':EXTRA', 'field': 'P1 Roundhouse Kick'}, 
    {'port': ':EXTRA', 'field': 'P1 Short Kick'}
]

We advise you to create an enum of all the possible actions, then send their action values to the emulator, see the example Actions Enum

There is also the problem of transitioning games between non-learnable gameplay screens such as the title screen and character select. To see how this can be implemented please look at the provided Steps script and the Example Street Fighter III Third Strike: Fight for the Future Environment Implementation

The emulator class also has a frame_ratio argument which can be used for adjusting the frame rate seen by your algorithm. By default MAME generates frames at 60 frames per second, however, this may be too many frames for your algorithm. The toolkit by default will use a frame_ratio of 3, which means that 1 in 3 frames are sent through the toolkit, this converts the frame rate to 20 frames per second. Using a higher frame_ratio also increases the performance of the toolkit.

from src.MAMEToolkit.emulator import Emulator

emulator = Emulator(env_id, roms_path, game_id, memory_addresses, frame_ratio=3)

Running The Library Without A Screen / On A Linux Server

If you are running a linux server or a docker instance then you will need to add some extra code to your python script to enable MAME to run. To achieve this we will be using the Xvfb library, which will simulate an instance of the X display server. Simply install the Xvfb library for your relevant linux distro. Then add to the following two lines to the top of your main Python script.

import os
os.system("Xvfb :0 -screen 0 800x600x16 +extension RANDR &")
os.environ["DISPLAY"] = ":0"

This will simulate a 800x600 resolution screen with 16-bit colour. Feel free to change the parameters to suit your needs.

Library Performance Benchmarks with PC Specs

The development and testing of this toolkit have been completed on an 8-core AMD FX-8300 3.3GHz CPU along with a 3GB GeForce GTX 1060 GPU. With a single random agent, the street fighter environment can be run at 600%+ the normal gameplay speed. And For hogwild training with 8 random agents, the environment can be run at 300%+ the normal gameplay speed.

Simple ConvNet Agent

To ensure that the toolkit is able to train algorithms, a simple 5 layer ConvNet was setup with minimal tuning. The algorithm was able to successfully learn some simple mechanics of Street Fighter, such as combos and blocking. The Street Fighter gameplay works by having the player fight different opponents across 10 stages of increasing difficulty. Initially, the algorithm would reach stage 2 on average, but eventually could reach stage 5 on average after 2200 episodes of training. The learning rate was tracked using the net damage done vs damage taken of a single playthough for each episode.

MAME Changes

The library acts as a wrapper around a modified MAME implementation. The following changes were made:

  • Updated the lua console to allow for the retrieval of the format of frame data
  • Update the lua console to allow for the retrieval of the current frames data
  • Disabled game start warnings

The following files are affected:

  • src/emu/machine.cpp
  • src/emu/video.cpp
  • src/emu/video.h
  • src/frontend/mame/luaengine.cpp
  • src/frontend/mame/ui/ui.cpp
  • src/osd/sdl/window.cpp

The modified MAME implementation can be found at [https://github.com/M-J-Murray/mame]

Compiling custom MAME

Unfortunately this library doesn't work with every single OS or CPU instruction set. This is because it uses a custom precompiled instance of MAME that is specific to the OS and CPU it was compiled on. However, if you are using a different linux distribution or instruction set, this does not mean you are out of options, it just means that your path to using this library is a little more complicated. Your only remaining option is to compile the custom instance of MAME yourself. To achieve this you just need a linux distribution with a GUI. Other operating systems will not work, as the library relies heavily on linux fifo pipes.

Compilation steps

To compile your own custom instance of MAME run the following commands in your terminal:

git clone [email protected]:M-J-Murray/mame.git
cd mame
make SUBTARGET=arcade -j4

Adjust j to match the amount of virtual cores your CPU supports, as this could take several hours depending on your computer.

Once the compilation has completed you should have an executable file called mamearcade64, or something along those lines. Now you can either use the binary_path keyword argument on your emulator method calls to point at your custom binary, or you can rename said executable to mame and replace the precompiled MAME instance in your python MAMEToolkit directory with your new file. You should be able to find the MAMEToolkit directory by going to your python environment directory, and then going to site-packages.

Troubleshooting

This section describes what to do if your make command fails with some kind of error message describing an incorrect/missing library. As different linux distributions implement different libraries by default it is likely that you will not have the correct libraries installed by default. These libraries will also need to be specific to your CPU instruction set. Writing all the library installation commands for all linux distributions and instruction sets would be extremely difficult, however, I can outline the libraries that MAME requires. The list is as follows:

  • libdl
  • librt
  • libSDL2-2.0
  • libpthread
  • libutil
  • libGL
  • libasound
  • libQt5Widgets
  • libQt5Gui
  • libQt5Core
  • libX11
  • libSDL2_ttf-2.0
  • libfontconfig
  • libstdc++
  • libm
  • libgcc_s
  • libc

Your error message should indicate that at least one of these libraries is missing. To install said library you will need to look online and find out how to install/update the library for your relevant linux distribution and instruction set. Use the following as a google search template: "{linux distribution} {CPU instruction set} install {missing library}" Just replace the curly brackets with the information relevant to you. Hopefully you should be able to find the relevant install command on a forum. If the missing library isn't available for your distro/cpu then the MAMEToolkit will not work for you.

Once you have installed your library just run make again and it will continue where it left off, you will not lose your compilation progress.

mametoolkit's People

Contributors

m-j-murray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mametoolkit's Issues

Qt platform plugin "xcb" not found --- calling run_cheat_debugger()

I can get Joust running with the emulator. I have to press F10 at the start to fix a speed issue.
I can't use the cheat debugger, apparently, as that's what's different.

Based on reading about this type of error, the solution is usually hard to find, and has nothing to do with the Qt installation or path variables.

joust2.py

from MAMEToolkit.emulator import run_cheat_debugger

roms_path = "/home/pc2/Desktop/MAME_Test/"  # Replace this with the path to your ROMs
game_id = "joust"

run_cheat_debugger(roms_path, game_id)

Running it:

pc2@PC:~/Desktop/MAME_Test$ python3 joust2.py
Debug Build: Disabling input grab for -debug
Debug Build: Disabling input grab for -debug
Debug Build: Disabling input grab for -debug
QFactoryLoader::QFactoryLoader() checking directory path "/home/pc2/.local/lib/python3.9/site-packages/MAMEToolkit/emulator/mame/platforms" ...
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Reinstalling the application may fix this problem.
b'\x1b[1;36m[MAME]\x1b[0m> '
pc2@PC:~/Desktop/MAME_Test$ 

Python 3.9.5
Ubuntu 21.04

Environment() setup time seems very long

Problem:

When creating any Environment, it takes a significant amount of time to return to code execution while the emulator is already running.

Minimal example:

import datetime

from MAMEToolkit.sf_environment import Environment

roms_path = 'roms/'
start = datetime.datetime.now()
env = Environment('env1', roms_path)
end = datetime.datetime.now()
print('Time to set up env: {}'.format(end-start))
env.start()
env.close()

Time to set up env: 0:00:12.894005

In my case, when not throttling, the setup time is much longer than the emulation itself, adding significant overhead to training time. Also, I am forced to reload the save state I am working with in env.start() since the emulator has been running for ~13s already.

Question:

Is this delay expected behaviour? If not, is there a way to reduce it?

Enable sound when throttle = True?

Hey there,
I'm basing an agent on your framework. It's very helpful.
One question, when I want to demonstrate my agent play in real-time with frame_ratio=1 and throttle = True, is it possible to enable sound? Of course, I will use faster settings while training.
Thanks in advance!

Exception when pip install MAMEToolkit

pip install MAMEToolkit
Collecting MAMEToolkit
Downloading https://files.pythonhosted.org/packages/e9/ad/39864cd62b6aa1ef9bfcf53df21c8922ffab7f353fdde6daefcf6a69816a/MAMEToolkit-1.0.2-py3-none-any.whl (60.3MB)
Exception:
Traceback (most recent call last):
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_vendor\urllib3\response.py", line 360, in _error_catcher
yield
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_vendor\urllib3\response.py", line 442, in read
data = self._fp.read(amt)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_vendor\cachecontrol\filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\http\client.py", line 447, in read
n = self.readinto(b)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\http\client.py", line 491, in readinto
n = self.fp.readinto(b)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\ssl.py", line 1052, in recv_into
return self.read(nbytes, buffer)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\ssl.py", line 911, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\cli\base_command.py", line 179, in main
status = self.run(options, args)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\commands\install.py", line 315, in run
resolver.resolve(requirement_set)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\resolve.py", line 131, in resolve
self._resolve_one(requirement_set, req)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\resolve.py", line 294, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\resolve.py", line 242, in _get_abstract_dist_for
self.require_hashes
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\operations\prepare.py", line 334, in prepare_linked_requirement
progress_bar=self.progress_bar
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\download.py", line 878, in unpack_url
progress_bar=progress_bar
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\download.py", line 702, in unpack_http_url
progress_bar)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\download.py", line 946, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\download.py", line 639, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\utils\hashes.py", line 62, in check_against_chunks
for chunk in chunks:
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\download.py", line 607, in written_chunks
for chunk in chunks:
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\utils\ui.py", line 159, in iter
for x in it:
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_internal\download.py", line 596, in resp_read
decode_content=False):
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_vendor\urllib3\response.py", line 494, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_vendor\urllib3\response.py", line 459, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\contextlib.py", line 130, in exit
self.gen.throw(type, value, traceback)
File "d:\users\hi\appdata\local\programs\python\python37-32\lib\site-packages\pip_vendor\urllib3\response.py", line 365, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

Error No output expected from command 'mem = manager:machine().devices[":maincpu"].spaces["program"]'

I tried to see my game id by running
e = Emulator("test_env", roms_path, "", {}, binary_path="/usr/local/lib/python3.6/dist-packages/MAMEToolkit/emulator/mame/mamearcade64")

But I got error of

No output expected from command 'mem = manager:machine().devices[":maincpu"].spaces["program"]', but recieved: error: 	[string "..."]:2: attempt to index a nil value (field ':maincpu')
Traceback (most recent call last):
  File "test.py", line 15, in <module>
    test_mame()
  File "test.py", line 7, in test_mame
    e = Emulator("test_env", roms_path, "", {}, binary_path="/usr/local/lib/python3.6/dist-packages/MAMEToolkit/emulator/mame/mamearcade64")
  File "/usr/local/lib/python3.6/dist-packages/MAMEToolkit/emulator/Emulator.py", line 56, in __init__
    self.create_lua_variables()
  File "/usr/local/lib/python3.6/dist-packages/MAMEToolkit/emulator/Emulator.py", line 91, in create_lua_variables
    self.console.writeln('mem = manager:machine().devices[":maincpu"].spaces["program"]')
  File "/usr/local/lib/python3.6/dist-packages/MAMEToolkit/emulator/Console.py", line 94, in writeln
    raise IOError(error)
OSError: No output expected from command 'mem = manager:machine().devices[":maincpu"].spaces["program"]', but recieved: error: 	[string "..."]:2: attempt to index a nil value (field ':maincpu')

Did I set up things right? or this is a MAME issue?

NOTE:
By running pip3 install MAMEToolkit, MAME isn't installed and the .mame isn't found. So I built mame my self with

cd /usr/local/lib/python3.6/dist-packages/MAMEToolkit/emulator && \                             
git clone https://github.com/M-J-Murray/mame.git && cd mame && \                                
make SUBTARGET=arcade -j4

get gemini wing actions fail

I use the list actions command:

from MAMEToolkit.emulator import list_actions

roms_path = "roms/" # Replace this with the path to your ROMs
game_id = "sfiii3n"
print(list_actions(roms_path, game_id))

I get:
[{'port': ':INPUTS', 'field': 'P2 Strong Punch'}, {'port': ':INPUTS', 'field': 'P1 Strong Punch'}, {'port': ':INPUTS', 'field': 'P2 Left'}, {'port': ':INPUTS', 'field': 'Service Mode'}, {'port': ':INPUTS', 'field': 'P2 Up'}, {'port': ':INPUTS', 'field': 'P1 Up'}, {'port': ':INPUTS', 'field': 'P1 Fierce Punch'}, {'port': ':INPUTS', 'field': 'P1 Jab Punch'}, {'port': ':INPUTS', 'field': 'P2 Jab Punch'}, {'port': ':INPUTS', 'field': 'P2 Down'}, {'port': ':INPUTS', 'field': 'P1 Down'}, {'port': ':INPUTS', 'field': 'P2 Fierce Punch'}, {'port': ':INPUTS', 'field': '2 Players Start'}, {'port': ':INPUTS', 'field': 'Coin 2'}, {'port': ':INPUTS', 'field': 'Service 1'}, {'port': ':INPUTS', 'field': '1 Player Start'}, {'port': ':INPUTS', 'field': 'P2 Roundhouse Kick'}, {'port': ':INPUTS', 'field': 'Coin 1'}, {'port': ':INPUTS', 'field': 'P1 Left'}, {'port': ':INPUTS', 'field': 'P2 Right'}, {'port': ':INPUTS', 'field': 'P1 Right'}, {'port': ':scsi:1:cdrom:SCSI_ID', 'field': 'SCSI ID'}, {'port': ':EXTRA', 'field': 'P2 Short Kick'}, {'port': ':EXTRA', 'field': 'P1 Short Kick'}, {'port': ':EXTRA', 'field': 'P1 Forward Kick'}, {'port': ':EXTRA', 'field': 'P2 Forward Kick'}, {'port': ':EXTRA', 'field': 'P1 Roundhouse Kick'}]

When I change game_id.
game_id = "gemini"
I get:
Expected output but received nothing from emulator after 'for k,v in pairs(iop.ports[':SYS_0'].fields) do print(k) end'
Traceback (most recent call last):
File "list_actions.py", line 7, in
print(list_actions(roms_path, game_id))
File "/usr/local/lib/python3.6/site-packages/MAMEToolkit/emulator/Emulator.py", line 21, in list_actions
fields = console.writeln("for k,v in pairs(iop.ports['"+port+"'].fields) do print(k) end", expect_output=True)
File "/usr/local/lib/python3.6/site-packages/MAMEToolkit/emulator/Console.py", line 71, in writeln
raise IOError(error)
OSError: Expected output but received nothing from emulator after 'for k,v in pairs(iop.ports[':SYS_0'].fields) do print(k) end'

How should I solve this problem?

Libraries not found when running MAME via python

I get an error that some libraries are not found when trying to run run_cheat_debugger().

>>> roms_path = "/home/syafiq/mame/roms/"
>>> game_id = "carpolo"
>>> from MAMEToolkit.emulator import run_cheat_debugger
>>> run_cheat_debugger(roms_path, game_id)
./mame: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by ./mame)
./mame: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.9' not found (required by ./mame)
./mame: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5' not found (required by ./mame)
./mame: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: version `Qt_5' not found (required by ./mame)
./mame: /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5: version `Qt_5' not found (required by ./mame)

At this point the program just hangs.

I've compiled your version of mame, cloned for the master branch. Am I supposed to place the mame program in some specific folder or install some additional libraries via apt-get?

I'm running on Ubuntu 16.04, Python 3.6.6 (Anaconda) and installed the MAMEToolkit via pip.

Emulator() call never hooks and returns - just runs MAME

I'm invoking it as follows, but it does not return - so I'm guessing it cannot hook the emulator.

emulator = Emulator("env1", 
                    roms_path, 
                    game_id, 
                    memory_addresses,
                    1,          # Ratio of frames reported
                    True,       # Render the little window
                    False,      # Throttle the emulator to realtime
                    5,          # 
                    False,      # Sound
                    True,      # Debug
                    "/home/dave/source/repos/CustomMameForToolkit/mame/mamearcade64")

I'm using the custom name and providing the path to it - any other ideas? I've tried with Debug set to True and Falsse, and without any of the optional params other than the binary_path, to no avail.

Thanks!
Dave

Memory values (or addresses) don't seem to match the MAME debugger

I'm trying to use the toolkit with a different game, but when I query the memory addresses I don't find the values I expect from the cheat_debugger. Is there a memory offset with the addresses given by the MAME debugger and the ones that should be specified in the environment? or there's some other detail that I'm missing?

SF3 wont work

I download the SF3 rom and I keep encountering this issues

sfiii3_japan_nocd.29f400.u2 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm1.0 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm1.1 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm1.2 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm1.3 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm2.0 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm2.1 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm2.2 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm2.3 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.0 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.1 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.2 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.3 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.4 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.5 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.6 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm3.7 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.0 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.1 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.2 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.3 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.4 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.5 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.6 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm4.7 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.0 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.1 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.2 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.3 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.4 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.5 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.6 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm5.7 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.0 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.1 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.2 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.3 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.4 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.5 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.6 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
sfiii3-simm6.7 NOT FOUND (tried in sfiii3n sfiii3 sfiii3n)
Fatal error: Required files are missing, the machine cannot be run.

I have those files in the rom path that I am sending to, yet I still encounter this issue.

Sample code problem

I want to ask what this "game_id" really is and how I can import the zip game file in roms. The code is as follows:

from MAMEToolkit.emulator import list_actions

roms_path = "roms/" # Replace this with the path to your ROMs
game_id = "supertank.zip"
print(list_actions(roms_path, game_id))

/home/lhs/.conda/envs/mame_project/bin/python /home/lhs/PycharmProjects/mame_project/mt_2.py
Unknown system 'supertank.zip'

"supertank.zip" approximately matches the following
supported machines (best match first):

Links from this part of readme aren't working:

He links in this part of documentation at ( https://github.com/M-J-Murray/MAMEToolkit) seems invalid:


There is also the problem of transitioning games between non-learnable gameplay screens such as the title screen and character select. To see how this can be implemented please look at the provided Steps script and the Example Street Fighter III Third Strike: Fight for the Future Environment Implementation```

Those are:
https://github.com/M-J-Murray/MAMEToolkit/blob/master/MAMEToolkit/sf_environment/Actions.py

https://github.com/M-J-Murray/MAMEToolkit/blob/master/MAMEToolkit/sf_environment/Steps.py

https://github.com/M-J-Murray/MAMEToolkit/blob/master/MAMEToolkit/sf_environment/Environment.py


And probably should be: 

https://github.com/M-J-Murray/MAMEToolkit/blob/master/src/MAMEToolkit/sf_environment/Actions.py

https://github.com/M-J-Murray/MAMEToolkit/blob/master/src/MAMEToolkit/sf_environment/Steps.py

https://github.com/M-J-Murray/MAMEToolkit/blob/master/src/MAMEToolkit/sf_environment/Environment.py

Error while loading shared lib ?

Hello,

I'm trying to get the see_games to run or the random agent, but I get the following error message:

./mame: error while loading shared libraries: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory

Could I get some help ? Thanks !

OSError: Expected output but received nothing from emulator after 'print(manager:machine().screens[":screen"])'

I tried to execute your demo code and I got a OSError.
OSError: Expected output but received nothing from emulator after 'print(manager:machine().screens[":screen"])'

import random
from MAMEToolkit.sf_environment import Environment

roms_path = "roms/" # Replace this with the path to your ROMs
env = Environment("env1", roms_path)
env.start()
while True:
move_action = random.randint(0, 8)
attack_action = random.randint(0, 9)
frames, reward, round_done, stage_done, game_done = env.step(move_action, attack_action)
if game_done:
env.new_game()
elif stage_done:
env.next_stage()
elif round_done:
env.next_round()

How can I fix it?
I use Ubuntu 16.04.

gemini wing agents can't work

I am write agents for gemini wing. my WorkerUtils.py at
GeminiAgents/tensorflow_simple/WorkerUtils.py

def prepro(frames):
x = []
for frame in frames:
frame = frame[32:214, 12:372] # crop
frame = 0.2989 * frame[:, :, 0] + 0.5870 * frame[:, :, 1] + 0.1140 * frame[:, :, 2] # greyscale
frame = frame[::3, ::3] # downsample
frame = frame/255
frame = frame-frame.mean()
x.append(frame.reshape(1, 61, 120))
return np.stack(x, axis=3).astype("float32")

When i run agents, I get error:
Traceback (most recent call last):
File "/home/guanzeying/GeminiAgents/tensorflow_simple/Worker.py", line 55, in run
observation = wu.prepro(frames)
File "/home/guanzeying/GeminiAgents/tensorflow_simple/WorkerUtils.py", line 14, in prepro
x.append(frame.reshape(1, 61, 120))
ValueError: cannot reshape array of size 5002 into shape (1,61,120)

How should I solve this problem?

appendix:
gemini solution:
RGB32 - 32bpp 8-8-8 RGB
width: 256
height: 224

sfiii3n solution:
RGB32 - 32bpp 8-8-8 RGB
width: 384
height: 224

get Error "FileNotFoundError: [Errno 2] No such file or directory"

I got error like this, does it mean I have to compile it manually?

I just ran the example:

import random
from MAMEToolkit.sf_environment import Environment

# roms_path = "roms/sf2ceua"  # Replace this with the path to your ROMs
# roms_path = r"roms/"  # Replace this with the path to your ROMs
roms_path = "roms/"  # Replace this with the path to your ROMs
env = Environment("env1", roms_path)
env.start()
while True:
    move_action = random.randint(0, 8)
    attack_action = random.randint(0, 9)
    frames, reward, round_done, stage_done, game_done = env.step(
        move_action, attack_action)
    if game_done:
        env.new_game()
    elif stage_done:
        env.next_stage()
    elif round_done:
        env.next_round()

and got error like this:

root@dbsx-PC:/home/dbsx/Desktop/project# python try.py 
Traceback (most recent call last):
  File "try.py", line 2, in <module>
    see_games()
  File "/root/anaconda3/lib/python3.6/site-packages/MAMEToolkit/emulator/Emulator.py", line 33, in see_games
    Emulator("env1", "", "", {}, binary_path=binary_path)
  File "/root/anaconda3/lib/python3.6/site-packages/MAMEToolkit/emulator/Emulator.py", line 53, in __init__
    self.console = Console(roms_path, game_id, render=render, throttle=throttle, frame_skip=frame_skip, sound=sound, debug=debug, binary_path=binary_path)
  File "/root/anaconda3/lib/python3.6/site-packages/MAMEToolkit/emulator/Console.py", line 50, in __init__
    self.process = Popen(command, cwd=mame_path, shell=True, stdin=PIPE, stdout=PIPE)
  File "/root/anaconda3/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/root/anaconda3/lib/python3.6/subprocess.py", line 1333, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: '/root/anaconda3/lib/python3.6/site-packages/MAMEToolkit/emulator/mame'

Do I have to compile it ?

I had to modify mamearcade.make - others may need this too.

in the file ... /mame/build/projects/sdl/mamearcade/gmake-linux/mamearcade.make

Every line containing the following (6 of them) needs to be modified to end with -lSLD2, as shown.
LIBS += $(LDDEPS) -ldl -lrt -lm -lpthread -lutil -lGL -lasound -lQt5Widgets -lQt5Gui -lQt5Core -lX11 -lXinerama -lXext -lXi -lSDL2_ttf -lfontconfig -lfreetype -lSDL2

Just search for -lfreetype, the current end of those lines, as this only occurs in the 6 relevant places.

Without this change, the following error occurs:

...
/usr/bin/ld: ../../../../linux_gcc/bin/x64/Release/mame_arcade/libosd_sdl.a(sdlmain.o): undefined reference to symbol 'SDL_GetVideoDriver'
/usr/bin/ld: /lib/x86_64-linux-gnu/libSDL2-2.0.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [mamearcade.make:251: ../../../../../mamearcade64] Error 1
make[1]: *** [Makefile:409: mamearcade] Error 2
make[1]: Leaving directory '/home/pc2/Desktop/MAME_Test/Make_MAME/mame/build/projects/sdl/mamearcade/gmake-linux'
make: *** [makefile:1293: linux_x64] Error 2

My system:
Ubuntu 20.04.2 LTS
Python 3.8.10 (included with Ubuntu LTS)
sudo apt-get install python-is-python3

Will not print the list from list_actions

parallels@parallels-Parallels-Virtual-Platform:~$ cat sfla.py
from MAMEToolkit.emulator import list_actions

roms_path = "roms/" # Replace this with the path to your ROMs
game_id = "sfiii3n"
print(list_actions(roms_path, game_id))

Seeing:

arallels@parallels-Parallels-Virtual-Platform:~$ python3.6 ./sfla.py
unzip: /home/parallels/roms/sfiii3.zip couldn't find ECD in last 64KiB
Expected output but received nothing from emulator after 'for k,v in pairs(iop.ports) do print(k) end'
Traceback (most recent call last):
File "./sfla.py", line 5, in
print(list_actions(roms_path, game_id))
File "/home/parallels/.local/lib/python3.6/site-packages/MAMEToolkit/emulator/Emulator.py", line 19, in list_actions
ports = console.writeln("for k,v in pairs(iop.ports) do print(k) end", expect_output=True, timeout=0.5)
File "/home/parallels/.local/lib/python3.6/site-packages/MAMEToolkit/emulator/Console.py", line 71, in writeln
raise IOError(error)
OSError: Expected output but received nothing from emulator after 'for k,v in pairs(iop.ports) do print(k) end'

Thanks,

Rick

ImportError: No module named MAMEToolkit.sf_environment

Hello, just installed on macOS:

$ sudo -H pip install MAMEToolkit
Password:
Collecting MAMEToolkit
  Downloading https://files.pythonhosted.org/packages/db/ad/dfa33e9ec2e96001f73b99b528af06fe32f39722a27123393f034bc4d038/MAMEToolkit-1.0.1.tar.gz (59.9MB)
    100% |████████████████████████████████| 59.9MB 60kB/s 
Building wheels for collected packages: MAMEToolkit
  Running setup.py bdist_wheel for MAMEToolkit ... done
  Stored in directory: /var/root/Library/Caches/pip/wheels/39/f7/7e/d0b7f5568ba6535eb224fa2238f6f061d814b89909e70b6656
Successfully built MAMEToolkit
Installing collected packages: MAMEToolkit
Successfully installed MAMEToolkit-1.0.1
ip-192-168-1-103:~ loretoparisi$ python
Python 2.7.15 (default, May 10 2018, 18:56:10) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> from MAMEToolkit.sf_environment import Environment
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named MAMEToolkit.sf_environment

And therefore tried virtualenv:

$ virtualenv venv
New python executable in /Users/loretoparisi/Documents/Projects/AI/games/venv/bin/python
Installing setuptools, pip, wheel...done.
ip-192-168-1-103:games loretoparisi$ . venv/bin/activate
(venv) ip-192-168-1-103:games loretoparisi$ pip install MAMEToolkit
Collecting MAMEToolkit
  Downloading https://files.pythonhosted.org/packages/db/ad/dfa33e9ec2e96001f73b99b528af06fe32f39722a27123393f034bc4d038/MAMEToolkit-1.0.1.tar.gz (59.9MB)
    100% |████████████████████████████████| 59.9MB 133kB/s 
Building wheels for collected packages: MAMEToolkit
  Running setup.py bdist_wheel for MAMEToolkit ... done
  Stored in directory: /Users/loretoparisi/Library/Caches/pip/wheels/39/f7/7e/d0b7f5568ba6535eb224fa2238f6f061d814b89909e70b6656
Successfully built MAMEToolkit
Installing collected packages: MAMEToolkit
Successfully installed MAMEToolkit-1.0.1
(venv) ip-192-168-1-103:games loretoparisi$ python
Python 2.7.10 (default, Aug 17 2018, 17:41:52) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from MAMEToolkit.sf_environment import Environment
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/loretoparisi/Documents/Projects/AI/games/venv/lib/python2.7/site-packages/MAMEToolkit/__init__.py", line 1, in <module>
    from MAMEToolkit import emulator
  File "/Users/loretoparisi/Documents/Projects/AI/games/venv/lib/python2.7/site-packages/MAMEToolkit/emulator/__init__.py", line 2, in <module>
    from MAMEToolkit.emulator.Emulator import Emulator, list_actions, see_games, run_cheat_debugger
  File "/Users/loretoparisi/Documents/Projects/AI/games/venv/lib/python2.7/site-packages/MAMEToolkit/emulator/Emulator.py", line 59
    pipes_path = f"{os.path.dirname(os.path.abspath(__file__))}/mame/pipes"
                                                                          ^
SyntaxError: invalid syntax

compilation failure

I had this building on a quite old version of Ubuntu, but I'm trying to get up and running on Ubuntu 21.04 and now I'm having troubles.

In particular, I run into this error within sol2:

./../../../../3rdparty/sol2/sol/stack_push.hpp:571:40: error: call of overloaded ‘push<const char32_t*>(lua_State*&, const char32_t [2], const char32_t*)’ is ambiguous

Some googling says this is "fixed" in the latest mame, but it's clear how or where it was fixed. I don't know if merging the latest mame is feasible here.

I've tried this in gcc10, then gcc9, then gcc8, and it's the same problem with each.

Any ideas?

duplicated and missing frames

In the standard sf environment, I receive a list of 3 frames after each step.

When I plot the frames like below (each row shows the 3 frames I receive in that step) I see a pattern of 2 repeated duplicated frames. I was expecting three unique frames in each step. It looks like there is a bug in processing the frames? Maybe an indexing error?

Any idea how I can fix this?

frames

Functionality and Installation questions for macOS and Ubuntu

Hey there,

Some months ago I discovered MAME's Lua engine and I started working on a reinforcement learning project that would train on all four currently emulated Tekken games (1,2,3,Tag). I wrote a Lua script that would control the emulator, selecting and loading randomly one of the four tekken games and wait for a demo cycle. The idea was that it would communiciate with a python agent every timestep via sockets, passing state information such as p1_hp, p2_hp, p1_score, p2_score, remaining_time (which would be read from memory values) as well as a frame at the current timestep, and would receive an action to perform. I stumbled on some limitations like how sockets might be too slow and also the Lua engine of MAME cannot take extensions for portability reasons. As such, I am thinking of migrating my project to this python framework. I have a few questions.

The first questions is, is this framework as powerful as Mame's Lua library? Will I be able to change games on the fly without human interaction? My Lua script also relied extensively on emu.wait() calls, which I'm not sure if direct emu commands can be given. But this framework seems to bypass a few problems, like the game warning screen, where the only way to be skipped was with a -str 299 argument that gave you max running time of 299 seconds.

Secondly, I tried installing it to my macOS installation and I will try with Ubuntu as well.
I went into my Anaconda environment with my ML tools and used "pip install MAMEToolkit".
When I tried to run it in python

from MAMEToolkit.emulator import see_games
see_games()

I got "cannot execute binary file
/bin/sh: /Users/rielfox/anaconda3/envs/tensorflow/lib/python3.6/site-packages/MAMEToolkit/emulator/mame/mame: Undefined error: 0". I assume you have to put a compiled version of MAME in the folder "/MAMEToolkit/emulator/mame". I have a compiled version of macOS Mame, but I believe it wants the compiled modified version of MAME found here "https://github.com/M-J-Murray/mame". I tried downloading and using "make" with terminal at that folder but I get

GCC 4.2.1 detected Linking genie ld: library not found for -lgcc_s.10.4 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [../../bin/darwin/genie] Error 1 make: *** [3rdparty/genie/bin/darwin/genie] Error 2

I'm not sure if it will only work on GNU/Linux.

Thanks!

[Q] alternative for older MAME versions

I am trying to use this library with an old MAME version (0.139) that has no lua support.
(i cannot use a more recent version because i have savestates i cannot use with that)

Do you know any alternative to lua plugins?

MAMEToolkit only supports RGB32 and ARGB32 frame bit format games - Tekken 2 Environment

Hey there,
I'm continuing development on a Tekken 2 environment to base my agents on.
I have reached a point where, upon creating the environment and MAME Toolkit attempts to return the first frames, where it will crash and raise EnvironmentError("MAMEToolkit only supports RGB32 and ARGB32 frame bit format games").
I'm not sure what frame bit format Tekken 2 uses. Is this per game? Would there be a way to reformat the image so that MAME Toolkit would accept it? Also, would there be an easy way to see what frame bit format is each game and what games are compatible?

Thanks!

Emulator error when initializing the environment.

I am running the start up code in readme, I download roms in freeroms.com and replace the path as absolute path.

import random
from MAMEToolkit.sf_environment import Environment

roms_path = "/home/leafzs/software/roms/sfiii3"  # Replace this with the path to your ROMs
env = Environment("env1", roms_path)
env.start()
while True:
    move_action = random.randint(0, 8)
    attack_action = random.randint(0, 9)
    frames, reward, round_done, stage_done, game_done = env.step(move_action, attack_action)
    if game_done:
        env.new_game()
    elif stage_done:
        env.next_stage()
    elif round_done:
        env.next_round()

One mistake happened, I think the problem may come from emulator. Whether I need to install MAME in github? or there are other reason for that.

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  100
  Current serial number in output stream:  101
Traceback (most recent call last):
  File "start_up.py", line 5, in <module>
    env = Environment("env1", roms_path)
  File "/home/leafzs/.local/lib/python3.6/site-packages/MAMEToolkit/sf_environment/Environment.py", line 70, in __init__
    self.emu = Emulator(env_id, roms_path, "sfiii3n", setup_memory_addresses(), frame_ratio=frame_ratio, render=render, throttle=throttle, debug=debug)
  File "/home/leafzs/.local/lib/python3.6/site-packages/MAMEToolkit/emulator/Emulator.py", line 51, in __init__
    self.wait_for_resource_registration()
  File "/home/leafzs/.local/lib/python3.6/site-packages/MAMEToolkit/emulator/Emulator.py", line 97, in wait_for_resource_registration
    result = self.console.writeln('print(manager:machine().devices[":maincpu"].spaces["program"])', expect_output=True, timeout=3, raiseError=False)
  File "/home/leafzs/.local/lib/python3.6/site-packages/MAMEToolkit/emulator/Console.py", line 64, in writeln
    self.process.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/leafzs/.local/lib/python3.6/site-packages/MAMEToolkit/emulator/Emulator.py", line 159, in close
    self.actionPipe.close()
AttributeError: 'Emulator' object has no attribute 'actionPipe'

my roms file is like this, are there something wrong?

10  20  29f400.u2  30  31  40  41  50  51  60  61

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.