Opened 8 years ago

Closed 3 years ago

#3845 closed enhancement (fixed)

Simulation API

Reported by: _kali Owned by:
Priority: Nice to Have Milestone: Alpha 24
Component: AI Keywords:
Cc: Patch:

Description (last modified by Brian Broll)

I'd like to propose an API for running multiple AI simulations for the purposes of statistical analysis and machine learning.

Recently on HackerNews, a 0ad bot was featured (https://news.ycombinator.com/item?id=11282069). After the success of AlphaGo, many are saying that Starcraft is the next domain for AI. However, the source code is closed. With 0ad being open source, we are an obvious choice for open-source RTS AI learning.

I'd envision something along the lines of the JS pseudo-code to run a simulation (command line flags would work too if easier):

results = Simulation.run({
  "players": 2,
  "civs": [randomCiv1, randomCiv2],
  "teams": [[petra-hard], [myNewBot, myHelperBot]], // a 2 dimensional array of teams/bots
  "map": "mainland.js",
  "resources": ["low", "high", "dethmatch"] // resources per player for being able to handicap a bot
  "popCap": 200,
  "timeLimit": 600 //number of seconds to run the simulation (600 = 10min)
  "statsFrequency": 60 // number of seconds between saving the game stats (60 = 1min)
  // all other game settings
});

I'd envision the results being returned having the following properties:

results.stats // an array of all the end of game statistics (kills, territory, trade income, etc. per player) taken every statsFrequency seconds
results.duration // total time of the simulation in case an AI was defeated early

In replays, the game can go 20x. Is it possible to make AI-only simulations go even faster than that?

Change History (6)

in reply to:  description comment:1 by Itms, 8 years ago

Keywords: simulation testing removed
Milestone: Alpha 21Backlog

Replying to _kali:

In replays, the game can go 20x. Is it possible to make AI-only simulations go even faster than that?

Yes, for instance, if you replay via command line (pyrogenesis -mod=public -replay=commands.txt) it will compute as fast as possible.

Please note that it's not urgent and no patch is proposed here, so it shouldn't be put to the A21 milestone. Thanks for the suggestion though. :)

comment:2 by sanderd17, 8 years ago

Keywords: simulation testing added
Milestone: BacklogAlpha 21

It would be nice to have the AI as a separate human-like player. So the game runs in a separate thread, and the AI can use the same GuiInterface-exposed functions to make its decisions.

Then the AI shouldn't be synchronised, and could use a self-learning strategy (perhaps coupled to an online database). Now, self-learning is nearly impossible, since the AIs on all players need to make exactly the same decisions.

comment:3 by sanderd17, 8 years ago

Keywords: simulation testing removed
Milestone: Alpha 21Backlog

comment:4 by _kali, 8 years ago

In addition to AI improvements and machine learning, we could use it to statistically test civ balance. We could run 100 1v1s with each civ pairing and see if the win/loss ratio is out of whack for any civ. It wouldn't capture good micro, like using cavs to raid trade, but it would get us reasonably close. We could also create test maps like 50 champs + hero vs. 50 champs + hero or stage 1-only battle to see if warfare is relatively fair among the civs at each stage in the game.

comment:5 by Brian Broll, 4 years ago

Description: modified (diff)

I believe this has been addressed by https://code.wildfiregames.com/D2199. The details of the interface are a little bit different but D2199 does add the required features for 0 AD to be used as a sandbox for machine learning as described in thid ticket!

comment:6 by Stan, 3 years ago

Milestone: BacklogAlpha 24
Resolution: fixed
Status: newclosed

Indeed was fixed.

Note: See TracTickets for help on using tickets.