Skip to content

Creatures

AppCraft-LLC edited this page Feb 8, 2018 · 1 revision

Example of simple creature called Megabrain:

br_megabrain = { 
 
    name: 'Megabrain',
    kind: kinds.moose,
    author: 'Author',

    thinkAboutIt: function(self, enemies, bullets, objects, events) { 
        return { action: actions.none };
    } 
}

Required fields are:

    name   - name of your awesome neuro-blockchain algorithm. max 10 chars.
    author - creator, displayed with the name of the algorithm on the leaderboard, max 10 chars.
    kind   - kind of a creature. Possible variations are: 
           [rhino: 0, bear: 1, moose: 2, bull: 3, runchip: 4, miner: 5, sprayer: 6, splitpus: 7]. 
           Design of creatures you can see in /img folder.

Required function are:

    thinkAboutIt - Loop function called by runner. 
    Must return a structure with desired action in the following format: 
    * { do: actions.move,  // desired action. See all variations in possible actions section. 
    *   params: {          // key value params, not necessary for some actions
    *      angle: 1.5      // desired direction of movement in radians
    *   }
    * };

Required parameters of thinkAboutIt function: self, enemies, bullets, objects and events.

Main brain variable's name must be the same as the filename. E.g. if the filename of the script is br_megabrain.js, the main variable in it must be br_megabrain.

Diameter of the creature's body is 60. There are 3 bars above the creature's body: red (health), green (energy), blue (bullets):

self - contains the sctucture with data of your creature:
    * { id: 0,                      // unique ID of an object
    *   name: 'Megabrain',          // creature's name
    *   author: 'Author',           // creature's author
    *   lives: 100,                 // amount of lives. Get max using {creatureMaxLives[self.level]}
    *   bullets: 3,                 // amount of bullets your creature has. 
                                       Limit is {creatureMaxBullets}
    *   energy: 100,                // amount of energy. Get max using {creatureMaxEnergy[self.level]}
    *   level: 0,                   // level of the creature. Three levels in the game: 0, 1 and 2.
    *   position: { x: 10, y: 10 }, // position on the map. Use {ground} struct to get its dimensions
    *   velocity: { x: 10, y: 10 }, // contains velocity vector of the creature's body  
    *   angle: 1.5,                 // direction the creature looking in, in radians.
    *   speed: 5,                   // speed of the body
    *   angularVelocity: 1          // use it to determine is the creature rotating or not
    *   kills: 2                    // amount of creature's kills
    *   deaths: 1                   // amount of creature's deaths
    *   iq: 14                      // creature's iq value
    * };

    enemies - contains an array with all other creatures. Can be empty. 
              It doesn't contain your creature, i.e. there is no self struct in it. 
              All elements has the same data like in self struct.

    bullets - an array with all free bullets.
                
    objects - contains all obstacles on the map.
        
    events  - an array with events.

Clone this wiki locally