From b3da74f092eaa38b6a1e20b77ca633f828ac8c63 Mon Sep 17 00:00:00 2001 From: Andrew Faraday Date: Fri, 31 Aug 2018 21:35:28 +0100 Subject: [PATCH] Bots work!!! --- config/bots.js | 10 +++ config/game.js | 4 +- config/players.js | 34 +++------- index.html | 9 +++ lib/api_ui.js | 68 +++++++++++++++++++ lib/classes/api.js | 54 +++++++++++++++ lib/classes/keyboard.js | 2 +- lib/classes/player.js | 4 +- lib/grid_game.js | 83 ++++++++++++++--------- lib/player_components/direction_change.js | 2 +- style/grid_game.css | 55 +++++++++++++-- 11 files changed, 261 insertions(+), 64 deletions(-) create mode 100644 config/bots.js create mode 100644 lib/api_ui.js create mode 100644 lib/classes/api.js diff --git a/config/bots.js b/config/bots.js new file mode 100644 index 0000000..c4f2bf4 --- /dev/null +++ b/config/bots.js @@ -0,0 +1,10 @@ +GridGame.data.bots = { + 'All Towards': '808c86eb544d9efaf94a30efc91bdfaf', + 'Code on Page': 'code', + 'Faraday Cage': 'd9eb9a70ad0dc0fb1885be0fce032adc', + 'Gist Id': 'bot_id', + 'Long Random': 'b9a0fe99060d9be1fc617bb7262f57be', + 'Manual': 'manual', + 'Rotate': '6634a7f381bb679ee7c2d90d93588d66', + 'Short Random': 'b16df33acb0f0c7830d2ca2d656f80be' +}; diff --git a/config/game.js b/config/game.js index 90984a1..8b5c83e 100644 --- a/config/game.js +++ b/config/game.js @@ -4,7 +4,7 @@ GridGame.data.game = { turn_time: 100, spawn_interval: 3, city_conversion_size: 10, - rock_count: 10, - wall_count: 40, + rock_count: 0, + wall_count: 0, wall_health: 100 }; diff --git a/config/players.js b/config/players.js index 3e4f5ef..58db239 100644 --- a/config/players.js +++ b/config/players.js @@ -3,33 +3,21 @@ GridGame.data.players = [ name: 'green', start: GridGame.positions.north_west_corner(2), direction: 'east', - playable: true + playable: true, + towardsX: 'east', + towardsY: 'south', + awayX: 'west', + awayY: 'north' }, { name: 'red', start: GridGame.positions.south_east_corner(2), direction: 'west', - playable: true + playable: true, + towardsX: 'west', + towardsY: 'north', + awayX: 'east', + awayY: 'south' } - /* - , - { - name: 'yellow', - start: { - x: 8, - y: 0 - }, - direction: 'south', - playable: false - }, - { - name: 'blue', - start: { - x: 11, - y: 11 - }, - direction: 'north', - playable: false - } - */ + // Only 2 for API-driven game ]; diff --git a/index.html b/index.html index 4451f74..3786e4e 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + @@ -40,12 +41,20 @@ + +

My Grid Game

+
+
+
Start
+
Stop
+
Reset
+