SimHacker / micropolis

Automatically exported from code.google.com/p/micropolis
901 stars 168 forks source link

AI api? #72

Open frnsys opened 9 years ago

frnsys commented 9 years ago

I'm interested in trying to build city planning AIs - do you think micropolis would be conducive to an api for developing AI players?

lloydsparkes commented 9 years ago

So I've recently been playing around with this project (I've rewritten it into C#).

It is possible for an AI to be written against it, but as the API stand's it is not really conductive, It is heavily optimised for fast and efficient drawing of the Map.

So you would need to build a translation layer in between, to provide a higher level, more semantic API for an AI to work with.

Also there are a few bits where the engine may do things which you will want the AI to have control over.

The main one I can think of is the automatic placement of Hospitals and Churches, but it should be quite easy to disable that code, and then add in API's to place them exactly.

smearle commented 6 years ago

I've taken a stab at this in this repo (find a more detailed description on reddit.

I'm currently using a very slightly modified Debian package of micropolis-activity (find it here), and sending build commands from python over tcl. I only had to duplicate some of the game's build-functions, making them editor/gui-independent, and then make them available as tcl commands.

I'm very interested in how one might speed this process up, though, since training is quite slow. I'm currently trying to compile MicropolisCore - if I could have the same commands I do now, but available directly to python via wrapping, rather than via the python expect module and tcl, I imagine there would be a speed increase. After all, if you can run the simulation ultra fast (via, i.e., the tcl command "sim Delay 0"), then I don't see why you shouldn't be able to build/destroy a road or zone once-per-timestep in the simulation, rather than over the course of a few hundred in-game years, as my current solution using tcl permits.