Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (def fighters [
- ["Ryu", "E.Honda", "Blanka", "Guile", "Balrog", "Vega"],
- ["Ken", "Chun Li", "Zangief", "Dhalsim", "Sagat", "M.Bison"]
- ])
- (def initital_position '(0 0))
- (def moves ["up", "left", "right", "left", "left"])
- (defn proc-input [pos move]
- ;; "returns new pos"
- (list
- (cond ;; X coord
- (= move "up") (dec (first pos))
- (= move "down") (inc (first pos))
- :else (first pos))
- (cond
- (= move "left") (dec (first (next pos)))
- (= move "right") (inc (first (next pos)))
- :else (first (next pos))))
- )
- (proc-input '(0,0) "up") ;; => (-1,0)
- (proc-input '(0,0) "down") ;; => (1,0)
- (proc-input '(0,0) "left") ;; => (0,-1)
- (proc-input '(0,0) "right") ;; => (0,1)
- (defn clamp-pos [pos]
- (let [x (first pos)
- y (first (next pos))]
- (list
- (cond
- (< x 0) 0
- (> x 1) 1
- :else x)
- (mod y 6))
- )
- )
- (clamp-pos '(-1,0)) ;; => (0,0)
- (clamp-pos '(2,0)) ;; => (1,0)
- (clamp-pos '(0,-1)) ;; => (0,5)
- (clamp-pos '(0,-6)) ;; => (0,0)
- (clamp-pos '(0,-1)) ;; => (0,0)
- (defn street-fighter-selection [fighters position move]
- (let [hmax (dec (count fighters))
- vmax (dec (count (first fighters))) ]
- ;;(apply #(proc-input position %) move)
- ;;((fighters 0) 0)
- )
- )
- ;;(street-fighter-selection fighters initital_position moves)
- ;; => ['Ryu', 'Vega', 'Ryu', 'Vega', 'Balrog']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement