home *** CD-ROM | disk | FTP | other *** search
- to "poly :d :a
- forward :d
- right :a
- poly :d :a
- end
-
- to "nim
- cleartext
- repeat 5 [pr "]
- pr [Welcome to the Game of NIM!]
- pr "
- pr [This is a game where you and the computer will each]
- pr [take turns picking stones from a pile. The challenge]
- pr [is not to stuck with the last stone.]
- pr "
- pr [You decide...how many stones will each player pick]
- pr [on each turn.]
- make "pick request
- make "picks :pick + 1
- pr [How many turns will we have to pick?]
- make "turns request
- make "total :picks * :turns + 1
- game
- over
- end
-
- make "pick "'5
- make "picks "'6
- make "turns "'6
- make "total "'1
- to "game
- type [There are ] type :total print [ stones in a pile.]
- type [Take from 1 to ] type :pick print [ stones.]
- make "key request
- if or :key > :pick :key < 1 [correct]
- type [I take ] print :picks - :key
- make "total :total - :picks
- if :total = 1 [stop]
- if :total > 1 [game]
- end
-
- to "correct
- print [Try again!]
- make "key request
- end
-
- make "key "'5
- to "over
- repeat 3 [pr "]
- print [There is one stone left. I win again.]
- end
-
- to "pr :list
- print :list
- end
-
- to "or :a :b
- if :a = "true [output "true]
- output :b = "true
- end
-
- in again.]
- end
-
- to "pr :list
- print :list
- end
-
- to "or :a :b
- if :a = "true [output "true]
- output