service {
const html WelcomeMagic =
Welcome to the magic room!
I will show you 5 cards, you will choose one and
concentrate on it. I will read in your mind to know
which card you chose... Ready?
;
const html ShowCards1 =
Now choose a card and concentrate on it. You not have to
click on your card, I will get it in your mind!
;
const html Wait =
Please let me few seconds to read in your mind and click
continue.
;
const html ShowCards2 =
I saw the card in your mind and I removed it from the
stack...
Are you impress?
;
const html ComputerPlay =
I take <[computer]> picks...
;
const html ShowPicks21 =
There are 21 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks20 =
There are 20 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks19 =
There are 19 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks18 =
There are 18 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks17 =
There are 17 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks16 =
There are 16 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks15 =
There are 15 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks14 =
There are 14 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks13 =
There are 13 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks12 =
There are 12 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks11 =
There are 11 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks10 =
There are 10 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks9 =
There are 9 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks8 =
There are 8 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks7 =
There are 7 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks6 =
There are 6 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks5 =
There are 5 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks4 =
There are 4 toothpicks left...
How many picks do want to get (1,2,3 or 4)?
;
const html ShowPicks3 =
There are 3 toothpicks left...
How many picks do want to get (1,2 or 3)?
;
const html ShowPicks2 =
There are 2 toothpicks left...
How many picks do want to get (1 or 2)?
;
const html ComputerBegin =
Since I begin, I will take 1 toothpick...
;
const html ComputerLost =
Oups... you have win. I will take a revenge anytime!!!!
;
const html PlayerLost =
You lose!!!!!!.
;
const html Welcome =
How to play:
1) It is a two players game
2) Start with 21 toothpicks, arranged in a line.
3) On each turn, a player may remove between 1 and 4 toothpicks.
4) The winner is the player who get the last toothpick.
;
const html ShowStats =
Number of compter win : <[win]>
Number of compter lost : <[lost]>
;
const html Restart =
I have now win <[win]> games and lost <[lost]> games.
Click here to play another game.
;
int lost;
int win;
int GetComputerMove(int x)
{
int returnVal;
returnVal = 4;
if(x==2)
return 2;
if(x==3)
return 3;
if(x==4)
return 4;
if(x==1)
return 1;
while(returnVal>1 && (x-returnVal)%5 != 0)
returnVal = returnVal-1;
return returnVal;
}
session Magic(){
show WelcomeMagic;
show ShowCards1;
show Wait;
show ShowCards2;
}
session Stats(){
exit plug ShowStats[win=win,lost=lost];
}
session Play() {
int count;
int val;
int winner;
int computerMove;
string begin;
count = 21;
val = 5;
winner = 0;
show Welcome;
while(count != 0){
while(winner==0 && (val<0 || val>4 || (count-val) < 0)){
if(count == 21)
show ShowPicks21 receive[val=toothpicks];
if(count == 20)
show ShowPicks20 receive[val=toothpicks];
if(count == 19)
show ShowPicks19 receive[val=toothpicks];
if(count == 18)
show ShowPicks18 receive[val=toothpicks];
if(count == 17)
show ShowPicks17 receive[val=toothpicks];
if(count == 16)
show ShowPicks16 receive[val=toothpicks];
if(count == 15)
show ShowPicks15 receive[val=toothpicks];
if(count == 14)
show ShowPicks14 receive[val=toothpicks];
if(count == 13)
show ShowPicks13 receive[val=toothpicks];
if(count == 12)
show ShowPicks12 receive[val=toothpicks];
if(count == 11)
show ShowPicks11 receive[val=toothpicks];
if(count == 10)
show ShowPicks10 receive[val=toothpicks];
if(count == 9)
show ShowPicks9 receive[val=toothpicks];
if(count == 8)
show ShowPicks8 receive[val=toothpicks];
if(count == 7)
show ShowPicks7 receive[val=toothpicks];
if(count == 6)
show ShowPicks6 receive[val=toothpicks];
if(count == 5)
show ShowPicks5 receive[val=toothpicks];
if(count == 4)
show ShowPicks4 receive[val=toothpicks];
if(count == 3)
show ShowPicks3 receive[val=toothpicks];
if(count == 2)
show ShowPicks2 receive[val=toothpicks];
}
count = count-val;
if(count==0)
winner = 1;
else{
computerMove = GetComputerMove(count);
show plug ComputerPlay[computer=computerMove];
count = count-computerMove;
if(count==0)
winner = 2;
}
val = 5;
}
if(winner==1){
show ComputerLost;
lost = lost+1;
}
else{
show PlayerLost;
win = win+1;
}
exit plug Restart[win=win,lost=lost];
}
}