This months challenge consists of you writing a bot to solve a maze. We will have three levels, level > 1 will be announced soon.
Level 1: DUE 31st Oct Level 2: DUE 14th Nov Level 3: DUE 23rd Jan
- Node only
- No dependencies
- No changes to engine
- Put your bot into a folder and name folder appropriately
- No data sharing between games
- No Internet
- No js prototype changing
- Your code has to stay inside your bots folder
- Do not output to
stdout
- At the beginning of each round, add your bot to a new folder then open a PR to this repo (we only merge on the day the round begins)
- LEVEL 1 Solve the maze by going to the green cross. You have 3000 steps to solve the first level. Due 31st Oct
- LEVEL 2 Solve both levels with the same bot. You have 3000 steps to solve the first level. You have 6000 steps to solve the first level. Due 14th Nov
- LEVEL 3 Solve all three levels with the same bot. You have 3000 steps to solve the first level. You have 6000 steps to solve the first level. You have 9120 steps to solve the last level. Due 23rd Jan
The game comes with a small "example" bot that just randomizes it's movements.
To run the game for a bot cd
into the challenge 201810-maze
folder.
To play the game run:
yarn play example/index.js --level 1
(💡 Tip: --level
& --speed
are optional. See CLI Options below.)
.
├── bot1
│ └── index.js
├── bot2
│ └── index.js
├── bot3
│ └── index.js
│
├── README.md
├── constants.js
├── helper.js
├── index.js
└── test.js
So in the example above to run the game for bot2 you must run:
yarn play bot2/index.js
Once the game runs you can use the key q
to quit the game any time.
You can also use the arrow functions ←
and →
to step through each step your bot has taken.
Go back in history and analyses where your bot went wrong etc.
--level|-l Set the level to run (Default: 1)
--speed|-s Set the time in milliseconds between each step (Default: 500)
- Create a folder in the root (next to the example bot)
- Include a javascript file that exports below class
The example bot is structured like this:
class BOT {
constructor({ size, start, end }) {}
Move({ MAP }) {
const actions = ['up', 'right', 'down', 'left'];
return actions[ Math.floor( Math.random() * actions.length ) ];
}
}
module.exports = exports = BOT;
The class you have to export from your bot needs to include the below method:
Move
- Called when it is your turn to decide where to go
- parameters:
{ MAP }
- return:
'up' | 'right' | 'down' | 'left'
constructor
of your class- parameters:
size
,start
,end
- parameters:
MAP
is an array of arrays and tells you in a grid of 5x5 around you where blocks are.
false
= blocks
true
= no blocks
An example would be:
MAP = [
[ true, false, true, true, true ],
[ true, true, true, true, false ],
[ true, true, false, true, true ],
[ false, true, true, false, true ],
[ true, true, true, false, true ],
];
This would visualize as:
░ ▓ ░ ░ ░
░ ░ ░ ░ ▓
░ ░ ▓ ░ ░
▓ ░ ░ ▓ ░
░ ░ ░ ▓ ░
Your constructor of your BOT will also get three parameters:
size
={ width: <Number>, height: <Number> }
- The size of your boardstart
=[ <Number>, <Number> ]
- The position you're starting at (The first number is the row, the second the column)end
=[ <Number>, <Number> ]
- The position you want to go to (The first number is the row, the second the column)
The engine will run the entire game and populate a history array with all the steps your bot has taken. Only then will it start playing it back to you. This gives you the power to go through the history at your own pace and even go back in time. That's the reason why the outcome of the game is displayed on the top right away.