forked from jeffszusz/robot-fruit-hunt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.js
68 lines (55 loc) · 2.3 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// API
// please remember to set var name = "Robot Name"
WIDTH = <width of game board>
HEIGHT = <height of game board>
// Returns the current board.
// It's an array of arrays, so
// board = get_board();
// field = board[x][y];
// can be used to get a position.
function get_board()
// Current position of your bot.
function get_my_x()
function get_my_y()
// Current position of your opponent.
function get_opponent_x()
function get_opponent_y()
EAST = <constant used to represent going right>
NORTH = <constant used to represent going up>
WEST = <constant used to represent going left>
SOUTH = <constant used to represent going south>
TAKE = <constant used to represent taking a piece of fruit if it exists on the cell>
PASS = <constant used to represent passing the turn>
// (Deprecated) For a given field (board[x][y]), if there's a fruit at
// that position, return the index of that fruit (starting with 1),
// or false if there's no fruit there. This is a convenience
// function that checks whether field>0.
function has_item(field)
// Return the number of different fruit types. Each fruit type might
// be on the board multiple times (use get_total_item_count(type))
// to query how often). Your goal is to have the most fruit as
// many categories as possible.
function get_number_of_item_types()
// Returns the number of fruits you or your opponent have.
// E.g. if get_my_item_count(1) returns 3, you have 3 pieces
// of the fruit 1.
function get_my_item_count(type)
function get_opponent_item_count(type)
// Returns the total number of fruits available for a given
// category. E.g. if get_total_item_count(2) returns 5,
// a total of 5 fruits of type 2 exists on the board and
// the players inventories.
function get_total_item_count(type)
// Print out a line of text, for debugging. This text will
// be visible to the author of the bot in the game replays
// and in the compile logs.
// Notice: Unlike in browsers, this function only works for strings.
// (Note that strings longer than 1024 characters won't be displayed,
// also the total limit of log output you can generate is 16k)
function trace(string)
// Implement this function, and return either
// NORTH, EAST, SOUTH, WEST, or TAKE.
function make_move()
// Optionally implement this function. It will be called
// at the start of the game.
function new_game()