forked from willowtreeapps/wombats-bots
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript-sample.js
More file actions
23 lines (20 loc) · 785 Bytes
/
javascript-sample.js
File metadata and controls
23 lines (20 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
((state, timeLeftFn) => {
const turnDirections = ['right', 'left', 'about-face'];
const turnDirection = turnDirections[Math.floor(Math.random() * 3)];
const smokeDirections = ['forward', 'backward', 'left', 'right', 'drop'];
const smokeDirection = smokeDirections[Math.floor(Math.random() * 5)];
const index = Math.floor(Math.random() * 17);
const command = index < 10 ?
{ action: 'move', metadata: {} } :
index < 12 ?
{ action: 'turn', metadata: { direction: turnDirection } } :
index < 16 ?
{ action: 'shoot', metadata: {} } :
{ action: 'smoke', metadata: { direction: smokeDirection } };
return {
command,
state: {
hello: 'world'
}
};
});