tjukes / battlesnake-node

A Simple BattleSnake AI Written in NodeJS
http://battlesnake.io
0 stars 1 forks source link

Table of Contents

Snakespeare

Team: Nate Rosenstock, Arkady Futerman, Ryder Bergerud, Tana Jukes

about

Individual work incorporated via pull requests. See PRs and open branches for details on each team member's work.

The snake was ultimately deployed from the branch nate-new to http://this-snake.herokuapp.com/.

documentation

To compile docs, npm run docs Add documentation in the JSdoc format, found here

If you wish to edit the README, please do so on the README_snakespeare.md file. It is used to autogenerate the README.md, so anything you add to README.md will be overwritten each time npm run docs is run.

The documentation.yml file is for configuring the documentation generator.

git-stuff

Use branches for feature development or personal experimentation: git checkout -b some-new-branch-name

Merge to master via Github pull requests.

testing

To run tests, npm test

Deploying to Heroku

Current Heroku deployment: http://this-snake.herokuapp.com/

Can be updated or replaced as development progresses.

Docs from starter-snake

battlesnake-node(js)

A simple BattleSnake AI written in Javascript for NodeJS. Founded on the Sendwithus starter snake

Getting started (from Sendwithus)

See https://github.com/sendwithus/battlesnake-node for full details or to start a new snake from a blank slate.

To get started you'll need a working NodeJS development environment, and at least read the Heroku docs on deploying a NodeJS app.

If you haven't setup a NodeJS development environment before, read how to get started with NodeJS. You'll also need npm for easy JS dependency management.

This client uses Express4 for easy route management, read up on the docs to learn more about reading incoming JSON params, writing responses, etc.

Running the AI locally

Clone this repo via HTTPS or SSH.

Install the client dependencies:

npm install

Create an .env file in the root of the project and add your environment variables (optional).

Run the server:

nf start web

Test the client in your browser: http://localhost:5000


API

simple

Weighting scheme will assign 1 to edges going out to vertices which are unoccupied

Parameters

Returns number weight

createGraph

Creates a graph of the board. See API of Graph.js

Parameters

Returns Graph

naiveProbabilityLongTerm

Should return an guestimation the probability of next cell being occupied on the nth turn:

Parameters

Snake

Parameters

move

Will return a copy of the snake who has moved in the direction specified. The direction will be taken whether or not its walkable, it is the responsibility of the board keep track of snake, and tell it on next turn whether or not it has died.

Parameters

Returns Snake a clone having taken the move.

_equiDistant

Looks for set of cells that are or distance n from the head Disregards all other snakes on board. Might return negative indices.

Parameters

equiDistantFromHead

Looks for set of cells that are or distance n from the head Disregards all other snakes on board. Doesn't return negative indices.

Parameters

searchBoard

Search First search all of moves keeping other snakes fixed. Can go deeper Then choose closest head, and if it is within the search depth*2, and search all combinations of all snakes heads mark all paths that give death as negative score

searchHeads

Takes a look at where other snake's heads might be in the short term.

Parameters

closestSnakes

Find all snakes that you could have a head-on collision with within distance turns Note: this assumes all other snakes are static when calculating number of turns until collision between two snake heads.

Parameters

Returns Array<Object> an array of objects w/ {snake: Snake, path: Array} that are within distance*2 of the given snakehead

checkMate

Check if next move could result in checkmate.

dijkstra

Find shortest path by dijkstra's algorithm given changing graph values

Parameters

aStar

Finds shortests path, faster normally the dijkstra's algorithm

Parameters

getNeighboursIndex

Returns an object with values indices[l,m] of neighbours that aren't other snakes

Parameters

checkTailGrowth

Keeps track of when another snake eats, and if planning on going into last element of tail, abort!

Parameters

taxiDistance

Calculates taxi-car distance between two points

Parameters