Coder Social home page Coder Social logo

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

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

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.

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!

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?

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 ?

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?

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

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

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

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

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

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

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

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

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.

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!

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?

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!

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

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.

[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?

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):

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.

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?

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.