Created
April 27, 2012 14:35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn monster-round-original [player monsters] | |
(loop [n 0 p player] | |
(if (>= n (count monsters)) | |
p | |
(recur (inc n) | |
(if (monster-dead? (nth monsters n)) | |
p | |
(let [r (monster-attack (nth monsters n) p)] | |
(print (:attack r)) | |
(:player r))))))) | |
(defn- attack-player [player monster] | |
(if (monster-dead? monster) | |
player | |
(let [r (monster-attack monster player)] | |
(print (:attack r)) | |
(:player r)))) | |
(defn monster-round-improved [player monsters] | |
(reduce attack-player player monsters)) | |
(defn- attack-monsters [monsters player] | |
(if (monsters-dead? monsters) | |
monsters | |
(do | |
(show-monsters monsters) | |
(player-attack player monsters)))) | |
(defn num-attacks [player] | |
(inc (Math/floor (/ (max 0 (:agility player)) 15)))) | |
(defn player-round [player monsters] | |
(reduce attack-monsters monsters | |
(repeat (num-attacks player) player))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment