Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
1,604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (def fighters [
  2.     ["Ryu", "E.Honda", "Blanka", "Guile", "Balrog", "Vega"],
  3.     ["Ken", "Chun Li", "Zangief", "Dhalsim", "Sagat", "M.Bison"]
  4.   ])
  5. (def initital_position '(0 0))
  6. (def moves ["up", "left", "right", "left", "left"])
  7.  
  8. (defn proc-input [pos move]
  9.   ;; "returns new pos"
  10.   (list
  11.     (cond ;; X coord
  12.       (= move "up") (dec (first pos))
  13.       (= move "down") (inc (first pos))
  14.       :else (first pos))
  15.     (cond
  16.       (= move "left") (dec (first (next pos)))
  17.       (= move "right") (inc (first (next pos)))
  18.       :else (first (next pos))))
  19. )
  20.  
  21. (proc-input '(0,0) "up") ;; => (-1,0)
  22. (proc-input '(0,0) "down") ;; => (1,0)
  23. (proc-input '(0,0) "left") ;; => (0,-1)
  24. (proc-input '(0,0) "right") ;; => (0,1)
  25.  
  26.  
  27. (defn clamp-pos [pos]
  28.   (let [x (first pos)
  29.         y (first (next pos))]    
  30.     (list
  31.       (cond
  32.         (< x 0) 0
  33.         (> x 1) 1
  34.         :else x)
  35.       (mod y 6))
  36.   )
  37. )
  38.  
  39. (clamp-pos '(-1,0)) ;; => (0,0)
  40. (clamp-pos '(2,0))  ;; => (1,0)
  41. (clamp-pos '(0,-1)) ;; => (0,5)
  42. (clamp-pos '(0,-6)) ;; => (0,0)
  43. (clamp-pos '(0,-1)) ;; => (0,0)
  44.  
  45.  
  46.  
  47. (defn street-fighter-selection [fighters position move]
  48.   (let [hmax (dec (count fighters))
  49.         vmax (dec (count (first fighters)))        ]
  50.     ;;(apply #(proc-input position %) move)
  51.     ;;((fighters 0) 0)
  52.   )
  53. )
  54.  
  55. ;;(street-fighter-selection fighters initital_position moves)
  56. ;; => ['Ryu', 'Vega', 'Ryu', 'Vega', 'Balrog']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement