18-97-9-175.crawl.commoncrawl.org | ToothyWiki | ChrisHowlett | RecentChanges | Login
[Click to play]
[Recompile this page]
[Compiler error log]
ToothyGDL
logic
{
int NO { 0 }
int YES { 1 }
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,
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 in_progress { NO }
int win { NO }
int guess { 1 }
int selected { 0 }
int right { 0 }
int half_right { 0 }
array counted_guess { 0, 0, 0, 0 }
array counted_ans { 0, 0, 0, 0 }
for i ( 1 .. 15 )
{
for j ( 0 .. 3 )
{
when
{
(guess == i) and (selected != 0)
}
allow
{
board[6 * i + j] = selected;
selected = 0;
}
label { "Put peg in " i ", " j }
}
}
when
{
(board[6 * guess] != 0) and
(board[6 * guess + 1] != 0) and
(board[6 * guess + 2] != 0) and
(board[6 * guess + 3] != 0)
}
allow
{
right = 0;
half_right = 0;
for i ( 0 .. 3 )
{
counted_guess[i] = NO;
counted_ans[i] = NO;
if (board[6 * guess + i] == board[i])
{
right = right + 1;
counted_guess[i] = YES;
counted_ans[i] = YES;
}
}
for i ( 0 .. 3 )
{
for j ( 0 .. 3 )
{
if ((counted_guess[i] == NO) and (counted_ans[j] == NO) and
(board[6 * guess + i] == board[j]))
{
half_right = half_right + 1;
counted_guess[i] = YES;
counted_ans[j] = YES;
}
}
}
board[6 * guess + 4] = right;
board[6 * guess + 5] = half_right;
guess++;
if (right == 4)
{
win = YES;
}
}
label { "Submit" }
when
{
win == YES
}
allow
{
in_progress = NO;
}
label { "You Win" }
when
{
(guess > 15) and (win == NO)
}
allow
{
in_progress = NO;
}
label { "You Lose" }
when
{
in_progress == NO
}
allow
{
win = NO;
guess = 1;
selected = 0;
in_progress = YES;
for i ( 1 .. 15)
{
for j ( 0 .. 5 )
{
board[6 * i + j] = 0;
}
}
for i ( 0 .. 3 )
{
board[i] = random[6] + 1;
}
}
label { "Start" }
when
{
(in_progress == YES)
}
allow
{
selected = 1;
}
label { "Pick black" }
when
{
((selected == 1) and (in_progress == YES))
}
allow
{
selected = 0;
}
label { "Drop black" }
when
{
(in_progress == YES)
}
allow
{
selected = 2;
}
label { "Pick red" }
when
{
((selected == 2) and (in_progress == YES))
}
allow
{
selected = 0;
}
label { "Drop red" }
when
{
(in_progress == YES)
}
allow
{
selected = 3;
}
label { "Pick blue" }
when
{
((selected == 3) and (in_progress == YES))
}
allow
{
selected = 0;
}
label { "Drop blue" }
when
{
(in_progress == YES)
}
allow
{
selected = 4;
}
label { "Pick green" }
when
{
((selected == 4) and (in_progress == YES))
}
allow
{
selected = 0;
}
label { "Drop green" }
when
{
(in_progress == YES)
}
allow
{
selected = 5;
}
label { "Pick yellow" }
when
{
((selected == 5) and (in_progress == YES))
}
allow
{
selected = 0;
}
label { "Drop yellow" }
when
{
(in_progress == YES)
}
allow
{
selected = 6;
}
label { "Pick fuchsia" }
when
{
((selected == 6) and (in_progress == YES))
}
allow
{
selected = 0;
}
label { "Drop fuchsia" }
}
display
{
box
{
content { "Mastermind" }
}
newline
for j ( 0 .. 3 )
{
box
{
width { 2em }
height { 2em }
content { " " }
border { 1px solid black }
padding { 3px }
if (in_progress == YES)
{
content { "?" }
}
if (in_progress == NO)
{
if ( board[j] == 1 )
{
background { black }
}
if ( board[j] == 2 )
{
background { red }
}
if ( board[j] == 3 )
{
background { blue }
}
if ( board[j] == 4 )
{
background { green }
}
if ( board[j] == 5 )
{
background { yellow }
}
if ( board[j] == 6 )
{
background { fuchsia }
}
}
}
}
box
{
width { 2em }
height { 2em }
content { " " }
border { 1px solid white }
}
box
{
width { 2em }
height { 2em }
content { " " }
border { 1px solid white }
}
newline
for i ( 1 .. 15 )
{
for j ( 0 .. 3 )
{
box
{
width { 2em }
height { 2em }
content { " " }
if ( (selected == 0) or (guess != i))
{
border { 1px solid black }
padding { 3px }
}
if ( (selected != 0) and (guess == i))
{
border { 4px solid aqua }
}
if ( board[6 * i + j] == 1 )
{
background { black }
}
if ( board[6 * i + j] == 2 )
{
background { red }
}
if ( board[6 * i + j] == 3 )
{
background { blue }
}
if ( board[6 * i + j] == 4 )
{
background { green }
}
if ( board[6 * i + j] == 5 )
{
background { yellow }
}
if ( board[6 * i + j] == 6 )
{
background { fuchsia }
}
bind_action { "Put peg in " i ", " j }
while_active { border { 4px solid aqua } padding { 0px } }
}
}
box
{
width { 2em }
height { 2em }
border { 1px solid black }
background { silver }
content { board[6 * i + 4] }
}
box
{
width { 2em }
height { 2em }
border { 1px solid black }
content { board[6 * i + 5] }
}
newline
}
newline
newline
box
{
width { 2em }
height { 2em }
content { " " }
background { black }
if ( selected != 1 )
{
border { 1px solid black }
}
if ( selected == 1 )
{
border { 4px solid black }
}
bind_action { "Pick black" }
bind_action { "Drop black" }
}
box
{
width { 2em }
height { 2em }
content { " " }
background { red }
if ( selected != 2 )
{
border { 1px solid black }
}
if ( selected == 2 )
{
border { 4px solid black }
}
bind_action { "Pick red" }
bind_action { "Drop red" }
}
box
{
width { 2em }
height { 2em }
content { " " }
background { blue }
if ( selected != 3 )
{
border { 1px solid black }
}
if ( selected == 3 )
{
border { 4px solid black }
}
bind_action { "Pick blue" }
bind_action { "Drop blue" }
}
box
{
width { 2em }
height { 2em }
content { " " }
background { green }
if ( selected != 4 )
{
border { 1px solid black }
}
if ( selected == 4 )
{
border { 4px solid black }
}
bind_action { "Pick green" }
bind_action { "Drop green" }
}
box
{
width { 2em }
height { 2em }
content { " " }
background { yellow }
if ( selected != 5 )
{
border { 1px solid black }
}
if ( selected == 5 )
{
border { 4px solid black }
}
bind_action { "Pick yellow" }
bind_action { "Drop yellow" }
}
box
{
width { 2em }
height { 2em }
content { " " }
background { fuchsia }
if ( selected != 6 )
{
border { 1px solid black }
}
if ( selected == 6 )
{
border { 4px solid black }
}
bind_action { "Pick fuchsia" }
bind_action { "Drop fuchsia" }
}
newline
box
{
content { }
border { 1px solid black }
bind_action { "Start" }
while_active { content { "Start a game" } }
}
box
{
content { }
border { 1px solid black }
bind_action { "Submit" }
while_active { content { "Submit your guess" } }
}
box
{
content { }
border { 1px solid black }
bind_action { "You Win" }
while_active { content { "You win! Click to see solution" } }
}
box
{
content { }
border { 1px solid black }
bind_action { "You Lose" }
while_active { content { "You lose. Click to see solution" } }
}
}
Suggestion: whenever a colour is selected, somehow highlight the boxes you can click on to set them to that colour. - MoonShadow
- That works, but is ugly as sin. Any better suggestions?
- I probably need to actually do some string find/replace operations on the CSS to only keep the last thing you set for each parameter, rather than relying on the browser to do it. - MoonShadow
- Well, that would be nice, but I actually meant...
- As in, the act of adding a 4px border is ugly, since nothing aligns. Any more aesthetic suggestions? --CH
- Could be done using position, but that'll make for some ugly code. I'll implement the ability to set padding and margins sometime tonight; then they could be set up to provide the extra 3px when necessary. - MoonShadow
- Er. I may be misunderstanding, but can you do what I did on chess and just put a border on every square and switch it out for the coloured border when needed? --K
- I suspect CH wants to retain the 1px black border around inactive squares. - MoonShadow
- Suppose I could. Not entirely sure how noticable a 1px aqua border would be, though. I'll give it a go at some point. --CH