battlesnake 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/lib/battlesnake/board.rb +13 -2
- data/lib/battlesnake/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc1006d3ed555bc10587302b1d0bd9323e92f2a194bc2ce6673ac44e4b502f74
|
4
|
+
data.tar.gz: e5a12dcd3a84f68b6d70735448d115a007909018b27010597753c7dff41aba84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66184f4a9b2474337f1d25a76a4ffd7cd2b63beeb390a7a3261e2ff51911b7c2dcabd453f7510018b785869ab25736d3e31e35e031111cbd4c8ef39966f1182c
|
7
|
+
data.tar.gz: 9ebae26dac464f629359f325f871500d0634a5bdf381ec416b8581ff358777ae94267973c5c937921279afc5dc45490ad63bc8e4357f4f2dce61cde08f0537ca
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/battlesnake/board.rb
CHANGED
@@ -41,12 +41,13 @@ module Battlesnake
|
|
41
41
|
end
|
42
42
|
|
43
43
|
##
|
44
|
-
# List of all occupied locations on the board; snakes,
|
44
|
+
# List of all occupied locations on the board; snakes, hazards, etc.
|
45
|
+
# Does NOT include food, since we don't want to avoid that.
|
45
46
|
#
|
46
47
|
# @return [Array<Location>] list of occupied locations
|
47
48
|
def occupied_locations
|
48
49
|
return @occupied_locations if defined?(@occupied_locations)
|
49
|
-
@occupied_locations = snakes.map(&:body).flatten +
|
50
|
+
@occupied_locations = snakes.map(&:body).flatten + hazards
|
50
51
|
end
|
51
52
|
|
52
53
|
##
|
@@ -79,6 +80,16 @@ module Battlesnake
|
|
79
80
|
on_board?(location) && !occupied?(location)
|
80
81
|
end
|
81
82
|
|
83
|
+
##
|
84
|
+
# Whether the supplied location is food.
|
85
|
+
#
|
86
|
+
# @param [Location] location being tested for availability.
|
87
|
+
#
|
88
|
+
# @return [Boolean] true if location is food.
|
89
|
+
def food?(location)
|
90
|
+
food.include?(location)
|
91
|
+
end
|
92
|
+
|
82
93
|
##
|
83
94
|
# List of directions (up, down, left, right) available for moving from given _Location_.
|
84
95
|
#
|
data/lib/battlesnake/version.rb
CHANGED