-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
59 lines (47 loc) · 1.65 KB
/
test.js
File metadata and controls
59 lines (47 loc) · 1.65 KB
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
// Build structure
var structure = []
structure[0] = ['|', '-', '-', '-', '-', '-', '|']
structure[1] = ['|', 'M', 'C', '_', '_', '_', '|']
structure[2] = ['|', '_', '_', 'X', 'D', '_', '|']
structure[3] = ['|', '_', 'X', '?', 'X', '_', '|']
structure[4] = ['|', '_', '_', '_', '_', 'X', '|']
structure[5] = ['|', '-', '-', '-', '-', '-', '|']
var walls = ['|', '-', 'X']
var phrases = {}
phrases['|'] = "cannot get there, this a maze border you just hitted"
phrases['-'] = "cannot get there, this a maze border you just hitted"
phrases['|'] = "cannot get there, this a maze border you just hitted"
phrases['X'] = "ouch, you bumped a wall"
phrases['_'] = "nothing here, let's continue exploring."
phrases['C'] = "hello kitty, you look hungry. Are you lost too? Jump in."
phrases['D'] = "WOW, an agressive dog is lying here. You've been bitten!"
phrases['M'] = "Too late, the ugly monster saw you. RUN!!!"
phrases['?'] = "CONGRATS, you found the treasure!!!"
var scores = {}
scores['|'] = -200
scores['-'] = -200
scores['|'] = -200
scores['X'] = -100
scores['_'] = 50
scores['C'] = 200
scores['D'] = -200
scores['M'] = -500
scores['?'] = 5000
// Create Maze
console.info("Starting a new Maze")
const Maze = require('./maze')
var game = new Maze(structure, walls, phrases, scores, '?')
game.pickInitialPosition('_')
game.updateScore(1000)
// Show map
console.log("Map:\n" + game.buildMap());
// Try directions
var move = game.up();
console.log(JSON.stringify(move));
move = game.left();
console.log(JSON.stringify(move));
move = game.down();
console.log(JSON.stringify(move));
move = game.right();
console.log(JSON.stringify(move));
console.log(`final score: ${game.score}`)