Giter Site home page Giter Site logo

futuron's Introduction

Futuron: Lightcycle AI Battles

Getting started

Prerequisites:

First steps:

  • Clone the repository
  • Run npm install
  • Run bower install
  • Run gulp watch

Futuron terminal

Futuron is controlled via the on-page command line terminal. The help command lists the following options:

  • rez <spec1> [<specN>...] Used to bring in bot AIs onto the Grid.

    Each spec is resolved to a JavaScript file in a three-step process:

    • As a local file name without extension, or
    • As a IP address, using default path /scripts/bots/bot.js, or (1)
    • As a full URL referencing the bot script file (1)

    A bot's code is wrapped in a Web Worker with some helpers, detailed in the bot template file in app/scripts/bots/bot.js.

    (1) The bot file must be served with CORS enabled

  • derez <id1> [<idN>...] Used to remove bot AIs from the Grid.

    Each id must correspond to an existing bot ID. Derezzing bots causes their associated Web Workers to terminate.

  • run Runs a Futuron battle, pitting the bot AIs against one another.

    Last man standing wins.

  • halt Can be used to halt a battle, for example when only one bot remains.

  • help Display the command line help

Developing your bot

Futuron comes with a bot AI template, app/scripts/bots/bot.js. You can modify this file (or make copies to test several variants) to implement a better strategy than the default (go right, always).

The bot AI is wrapped inside a Web Worker. Since debugging Web Workers can be a bit tedious, the bot helpers are included in the Futuron page itself. This will make interactive development of custom helper functions easier.

Using Web Workers allows for multiple threads, enabling concurrent strategy computation for each bot.

The bot strategy function needs to balance computational intelligence with speed, since each bot is allowed only a fixed time frame for each move. This value defaults currently to 100 milliseconds.

To help you understand how much time your current bot algorithm is using, the bot legend view next to the Grid on the Futuron page displays information next to each bot entry. This information contains the time, in milliseconds, how long your strategy function took to execute that tick. Next to it, the number of times your strategy function invoked the look helper function during that tick is displayed.

Sharing results for battles

Once several bots are developed, they can be battle for supremacy on a shared Grid.

Futuron comes with a simple Python script (app/serve.py) which can be used from that location to serve your bot files. The rez bot resolution mechanism will search for bots from the default template location, when using the IP address resolution step.

The provided Python script enables CORS (Access-Control-Allow-Origin: *).

If you want to minify/uglify your bot code first, serve it with CORS enabled form the dist directory or another location of your choice.

Once every bot is served from a known location, you can use rez with IP address or full URL to bring in the bots for battle!

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.