home *** CD-ROM | disk | FTP | other *** search
- ;Stones game
-
- ; RemainingStones is the number of remaining stones. (15 thru 35)
- ; MaxTakePerTurn is the most you can take away at one time (3 thru 6)
-
- CR=StrCat(Num2Char(13),Num2Char(10))
- TextBox("HOW 2 PLAY STONES","stones.wtx")
- ClipPut("")
- if WinExist("Clipboard") then WinZoom("Clipboard")
- if !WinExist("Clipboard") then RunZoom("clipbrd.exe","")
-
-
- :playitagainsam
- RemainingStones=Random(21)
- ;Normalize RemainingStones to be between 15 and 35
- RemainingStones = RemainingStones + 15
-
- MaxTakePerTurn=Random(3)
- ;Normalize MaxTakePerTurn to be between 3 and 6
- MaxTakePerTurn = MaxTakePerTurn + 3
- TheMagicNumber = MaxTakePerTurn + 1
-
- ClipPut("STONES%CR%")
- ClipAppend("Starting with %RemainingStones% Stones.%CR%")
-
- :next
- PlayerTakes=AskLine("STONES","%RemainingStones% Stones left. Take 1 to %MaxTakePerTurn% stones","")
-
- if PlayerTakes<1 then goto cheat
- if PlayerTakes>MaxTakePerTurn then goto cheat
- goto gotok
-
- :cheat
- Message("STONES","You cheat! You may only take 1 to %MaxTakePerTurn% stones.")
- goto next
-
- :gotok
- ClipAppend("Human takes %PlayerTakes% stones%CR%")
- if PlayerTakes>=RemainingStones then goto youlose
-
- RemainingStones = RemainingStones - PlayerTakes
- if RemainingStones==1 then goto complose
-
- MyMove =RemainingStones - 1
- MyMove = MyMove mod TheMagicNumber
- if MyMove == 0 then MyMove = Random(MaxTakePerTurn)+1
- StonesLeft =RemainingStones - MyMove
- ClipAppend("Hmm %RemainingStones% stones left. I take %MyMove% stones, leaving %StonesLeft%.%CR%")
- RemainingStones = StonesLeft
- if RemainingStones==1 then goto youlose
- goto next
-
- :youlose
- ClipAppend("Human stuck with final stone.%CR%")
- Message("STONES","Nyah Nyah Nyah. You Lose.")
- goto bye
-
- :complose
- ClipAppend("Hmmm I lost. Human must be running program on defective CPU.%CR%")
- Message("STONES","Hmmm. I lost. CPU must be damaged. Please replace.")
- :bye
- Response=AskYesNo("STONES","Would you like to play again?")
- if Response == @TRUE then goto playitagainsam
- ErrorMode(@off)
- if WinExist("Clipboard") then WinClose("Clipboard")
- exit
-
-