ec2-3-17-79-60.us-east-2.compute.amazonaws.com | ToothyWiki | Hawk | RecentChanges | Login | Webcomic
[Recompile this page]
[Compiler error log]
[Play]
logic
{
int boardWidth {20}
int boardHeight {20}
int TOP_SPACE {10}
int TILE_EMPTY {0}
int TILE_ROBOT {2}
int TILE_MIN_EXPLOSION {4}
int playerX {8}
int playerY {12}
array board {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}
int numRobots {8}
array robotX { 2, 4, 19, 15, 13, 8, 9, 17 }
array robotY { 8, 4, 4, 5, 7, 2, 16, 15 }
array xMoves { -1, 0, 1, -1, 1, -1, 0, 1 }
array yMoves { 1, 1, 1, 0, 0, -1, -1, -1 }
// Generate a random board
when
{
(1 == 1)
}
allow
{
for y (0 .. (boardHeight - 1))
{
for x (0 .. (boardWidth - 1))
{
board[x + (y * boardWidth)] = TILE_EMPTY;
}
}
for i (0..(numRobots-1))
{
robotX[i] = random[boardWidth];
robotY[i] = random[boardHeight];
board[robotX[i] + (robotY[i] * boardWidth)] = board[robotX[i] + (robotY[i] * boardWidth)] + TILE_ROBOT;
}
playerX = random[boardWidth];
playerY = random[boardHeight];
}
label
{
"Reset"
}
for p (0..7)
{
// Move player.
when
{
((playerX + xMoves[p]) >= 0)
and ((playerX + xMoves[p]) < boardWidth)
and ((playerY + yMoves[p]) >= 0)
and ((playerY + yMoves[p]) < boardHeight)
}
allow
{
playerX = (playerX + xMoves[p]);
playerY = (playerY + yMoves[p]);
}
label
{
"Player dx=" xMoves[p] " dy=" yMoves[p] "."
}
}
for r (0 .. (numRobots - 1))
{
// Move each robot toward the player, killing him if he's hit.
when
{
(playerX > robotX[r])
and (playerY > robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] + 1 + ((robotY[r] + 1) * boardWidth)] = board[robotX[r] + 1 + ((robotY[r] + 1) * boardWidth)] + TILE_ROBOT;
robotX[r] = robotX[r] + 1;
robotY[r] = robotY[r] + 1;
}
label
{
"Robot move"
}
when
{
(playerX > robotX[r])
and (playerY == robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] + 1 + (robotY[r] * boardWidth)] = board[robotX[r] + 1 + (robotY[r] * boardWidth)] + TILE_ROBOT;
robotX[r] = robotX[r] + 1;
}
label
{
"Robot move"
}
when
{
(playerX > robotX[r])
and (playerY < robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] + 1 + ((robotY[r] - 1) * boardWidth)] = board[robotX[r] + 1 + ((robotY[r] - 1) * boardWidth)] + TILE_ROBOT;
robotX[r] = robotX[r] + 1;
robotY[r] = robotY[r] - 1;
}
label
{
"Robot move"
}
when
{
(playerX == robotX[r])
and (playerY > robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] + ((robotY[r] + 1) * boardWidth)] = board[robotX[r] + ((robotY[r] + 1) * boardWidth)] + TILE_ROBOT;
robotY[r] = robotY[r] + 1;
}
label
{
"Robot move"
}
when
{
(playerX == robotX[r])
and (playerY < robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] + ((robotY[r] - 1) * boardWidth)] = board[robotX[r] + ((robotY[r] - 1) * boardWidth)] + TILE_ROBOT;
robotY[r] = robotY[r] - 1;
}
label
{
"Robot move"
}
when
{
(playerX < robotX[r])
and (playerY > robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] - 1 + ((robotY[r] + 1) * boardWidth)] = board[robotX[r] - 1 + ((robotY[r] + 1) * boardWidth)] + TILE_ROBOT;
robotX[r] = robotX[r] - 1;
robotY[r] = robotY[r] + 1;
}
label
{
"Robot move"
}
when
{
(playerX < robotX[r])
and (playerY == robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] - 1 + (robotY[r] * boardWidth)] = board[robotX[r] - 1 + (robotY[r] * boardWidth)] + TILE_ROBOT;
robotX[r] = robotX[r] - 1;
}
label
{
"Robot move"
}
when
{
(playerX < robotX[r])
and (playerY < robotY[r])
and (board[robotX[r] + (robotY[r] * boardWidth)] == TILE_ROBOT)
}
allow
{
board[robotX[r] + (robotY[r] * boardWidth)] = TILE_EMPTY;
board[robotX[r] - 1 + ((robotY[r] - 1) * boardWidth)] = board[robotX[r] - 1 + ((robotY[r] - 1) * boardWidth)] + TILE_ROBOT;
robotX[r] = robotX[r] - 1;
robotY[r] = robotY[r] - 1;
}
label
{
"Robot move"
}
}
}
display
{
stringtable items
{
" ", "", "♗", "^", "✴", "✴", "✷", "✷", "✸", "✸", "✸", "✸", "✹", "✹", "✹", "✹", "✹", "✹", "✹"
}
box
{
content { "Robots!" }
}
newline
sprite
{
position { absolute; left: 0em; top: (TOP_SPACE) em }
border { 1px solid black }
height { 20em }
width { 20em }
}
for r (0 .. (numRobots-1))
{
sprite
{
position { absolute; left: (robotX[r]) em; top: (robotY[r] + TOP_SPACE) em }
width { 1em }
height { 1em }
content { items[board[robotX[r] + (robotY[r] * boardWidth)]] }
}
}
box
{
position { absolute; left: (playerX) em; top: (playerY + TOP_SPACE) em }
width { 1em }
height { 1em }
content { "☺" }
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action{ "Robot move" }
}
if (board[playerX + (playerY * boardWidth)] != TILE_EMPTY)
{
content { "☹" }
}
}
newline
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=-1 dy=-1." }
while_active {
position { absolute; left: (playerX - 1) em; top: (playerY + TOP_SPACE - 1) em }
width { 1em }
height { 1em }
if (board[playerX - 1 + ((playerY - 1) * boardWidth)] == TILE_EMPTY) {
content { "↖" }
}
}
bind_action { "Robot move" }
}
}
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=0 dy=-1." }
while_active {
position { absolute; left: (playerX) em; top: (playerY + TOP_SPACE - 1) em }
width { 1em }
height { 1em }
if (board[playerX + ((playerY - 1) * boardWidth)] == TILE_EMPTY) {
content { "↑" }
}
}
bind_action { "Robot move" }
}
}
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=1 dy=-1." }
while_active {
position { absolute; left: (playerX + 1) em; top: (playerY + TOP_SPACE - 1) em }
width { 1em }
height { 1em }
if (board[playerX + 1 + ((playerY - 1) * boardWidth)] == TILE_EMPTY) {
content { "↗" }
}
}
bind_action { "Robot move" }
}
}
newline
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=-1 dy=0." }
while_active {
position { absolute; left: (playerX - 1) em; top: (playerY + TOP_SPACE) em }
width { 1em }
height { 1em }
if (board[playerX - 1 + (playerY * boardWidth)] == TILE_EMPTY) {
content { "←" }
}
}
bind_action { "Robot move" }
}
}
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=1 dy=0." }
while_active {
position { absolute; left: (playerX + 1) em; top: (playerY + TOP_SPACE) em }
width { 1em }
height { 1em }
if (board[playerX + 1 + (playerY * boardWidth)] == TILE_EMPTY) {
content { "→" }
}
}
bind_action { "Robot move" }
}
}
newline
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=-1 dy=1." }
while_active {
position { absolute; left: (playerX - 1) em; top: (playerY + TOP_SPACE + 1) em }
width { 1em }
height { 1em }
if (board[playerX - 1 + ((playerY + 1) * boardWidth)] == TILE_EMPTY) {
content { "↙" }
}
}
bind_action { "Robot move" }
}
}
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=0 dy=1." }
while_active {
position { absolute; left: (playerX) em; top: (playerY + TOP_SPACE + 1) em }
width { 1em }
height { 1em }
if (board[playerX + ((playerY + 1) * boardWidth)] == TILE_EMPTY) {
content { "↓" }
}
}
bind_action { "Robot move" }
}
}
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
bind_action { "Player dx=1 dy=1." }
while_active {
position { absolute; left: (playerX + 1) em; top: (playerY + TOP_SPACE + 1) em }
width { 1em }
height { 1em }
if (board[playerX + 1 + ((playerY + 1) * boardWidth)] == TILE_EMPTY) {
content { "↘" }
}
}
bind_action { "Robot move" }
}
}
box
{
if (board[playerX + (playerY * boardWidth)] == TILE_EMPTY)
{
content { "Make your escape!" }
}
if (board[playerX + (playerY * boardWidth)] != TILE_EMPTY)
{
content { "Game over!" }
}
}
newline
box
{
border { 1px solid black }
content { "Regenerate" }
bind_action { "Reset" }
}
}