|
|
@ -70,6 +70,12 @@ var LEVEL3 = [ |
|
|
|
[{},{...WRITERDOWN},{},{},{},], |
|
|
|
[{},{...WRITERDOWN},{},{},{},], |
|
|
|
[{},{...BELTRIGHT},{},{},{},], |
|
|
|
[{},{...BELTRIGHT},{},{},{},], |
|
|
|
[{},{},{},{},{},],] |
|
|
|
[{},{},{},{},{},],] |
|
|
|
|
|
|
|
var LEVEL4 = [ |
|
|
|
|
|
|
|
[{},{},{},{},{},], |
|
|
|
|
|
|
|
[{},{},{},{},{},], |
|
|
|
|
|
|
|
[{},{...BELTRIGHT,direction2:DOWN},{},{},{},], |
|
|
|
|
|
|
|
[{},{},{...BELTUP,direction2:LEFT},{},{},], |
|
|
|
|
|
|
|
[{},{},{},{},{},],] |
|
|
|
|
|
|
|
|
|
|
|
var gameGrid= [] |
|
|
|
var gameGrid= [] |
|
|
|
|
|
|
|
|
|
|
@ -92,10 +98,26 @@ function runBot(testing) { |
|
|
|
//console.log("Update")
|
|
|
|
//console.log("Update")
|
|
|
|
var nextSquare = {} |
|
|
|
var nextSquare = {} |
|
|
|
switch (BOT_DIR) { |
|
|
|
switch (BOT_DIR) { |
|
|
|
case UP:{nextSquare = gameGrid[--BOT_Y][BOT_X];}break; |
|
|
|
case UP:{ |
|
|
|
case LEFT:{nextSquare = gameGrid[BOT_Y][--BOT_X];}break; |
|
|
|
nextSquare = gameGrid[--BOT_Y][BOT_X]; |
|
|
|
case RIGHT:{nextSquare = gameGrid[BOT_Y][++BOT_X];}break; |
|
|
|
BOT_DIR=(nextSquare.direction2 && |
|
|
|
case DOWN:{nextSquare = gameGrid[++BOT_Y][BOT_X];}break; |
|
|
|
(nextSquare.direction2===UP||nextSquare.direction2===DOWN))?nextSquare.direction2:nextSquare.direction |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case LEFT:{ |
|
|
|
|
|
|
|
nextSquare = gameGrid[BOT_Y][--BOT_X]; |
|
|
|
|
|
|
|
BOT_DIR=(nextSquare.direction2 && |
|
|
|
|
|
|
|
(nextSquare.direction2===RIGHT||nextSquare.direction2===LEFT))?nextSquare.direction2:nextSquare.direction |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case RIGHT:{ |
|
|
|
|
|
|
|
nextSquare = gameGrid[BOT_Y][++BOT_X]; |
|
|
|
|
|
|
|
BOT_DIR=(nextSquare.direction2 && |
|
|
|
|
|
|
|
(nextSquare.direction2===RIGHT||nextSquare.direction2===LEFT))?nextSquare.direction2:nextSquare.direction |
|
|
|
|
|
|
|
}break; |
|
|
|
|
|
|
|
case DOWN:{ |
|
|
|
|
|
|
|
nextSquare = gameGrid[++BOT_Y][BOT_X]; |
|
|
|
|
|
|
|
BOT_DIR=(nextSquare.direction2 && |
|
|
|
|
|
|
|
(nextSquare.direction2===UP||nextSquare.direction2===DOWN))?nextSquare.direction2:nextSquare.direction |
|
|
|
|
|
|
|
}break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (nextSquare.direction!==undefined) { |
|
|
|
if (nextSquare.direction!==undefined) { |
|
|
|
switch (nextSquare.type) { |
|
|
|
switch (nextSquare.type) { |
|
|
@ -115,12 +137,13 @@ function runBot(testing) { |
|
|
|
} |
|
|
|
} |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case "WRITER":{ |
|
|
|
case "WRITER":{ |
|
|
|
AppendTape(nextSquare.color) |
|
|
|
if (nextSquare.overwrite) { |
|
|
|
|
|
|
|
OverwriteTape(nextSquare.color) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
AppendTape(nextSquare.color) |
|
|
|
|
|
|
|
} |
|
|
|
BOT_DIR = nextSquare.direction |
|
|
|
BOT_DIR = nextSquare.direction |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
default:{ |
|
|
|
|
|
|
|
BOT_DIR = nextSquare.direction |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//console.log("Direction is now "+BOT_DIR)
|
|
|
|
//console.log("Direction is now "+BOT_DIR)
|
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -191,6 +214,9 @@ function ConsumeTape() { |
|
|
|
function AppendTape(col) { |
|
|
|
function AppendTape(col) { |
|
|
|
BOT_TAPE.push({color:col}) |
|
|
|
BOT_TAPE.push({color:col}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function OverwriteTape(col) { |
|
|
|
|
|
|
|
BOT_TAPE[0]={color:col} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function LeftOf(dir) { |
|
|
|
function LeftOf(dir) { |
|
|
|
return (dir+1)%4 |
|
|
|
return (dir+1)%4 |
|
|
|