Guest User

Untitled

a guest
Oct 21st, 2019
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (format t "LISP Nim~%~%")
  2. (defvar L '())
  3. ;; (setq tok 8)
  4. ;; (format t "We have ~D tokens initially.~%" tok)
  5.  
  6. (defun random123 () ;; this returns a number 1,2,or 3
  7. (+ 1 (random 3))
  8. )
  9.  
  10.  
  11.  
  12. (defun randomPile(L) ;;just returns a random index for any pile
  13.  
  14. 1
  15. )
  16.  
  17. (defun pickPile (L)
  18. ;index 0 can also be done (+ pilenum 1 ) would be needed in print later if thats the case
  19. (setq index 1)
  20. (loop for i from 0 to (length L)
  21. do (
  22. if ( = (nth index L) 0) (setq index (+ index 1))
  23. )
  24. )
  25. (format t "index is : ~D" index)
  26. index
  27.  
  28. )
  29.  
  30. ;;this to0k so long im so dumb
  31. (defun makePiles (N L X)
  32. (setq L (make-list X :initial-element N))
  33. (setq pileNum (pickPile L))
  34. (print L)
  35. (FRESH-LINE)
  36. (format t "(Pile number ~D)" pileNum)
  37. (FRESH-LINE)
  38. (setq curTokens (nth pileNum L))
  39. (format t "(Current number of tokens in pile ~D)" curTokens)
  40. (FRESH-LINE)
  41.  
  42. (setq take (take123 curTokens))
  43. (format t "(Tokens taken from pile ~D)" take)
  44. (setf (nth pileNum L) (- (nth pileNum L) take))
  45. (FRESH-LINE)
  46. (print (nth pileNum L))
  47.  
  48. (format t "(P~D ~D ~D)~S~%" playerNum pileNum take L)
  49. L
  50.  
  51.  
  52. )
  53.  
  54. (defun take123 (tokens)
  55. ;; given # of tokens, return a number 1,2,3 or tokens
  56. (if (>= tokens (setq x (+ 1 (random 3))))
  57. x
  58. tokens
  59. )
  60. )
RAW Paste Data