home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / logo / labybug / nim.bug < prev    next >
Text File  |  1989-05-12  |  1KB  |  71 lines

  1. to "poly   :d :a
  2. forward :d
  3. right :a
  4. poly :d :a
  5. end
  6.  
  7. to "nim  
  8. cleartext
  9. repeat 5 [pr "]
  10. pr [Welcome to the Game of NIM!]
  11. pr "
  12. pr [This is a game where you and the computer will each]
  13. pr [take turns picking stones from a pile.  The challenge]
  14. pr [is not to stuck with the last stone.]
  15. pr "
  16. pr [You decide...how many stones will each player pick]
  17. pr [on each turn.]
  18. make "pick request
  19. make "picks :pick + 1
  20. pr [How many turns will we have to pick?]
  21. make "turns request
  22. make "total :picks * :turns + 1
  23. game
  24. over
  25. end
  26.  
  27. make "pick "'5
  28. make "picks "'6
  29. make "turns "'6
  30. make "total "'1
  31. to "game  
  32. type [There are ] type :total print [ stones in a pile.]
  33. type [Take from 1 to ] type :pick print [ stones.]
  34. make "key request
  35. if or :key > :pick :key < 1 [correct]
  36. type [I take ] print :picks - :key
  37. make "total :total - :picks
  38. if :total = 1 [stop]
  39. if :total > 1 [game]
  40. end
  41.  
  42. to "correct  
  43. print [Try again!]
  44. make "key request
  45. end
  46.  
  47. make "key "'5
  48. to "over  
  49. repeat 3 [pr "]
  50. print [There is one stone left. I win again.]
  51. end
  52.  
  53. to "pr  :list
  54. print :list
  55. end
  56.  
  57. to "or    :a :b
  58. if :a = "true [output "true]
  59. output :b = "true
  60. end
  61.  
  62. in again.]
  63. end
  64.  
  65. to "pr  :list
  66. print :list
  67. end
  68.  
  69. to "or    :a :b
  70. if :a = "true [output "true]
  71. output