Giter Site home page Giter Site logo

autofix-bot / terraforming-mars-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jankeromnes/terraforming-mars-bot

0.0 1.0 0.0 69 KB

A proof-of-concept Terraforming Mars AI meant to play https://github.com/bafolts/terraforming-mars/ automatically

License: MIT License

JavaScript 100.00%

terraforming-mars-bot's Introduction

terraforming-mars-bot

Gitpod ready-to-code

A proof-of-concept Terraforming Mars AI meant to play https://github.com/bafolts/terraforming-mars/ automatically.

How to run this

Open this repository in Gitpod, a free online development environment:

Open in Gitpod

This will give you a cloud workspace containing this repository already set-up and running:

terraforming-mars-bot-in-gitpod

How to implement your own bot

  1. Feel free to fork this repository, or to contribute your own bot here (Pull Requests welcome!)

  2. Create your own bot script under the bots/ directory, for example by copying one of the existing bots:

cd bots/
cp random.js my-bot.js
  1. Implement or modify the required functions in your bot script, like for example exports.playInitialResearchPhase:
exports.playInitialResearchPhase = async (game, availableCorporations, availableCards) => {
  const corporation = // TODO
  const initialCards = // TODO
  return [[ corporation ], initialCards];
}

๐Ÿ’ก Feel free to inspect the game object, for example with console.log(game), as it holds all the interesting details about the game in progress.

  1. Test your bot by making it play a full game of Terraforming Mars:
  • node play-bot --bot=my-bot.js: Makes your bot play a new local solo game

Here is what such a test run may look like in yout Terminal:

$ node play-bot --bot=my-bot.js
Bot plays: [ [ 'CrediCor' ], [ 'Solar Wind Power' ] ]
...
Game ended!
Game state (1p): gen=14, temp=-20, oxy=1, oceans=2, phase=end
Final scores:
  - Bot (red): 22 points

๐Ÿ’ก This should make your bot play until the end of the game. However, if an error occurs (for example, if your bot tries to play an illegal move) you can debug it like so:

  • Notice in the logs what the game was waiting for, and what your bot attempted to play
  • Then, open the bot's player link in your browser
  • Open your browser's Developer Tools, then open the Network panel, and clear all previous entries
  • Manually play what your bot should have played
  • Click on the first item that appeared in your Network panel (looks like /input), and display the request's JSON payload
  • Then, compare what your bot tried to play with what you manually played -- this should tell you what your bot should do differently

Helper scripts

This repository comes with a few useful scripts:

node play-bot [PLAYER_LINK]

# Make a bot play a full solo game of Terraforming Mars
node play-bot

# Make a bot play Terraforming Mars (using a regular player link)
node play-bot https://my-tm-server.com/player?id=123456789

# Make a specific bot play Terraforming Mars
node play-bot --bot=random https://my-tm-server.com/player?id=123456789

# See all available options and what they do
node play-bot --help

node start-game [SERVER]

# Start a new local game of Terraforming Mars (outputs a player link)
node start-game

# Start a new game on any Terraforming Mars server
node start-game https://my-tm-server.com

# Start a new local game of Terraforming Mars, but only print player links (no extra text)
node start-game --quiet

# See all available options and what they do
node start-game --help

terraforming-mars-bot's People

Contributors

autofix-bot avatar jankeromnes avatar

Watchers

 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.