RosettaCodeData/Task/Penneys-game/MiniScript/penneys-game.mini

31 lines
743 B
Plaintext

randomTorH = function()
if rnd < 0.5 then return "T" else return "H"
end function
if rnd < 0.5 then
playerSeq = input("Input your sequence (e.g. HTH): ").upper
if playerSeq[1] == "T" then compSeq = "H" else compSeq = "T"
compSeq = compSeq + playerSeq[:2]
print "I choose: " + compSeq
else
compSeq = randomTorH + randomTorH + randomTorH
print "I choose: " + compSeq
playerSeq = input("Input your sequence (e.g. HTH): ").upper
end if
print "Here we go..."
seq = ""
while true
flip = randomTorH
print flip
seq = seq + flip
if seq[-3:] == playerSeq then
print "You win!"
break
else if seq[-3:] == compSeq then
print "I win!"
break
end if
wait
end while