Giter VIP home page Giter VIP logo

hell-to-heaven / gym-city Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smearle/gym-city

0.0 1.0 0.0 329.04 MB

An interface with micropolis for city-building agents, packaged as an OpenAI gym environment

License: MIT License

Python 17.97% Makefile 0.86% Tcl 8.48% C++ 26.16% C 37.05% C# 0.75% HTML 2.67% CSS 0.14% Batchfile 0.01% Shell 0.10% Yacc 0.17% sed 0.01% Objective-C 0.21% Roff 0.01% Perl 0.04% Java 3.27% JavaScript 2.10% PHP 0.02%

gym-city's Introduction

The work in this repo was presented and demoed at the 2019 Experimental A.I. in Games (EXAG) workshop, an AIIDE workshop. You can read the paper here: http://www.exag.org/papers/EXAG_2019_paper_21.pdf

gym-city

A Reinforcement Learning interface for variable-scale city-planing-type gym environments, including Micropolis (open-source SimCity 1) and an interactive version of Conway's Game of Life.

Example

breathy Interacting with a trained agent

Installation

Clone this repository, then

cd gym-city

To install dependencies, use either anaconda:

conda create --name gc --file requirements.txt

or pip:

pip install -r requirements.txt

Then build Micropolis:

make install

Basic Use

From this directory, run:

from gym_micropolis.envs.corecontrol import MicropolisControl
m = MicropolisControl(MAP_W=50, MAP_H=50)
m.layGrid(4, 4)

Training w/ RL

To use micropolis as a gym environment, install gym.

To train an agent using A2C:

python3 main.py --experiment test_0 --algo a2c --model FullyConv --num-process 24 --map-width 16 --render

To visualize reward, in a separate terminal run: python -m visdom.server

To run inference using the agent we have just trained:

python3 enjoy.py --load-dir <directory/containing/MicropolisEnv-v0.tar> --map-width 16

Generally, agents quickly discover the power-plant + residential zone pairing that creates initial populations, then spend very long at a local minima consisting of a gameboard tiled by residential zones, surrounding a single power plant. On more successful runs, the agent will make the leap toward a smattering of lone road tiles place next to zones, at least one per zone to maximize population density.

I'm interested in emergent transport networks, though it does not seem that the simulation is complex enough for population-optimizing builds to require large-scale transport networks.

We can, however, reward traffic density just enough for continuous/traffic-producing roads to be drawn between zones, but not so much that they billow out into swaths of traffic-exploiting asphalt badlands.

Interacting w/ the Bot

During training and inference, a micropolis gui will be rendered by default. During training, it is the environment of rank 0 if multiple games are being run in parallel. The gui is controlled by the learning algorithm, and thus can be laggy, but is fully interactive, so that a player may build or delete zones during training and inference.

Any action that is successfully performed by the player on the subsection of the larger game-map which corresponds to the bot's play-area, is registered by the bot as an action of its own, sampled from its own action distribution, so that the player can influence the agent's training data in real time.

gym-city's People

Contributors

smearle avatar

Watchers

James Cloos avatar

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.