Skip to content

Commit 3eb9013

Browse files
authored
Merge pull request #1 from GregA100k/navigate-fix
fix naive-navigate to use position of destination
2 parents c8cab4e + 3a0ee92 commit 3eb9013

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

starter_kits/Clojure/hlt/lib/hlt/game_map.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
still if no such move exists."
102102
[ship destination]
103103
(let [ship-position (:position ship)
104-
unsafe-moves (get-unsafe-moves ship-position destination)
104+
destination-position (:position destination)
105+
unsafe-moves (get-unsafe-moves ship-position destination-position)
105106
dir (reduce
106107
(fn [_ direction]
107108
(if (is-empty?

starter_kits/Clojure/project.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[com.taoensso/timbre "4.10.0"]
44
[org.clojure/data.json "0.2.6"]]
55
:source-paths ["hlt/lib" "hlt/app"]
6+
:test-paths ["test"]
67
:main MyBot
78
:aot [MyBot]
89
:uberjar-name "MyBot.jar")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(ns hlt.game-map-test
2+
(:require [clojure.test :refer :all]
3+
[hlt.ship :as ship]
4+
[hlt.player :as player]
5+
[hlt.shipyard :as shipyard]
6+
[hlt.game-map :refer :all]))
7+
8+
(deftest test-naive-navigate
9+
(with-redefs [game-map (fn [] {:width 32 :height 32})
10+
]
11+
(let [ship {::ship/id 1 ::player/id 0 :position [8 10] :halite 100}
12+
shipyard {::shipyard/id -1 ::player/id 0 :position [8 16]}
13+
14+
]
15+
(is (= [0 1] (naive-navigate ship shipyard)))
16+
)))

0 commit comments

Comments
 (0)