1.1.2 • Published 6 years ago

cw-node-wrapper v1.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Code Wars

This project contains a NodeJS wrapper for the code wars challenge.

npm install cw-node-wrapper --save

Hooking into the game loop

The wrapper will connect to the server and trigger an "update" function whenever it receives a new state. The update function should return the new controls of the bot.

let controls = { direction: { up: true, down: false, left: false, right: false }, shooting: true, running: false };

const update = (state) => {

    // TODO: Write your AI here

  return controls;
};

require('cw-node-wrapper')({ environment: 'codewars.be', botId: '1', botSecret: '1', update });

The wrapper requires an environment to which it needs to connect. Your bot identification number and your bot secret. Do NOT share your bot secret or another team will be able to take control of your bot. The tick function is executed whenever the wrapper receives a new state.

Listen to other events

require('cw-node-wrapper')({ 
    environment: 'codewars.be', 
    botId: '1', 
    botSecret: '1', 
    update,
    events: {
        state: () => null,
        map: () => null,
        bots: () => null,
        activity: () => null
    }
});

The game engine will inform you whenever something changes. Most notably the map should be implemented to detect whenever a map changes, because in the near future the map will not be send with the update function.

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago