rubinstu
Posts: 1
Joined: Tue Feb 23, 2021 9:28 pm

Client-Server model for control

Here is my idea. I would not be surprised if someone has already done it, or something similar. If that's the case, please do let me know!

The ultimate goal is to have a platform for controlling game play with algorithms, AI, machine learning, etc. I would like to embed a TCP-based server into MAME. The server has access to the same data and controls as the Lua engine - reading and writing data, controlling the inputs, etc.

On a completely different software application (or really, many applications!), I would like to build a TCP-based client which could talk to the server and control the games remotely.

As opposed to the built-in Lua plugin mechanism (which is excellent, BTW), this proposed method has the following advantages:
  • Language independence. The client software can be written in just about any language (C++, Python, or whatever). If you can make a TCP client, you can control the game.
  • Easy integration with third-party libraries. The client can integrate with third-party or novel software libraries like Tensor Flow, OpenCV, etc.
  • Client could run on separate computer. Although not required, one can run MAME (server) on a separate physical computer than the client. This may help with processing bottlenecks, debugging, etc.
  • Client user interface is unconstrained to MAME's capabilities.

I propose a simple data exchange protocol. It could be a simple homebrewed packet exchange, or leverage an established mechanism like MQTT (https://mqtt.org/), Protocol Buffers (https://developers.google.com/protocol-buffers), gRPC (https://grpc.io/), etc.

I have a vague idea that the server would operate in parallel with the Lua engine, and perhaps make use of the same underlying code. For me, this is where things get a little murky. I have written various machine-to-machine networking protocols, etc., and am confident that I could do a reasonable job with this except for the critical interface between the server components and MAME itself.

So, if anyone can help with the following, I would be greatly appreciative!
  • Where in the source code should I look to make he actual "hooks" into MAME?
  • Has anyone done anything like this before? I have seen some older projects where MAME is compiled as a library, which is a good approach, but the projects are old and don't really have the hooks needed. They are more for front-end and integrating MAME into general applications.
  • Anyone interested in collaborating?
Ultimately, I would be pleased to open-source this code, or if appropriate, have it merged into the official MAME codebase.

All thoughts and input are welcome!

-Stuart

Return to “MAME Discussion”