Advertisement
Guest User

Forth Rock Paper Scissors Lizard Spock

a guest
Jul 14th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. 1 constant rock
  2. 2 constant paper
  3. 3 constant scissors
  4. 4 constant lizard
  5. 5 constant spock
  6.  
  7. : test-rock dup scissors = if s" rock crushes scissors" else lizard = if s" rock crushes lizard" else 0 then then ;
  8. : test-paper dup rock = if s" paper covers rock" else spock = if s" paper disproves spock" else 0 then then ;
  9. : test-scissors dup lizard = if s" scissors decapitates lizard" else paper = if s" scissors cuts paper" else 0 then then ;
  10. : test-lizard dup paper = if s" lizard eats paper" else spock = if s" lizard poisons spock" else 0 then then ;
  11. : test-spock dup rock = if s" spock vaporizes rock" else scissors = if s" spock smashes scissors" else 0 then then ;
  12.  
  13. : test dup rock = if drop test-rock else dup paper = if drop test-paper else dup scissors = if drop test-scissors else dup lizard = if drop test-lizard else spock = if test-spock then then then then then ;
  14.  
  15. : play 2dup = if ." Tie!" else 2dup test dup 0 = if drop swap test ." Player 1 wins: " type else ." Player 2 wins: " type 2drop then then ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement