battlesnake 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,11 +69,13 @@
69
69
  <dl>
70
70
  <dt>Inherits:</dt>
71
71
  <dd>
72
- <span class="inheritName">Object</span>
72
+ <span class="inheritName"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></span>
73
73
 
74
74
  <ul class="fullTree">
75
75
  <li>Object</li>
76
76
 
77
+ <li class="next"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></li>
78
+
77
79
  <li class="next">Battlesnake::Location</li>
78
80
 
79
81
  </ul>
@@ -369,6 +371,17 @@
369
371
  </ul>
370
372
 
371
373
 
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></h3>
384
+ <p class="inherited"><span class='object_link'><a href="Base.html#==-instance_method" title="Battlesnake::Base#== (method)">#==</a></span></p>
372
385
  <div id="constructor_details" class="method_details_list">
373
386
  <h2>Constructor Details</h2>
374
387
 
@@ -995,7 +1008,7 @@
995
1008
  </div>
996
1009
 
997
1010
  <div id="footer">
998
- Generated on Fri Nov 4 14:55:40 2022 by
1011
+ Generated on Sat Nov 5 20:09:02 2022 by
999
1012
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1000
1013
  0.9.28 (ruby-2.7.2).
1001
1014
  </div>
@@ -69,11 +69,13 @@
69
69
  <dl>
70
70
  <dt>Inherits:</dt>
71
71
  <dd>
72
- <span class="inheritName">Object</span>
72
+ <span class="inheritName"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></span>
73
73
 
74
74
  <ul class="fullTree">
75
75
  <li>Object</li>
76
76
 
77
+ <li class="next"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></li>
78
+
77
79
  <li class="next">Battlesnake::Snake</li>
78
80
 
79
81
  </ul>
@@ -502,6 +504,17 @@
502
504
  </ul>
503
505
 
504
506
 
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></h3>
517
+ <p class="inherited"><span class='object_link'><a href="Base.html#==-instance_method" title="Battlesnake::Base#== (method)">#==</a></span></p>
505
518
  <div id="constructor_details" class="method_details_list">
506
519
  <h2>Constructor Details</h2>
507
520
 
@@ -1339,7 +1352,7 @@
1339
1352
  </div>
1340
1353
 
1341
1354
  <div id="footer">
1342
- Generated on Fri Nov 4 14:55:40 2022 by
1355
+ Generated on Sat Nov 5 20:09:02 2022 by
1343
1356
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1344
1357
  0.9.28 (ruby-2.7.2).
1345
1358
  </div>
@@ -79,7 +79,7 @@
79
79
  <dl>
80
80
  <dt>Defined in:</dt>
81
81
  <dd>lib/battlesnake.rb<span class="defines">,<br />
82
- lib/battlesnake/snake.rb,<br /> lib/battlesnake/version.rb,<br /> lib/battlesnake/location.rb</span>
82
+ lib/battlesnake/base.rb,<br /> lib/battlesnake/game.rb,<br /> lib/battlesnake/board.rb,<br /> lib/battlesnake/snake.rb,<br /> lib/battlesnake/version.rb,<br /> lib/battlesnake/location.rb</span>
83
83
  </dd>
84
84
  </dl>
85
85
 
@@ -102,7 +102,7 @@
102
102
 
103
103
 
104
104
 
105
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span>, <span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span>, <span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>
105
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Battlesnake/Base.html" title="Battlesnake::Base (class)">Base</a></span>, <span class='object_link'><a href="Battlesnake/Board.html" title="Battlesnake::Board (class)">Board</a></span>, <span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span>, <span class='object_link'><a href="Battlesnake/Game.html" title="Battlesnake::Game (class)">Game</a></span>, <span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span>, <span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>
106
106
 
107
107
 
108
108
  </p>
@@ -129,7 +129,7 @@
129
129
 
130
130
  </div>
131
131
  </dt>
132
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
132
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.2</span><span class='tstring_end'>&quot;</span></span></pre></dd>
133
133
 
134
134
  </dl>
135
135
 
@@ -145,7 +145,7 @@
145
145
  </div>
146
146
 
147
147
  <div id="footer">
148
- Generated on Fri Nov 4 14:55:40 2022 by
148
+ Generated on Sat Nov 5 20:09:02 2022 by
149
149
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
150
150
  0.9.28 (ruby-2.7.2).
151
151
  </div>
data/docs/_index.html CHANGED
@@ -80,11 +80,25 @@
80
80
  <li class="letter">B</li>
81
81
  <ul>
82
82
 
83
+ <li>
84
+ <span class='object_link'><a href="Battlesnake/Base.html" title="Battlesnake::Base (class)">Base</a></span>
85
+
86
+ <small>(Battlesnake)</small>
87
+
88
+ </li>
89
+
83
90
  <li>
84
91
  <span class='object_link'><a href="Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span>
85
92
 
86
93
  </li>
87
94
 
95
+ <li>
96
+ <span class='object_link'><a href="Battlesnake/Board.html" title="Battlesnake::Board (class)">Board</a></span>
97
+
98
+ <small>(Battlesnake)</small>
99
+
100
+ </li>
101
+
88
102
  </ul>
89
103
  </ul>
90
104
 
@@ -104,6 +118,21 @@
104
118
  </ul>
105
119
 
106
120
 
121
+ <ul id="alpha_G" class="alpha">
122
+ <li class="letter">G</li>
123
+ <ul>
124
+
125
+ <li>
126
+ <span class='object_link'><a href="Battlesnake/Game.html" title="Battlesnake::Game (class)">Game</a></span>
127
+
128
+ <small>(Battlesnake)</small>
129
+
130
+ </li>
131
+
132
+ </ul>
133
+ </ul>
134
+
135
+
107
136
  <ul id="alpha_L" class="alpha">
108
137
  <li class="letter">L</li>
109
138
  <ul>
@@ -142,7 +171,7 @@
142
171
  </div>
143
172
 
144
173
  <div id="footer">
145
- Generated on Fri Nov 4 14:55:40 2022 by
174
+ Generated on Sat Nov 5 20:09:02 2022 by
146
175
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
147
176
  0.9.28 (ruby-2.7.2).
148
177
  </div>
data/docs/class_list.html CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
  <ul id="full_list" class="class">
45
45
  <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
46
- <li id='object_Battlesnake' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Battlesnake::Error' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span> &lt; StandardError<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Location' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Snake' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li></ul></li>
46
+ <li id='object_Battlesnake' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Battlesnake::Base' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Base.html" title="Battlesnake::Base (class)">Base</a></span> &lt; Object<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Board' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Board.html" title="Battlesnake::Board (class)">Board</a></span> &lt; Base<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Error' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Error.html" title="Battlesnake::Error (class)">Error</a></span> &lt; StandardError<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Game' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Game.html" title="Battlesnake::Game (class)">Game</a></span> &lt; Base<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Location' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Location.html" title="Battlesnake::Location (class)">Location</a></span> &lt; Base<small class='search_info'>Battlesnake</small></div></li><li id='object_Battlesnake::Snake' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Battlesnake/Snake.html" title="Battlesnake::Snake (class)">Snake</a></span> &lt; Base<small class='search_info'>Battlesnake</small></div></li></ul></li>
47
47
 
48
48
  </ul>
49
49
  </div>
@@ -83,7 +83,7 @@
83
83
 
84
84
  <h2 id="label-Usage">Usage</h2>
85
85
 
86
- <p>Examples coming soon. For now, view our <a href="https://raw.githubusercontent.com/bellmyer/battlesnake/master/doc/_index.html">documentation</a>.</p>
86
+ <p>Examples coming soon. For now, view our <a href="https://bellmyer.github.io/battlesnake/">documentation</a>.</p>
87
87
 
88
88
  <h2 id="label-Development">Development</h2>
89
89
 
@@ -97,7 +97,7 @@
97
97
  </div></div>
98
98
 
99
99
  <div id="footer">
100
- Generated on Fri Nov 4 14:55:40 2022 by
100
+ Generated on Sat Nov 5 20:09:02 2022 by
101
101
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
102
102
  0.9.28 (ruby-2.7.2).
103
103
  </div>
data/docs/index.html CHANGED
@@ -83,7 +83,7 @@
83
83
 
84
84
  <h2 id="label-Usage">Usage</h2>
85
85
 
86
- <p>Examples coming soon. For now, view our <a href="https://raw.githubusercontent.com/bellmyer/battlesnake/master/doc/_index.html">documentation</a>.</p>
86
+ <p>Examples coming soon. For now, view our <a href="https://bellmyer.github.io/battlesnake/">documentation</a>.</p>
87
87
 
88
88
  <h2 id="label-Development">Development</h2>
89
89
 
@@ -97,7 +97,7 @@
97
97
  </div></div>
98
98
 
99
99
  <div id="footer">
100
- Generated on Fri Nov 4 14:55:40 2022 by
100
+ Generated on Sat Nov 5 20:09:02 2022 by
101
101
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
102
102
  0.9.28 (ruby-2.7.2).
103
103
  </div>
@@ -46,8 +46,8 @@
46
46
 
47
47
  <li class="odd ">
48
48
  <div class="item">
49
- <span class='object_link'><a href="Battlesnake/Snake.html#as_json-instance_method" title="Battlesnake::Snake#as_json (method)">#as_json</a></span>
50
- <small>Battlesnake::Snake</small>
49
+ <span class='object_link'><a href="Battlesnake/Base.html#==-instance_method" title="Battlesnake::Base#== (method)">#==</a></span>
50
+ <small>Battlesnake::Base</small>
51
51
  </div>
52
52
  </li>
53
53
 
@@ -62,13 +62,53 @@
62
62
 
63
63
  <li class="odd ">
64
64
  <div class="item">
65
- <span class='object_link'><a href="Battlesnake/Snake.html#body-instance_method" title="Battlesnake::Snake#body (method)">#body</a></span>
65
+ <span class='object_link'><a href="Battlesnake/Snake.html#as_json-instance_method" title="Battlesnake::Snake#as_json (method)">#as_json</a></span>
66
66
  <small>Battlesnake::Snake</small>
67
67
  </div>
68
68
  </li>
69
69
 
70
70
 
71
71
  <li class="even ">
72
+ <div class="item">
73
+ <span class='object_link'><a href="Battlesnake/Game.html#as_json-instance_method" title="Battlesnake::Game#as_json (method)">#as_json</a></span>
74
+ <small>Battlesnake::Game</small>
75
+ </div>
76
+ </li>
77
+
78
+
79
+ <li class="odd ">
80
+ <div class="item">
81
+ <span class='object_link'><a href="Battlesnake/Board.html#as_json-instance_method" title="Battlesnake::Board#as_json (method)">#as_json</a></span>
82
+ <small>Battlesnake::Board</small>
83
+ </div>
84
+ </li>
85
+
86
+
87
+ <li class="even ">
88
+ <div class="item">
89
+ <span class='object_link'><a href="Battlesnake/Board.html#available%3F-instance_method" title="Battlesnake::Board#available? (method)">#available?</a></span>
90
+ <small>Battlesnake::Board</small>
91
+ </div>
92
+ </li>
93
+
94
+
95
+ <li class="odd ">
96
+ <div class="item">
97
+ <span class='object_link'><a href="Battlesnake/Board.html#available_directions-instance_method" title="Battlesnake::Board#available_directions (method)">#available_directions</a></span>
98
+ <small>Battlesnake::Board</small>
99
+ </div>
100
+ </li>
101
+
102
+
103
+ <li class="even ">
104
+ <div class="item">
105
+ <span class='object_link'><a href="Battlesnake/Snake.html#body-instance_method" title="Battlesnake::Snake#body (method)">#body</a></span>
106
+ <small>Battlesnake::Snake</small>
107
+ </div>
108
+ </li>
109
+
110
+
111
+ <li class="odd ">
72
112
  <div class="item">
73
113
  <span class='object_link'><a href="Battlesnake/Location.html#coords-instance_method" title="Battlesnake::Location#coords (method)">#coords</a></span>
74
114
  <small>Battlesnake::Location</small>
@@ -76,7 +116,7 @@
76
116
  </li>
77
117
 
78
118
 
79
- <li class="odd ">
119
+ <li class="even ">
80
120
  <div class="item">
81
121
  <span class='object_link'><a href="Battlesnake/Snake.html#customizations-instance_method" title="Battlesnake::Snake#customizations (method)">#customizations</a></span>
82
122
  <small>Battlesnake::Snake</small>
@@ -84,7 +124,7 @@
84
124
  </li>
85
125
 
86
126
 
87
- <li class="even ">
127
+ <li class="odd ">
88
128
  <div class="item">
89
129
  <span class='object_link'><a href="Battlesnake/Snake.html#direction-instance_method" title="Battlesnake::Snake#direction (method)">#direction</a></span>
90
130
  <small>Battlesnake::Snake</small>
@@ -92,7 +132,7 @@
92
132
  </li>
93
133
 
94
134
 
95
- <li class="odd ">
135
+ <li class="even ">
96
136
  <div class="item">
97
137
  <span class='object_link'><a href="Battlesnake/Location.html#direction-instance_method" title="Battlesnake::Location#direction (method)">#direction</a></span>
98
138
  <small>Battlesnake::Location</small>
@@ -100,7 +140,7 @@
100
140
  </li>
101
141
 
102
142
 
103
- <li class="even ">
143
+ <li class="odd ">
104
144
  <div class="item">
105
145
  <span class='object_link'><a href="Battlesnake/Location.html#distance-instance_method" title="Battlesnake::Location#distance (method)">#distance</a></span>
106
146
  <small>Battlesnake::Location</small>
@@ -108,7 +148,23 @@
108
148
  </li>
109
149
 
110
150
 
151
+ <li class="even ">
152
+ <div class="item">
153
+ <span class='object_link'><a href="Battlesnake/Board.html#food-instance_method" title="Battlesnake::Board#food (method)">#food</a></span>
154
+ <small>Battlesnake::Board</small>
155
+ </div>
156
+ </li>
157
+
158
+
111
159
  <li class="odd ">
160
+ <div class="item">
161
+ <span class='object_link'><a href="Battlesnake/Board.html#hazards-instance_method" title="Battlesnake::Board#hazards (method)">#hazards</a></span>
162
+ <small>Battlesnake::Board</small>
163
+ </div>
164
+ </li>
165
+
166
+
167
+ <li class="even ">
112
168
  <div class="item">
113
169
  <span class='object_link'><a href="Battlesnake/Snake.html#head-instance_method" title="Battlesnake::Snake#head (method)">#head</a></span>
114
170
  <small>Battlesnake::Snake</small>
@@ -116,7 +172,7 @@
116
172
  </li>
117
173
 
118
174
 
119
- <li class="even ">
175
+ <li class="odd ">
120
176
  <div class="item">
121
177
  <span class='object_link'><a href="Battlesnake/Snake.html#health-instance_method" title="Battlesnake::Snake#health (method)">#health</a></span>
122
178
  <small>Battlesnake::Snake</small>
@@ -124,6 +180,14 @@
124
180
  </li>
125
181
 
126
182
 
183
+ <li class="even ">
184
+ <div class="item">
185
+ <span class='object_link'><a href="Battlesnake/Board.html#height-instance_method" title="Battlesnake::Board#height (method)">#height</a></span>
186
+ <small>Battlesnake::Board</small>
187
+ </div>
188
+ </li>
189
+
190
+
127
191
  <li class="odd ">
128
192
  <div class="item">
129
193
  <span class='object_link'><a href="Battlesnake/Snake.html#id-instance_method" title="Battlesnake::Snake#id (method)">#id</a></span>
@@ -134,8 +198,8 @@
134
198
 
135
199
  <li class="even ">
136
200
  <div class="item">
137
- <span class='object_link'><a href="Battlesnake/Location.html#initialize-instance_method" title="Battlesnake::Location#initialize (method)">#initialize</a></span>
138
- <small>Battlesnake::Location</small>
201
+ <span class='object_link'><a href="Battlesnake/Game.html#id-instance_method" title="Battlesnake::Game#id (method)">#id</a></span>
202
+ <small>Battlesnake::Game</small>
139
203
  </div>
140
204
  </li>
141
205
 
@@ -149,6 +213,30 @@
149
213
 
150
214
 
151
215
  <li class="even ">
216
+ <div class="item">
217
+ <span class='object_link'><a href="Battlesnake/Location.html#initialize-instance_method" title="Battlesnake::Location#initialize (method)">#initialize</a></span>
218
+ <small>Battlesnake::Location</small>
219
+ </div>
220
+ </li>
221
+
222
+
223
+ <li class="odd ">
224
+ <div class="item">
225
+ <span class='object_link'><a href="Battlesnake/Board.html#initialize-instance_method" title="Battlesnake::Board#initialize (method)">#initialize</a></span>
226
+ <small>Battlesnake::Board</small>
227
+ </div>
228
+ </li>
229
+
230
+
231
+ <li class="even ">
232
+ <div class="item">
233
+ <span class='object_link'><a href="Battlesnake/Game.html#initialize-instance_method" title="Battlesnake::Game#initialize (method)">#initialize</a></span>
234
+ <small>Battlesnake::Game</small>
235
+ </div>
236
+ </li>
237
+
238
+
239
+ <li class="odd ">
152
240
  <div class="item">
153
241
  <span class='object_link'><a href="Battlesnake/Snake.html#latency-instance_method" title="Battlesnake::Snake#latency (method)">#latency</a></span>
154
242
  <small>Battlesnake::Snake</small>
@@ -156,7 +244,7 @@
156
244
  </li>
157
245
 
158
246
 
159
- <li class="odd ">
247
+ <li class="even ">
160
248
  <div class="item">
161
249
  <span class='object_link'><a href="Battlesnake/Snake.html#length-instance_method" title="Battlesnake::Snake#length (method)">#length</a></span>
162
250
  <small>Battlesnake::Snake</small>
@@ -164,6 +252,14 @@
164
252
  </li>
165
253
 
166
254
 
255
+ <li class="odd ">
256
+ <div class="item">
257
+ <span class='object_link'><a href="Battlesnake/Game.html#map-instance_method" title="Battlesnake::Game#map (method)">#map</a></span>
258
+ <small>Battlesnake::Game</small>
259
+ </div>
260
+ </li>
261
+
262
+
167
263
  <li class="even ">
168
264
  <div class="item">
169
265
  <span class='object_link'><a href="Battlesnake/Location.html#move-instance_method" title="Battlesnake::Location#move (method)">#move</a></span>
@@ -181,6 +277,30 @@
181
277
 
182
278
 
183
279
  <li class="even ">
280
+ <div class="item">
281
+ <span class='object_link'><a href="Battlesnake/Board.html#occupied%3F-instance_method" title="Battlesnake::Board#occupied? (method)">#occupied?</a></span>
282
+ <small>Battlesnake::Board</small>
283
+ </div>
284
+ </li>
285
+
286
+
287
+ <li class="odd ">
288
+ <div class="item">
289
+ <span class='object_link'><a href="Battlesnake/Board.html#occupied_locations-instance_method" title="Battlesnake::Board#occupied_locations (method)">#occupied_locations</a></span>
290
+ <small>Battlesnake::Board</small>
291
+ </div>
292
+ </li>
293
+
294
+
295
+ <li class="even ">
296
+ <div class="item">
297
+ <span class='object_link'><a href="Battlesnake/Game.html#ruleset-instance_method" title="Battlesnake::Game#ruleset (method)">#ruleset</a></span>
298
+ <small>Battlesnake::Game</small>
299
+ </div>
300
+ </li>
301
+
302
+
303
+ <li class="odd ">
184
304
  <div class="item">
185
305
  <span class='object_link'><a href="Battlesnake/Snake.html#shout-instance_method" title="Battlesnake::Snake#shout (method)">#shout</a></span>
186
306
  <small>Battlesnake::Snake</small>
@@ -188,7 +308,23 @@
188
308
  </li>
189
309
 
190
310
 
311
+ <li class="even ">
312
+ <div class="item">
313
+ <span class='object_link'><a href="Battlesnake/Board.html#snakes-instance_method" title="Battlesnake::Board#snakes (method)">#snakes</a></span>
314
+ <small>Battlesnake::Board</small>
315
+ </div>
316
+ </li>
317
+
318
+
191
319
  <li class="odd ">
320
+ <div class="item">
321
+ <span class='object_link'><a href="Battlesnake/Game.html#source-instance_method" title="Battlesnake::Game#source (method)">#source</a></span>
322
+ <small>Battlesnake::Game</small>
323
+ </div>
324
+ </li>
325
+
326
+
327
+ <li class="even ">
192
328
  <div class="item">
193
329
  <span class='object_link'><a href="Battlesnake/Snake.html#squad-instance_method" title="Battlesnake::Snake#squad (method)">#squad</a></span>
194
330
  <small>Battlesnake::Snake</small>
@@ -196,7 +332,23 @@
196
332
  </li>
197
333
 
198
334
 
335
+ <li class="odd ">
336
+ <div class="item">
337
+ <span class='object_link'><a href="Battlesnake/Game.html#timeout-instance_method" title="Battlesnake::Game#timeout (method)">#timeout</a></span>
338
+ <small>Battlesnake::Game</small>
339
+ </div>
340
+ </li>
341
+
342
+
199
343
  <li class="even ">
344
+ <div class="item">
345
+ <span class='object_link'><a href="Battlesnake/Board.html#width-instance_method" title="Battlesnake::Board#width (method)">#width</a></span>
346
+ <small>Battlesnake::Board</small>
347
+ </div>
348
+ </li>
349
+
350
+
351
+ <li class="odd ">
200
352
  <div class="item">
201
353
  <span class='object_link'><a href="Battlesnake/Location.html#x-instance_method" title="Battlesnake::Location#x (method)">#x</a></span>
202
354
  <small>Battlesnake::Location</small>
@@ -204,7 +356,7 @@
204
356
  </li>
205
357
 
206
358
 
207
- <li class="odd ">
359
+ <li class="even ">
208
360
  <div class="item">
209
361
  <span class='object_link'><a href="Battlesnake/Location.html#y-instance_method" title="Battlesnake::Location#y (method)">#y</a></span>
210
362
  <small>Battlesnake::Location</small>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Fri Nov 4 14:55:40 2022 by
103
+ Generated on Sat Nov 5 20:09:02 2022 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.28 (ruby-2.7.2).
106
106
  </div>
@@ -0,0 +1,15 @@
1
+ module Battlesnake
2
+ ##
3
+ # Base class for "model" classes - _Game, Board, Snake, Location,_ etc.
4
+ class Base
5
+ ##
6
+ # Whether both locations have the same coordinates.
7
+ #
8
+ # @param other [Location]
9
+ #
10
+ # @return [Boolean] true if location objects have the same coordinates.
11
+ def ==(other)
12
+ other.is_a?(self.class) && self.as_json == other.as_json
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,89 @@
1
+ require 'json'
2
+
3
+ module Battlesnake
4
+ ##
5
+ # Represents a single iteration (turn) of a Battlesnake board during gameplay.
6
+ class Board < Base
7
+ # @return [Hash] board as a data structure usable by other objects.
8
+ attr_reader :as_json
9
+
10
+ # @return [Integer] height of the board
11
+ attr_reader :height
12
+
13
+ # @return [Integer] width of the board
14
+ attr_reader :width
15
+
16
+ # @return [Array<Snake>] list of snake objects
17
+ attr_reader :snakes
18
+
19
+ # @return [Array<Location>] list of food location objects
20
+ attr_reader :food
21
+
22
+ # @return [Array<Location>] list of hazard location objects
23
+ attr_reader :hazards
24
+
25
+ ##
26
+ # Returns a new instance of Board.
27
+ #
28
+ # @param json_or_hash [String,Hash] can be a hash of attributes, or a JSON string which
29
+ # represents such a structure.
30
+ #
31
+ # @return [Board]
32
+ def initialize(json_or_hash)
33
+ data = json_or_hash.is_a?(String) ? JSON.parse(json_or_hash) : json_or_hash
34
+
35
+ @as_json = data
36
+ @height = data['height']
37
+ @width = data['width']
38
+ @snakes = data['snakes'].map{ |attrs| Snake.new(attrs) }
39
+ @food = data['food'].map{ |attrs| Location.new(attrs) }
40
+ @hazards = data['hazards'].map{ |attrs| Location.new(attrs) }
41
+ end
42
+
43
+ ##
44
+ # List of all occupied locations on the board; snakes, food, hazards, etc
45
+ #
46
+ # @return [Array<Location>] list of occupied locations
47
+ def occupied_locations
48
+ return @occupied_locations if defined?(@occupied_locations)
49
+ @occupied_locations = snakes.map(&:body).flatten + food + hazards
50
+ end
51
+
52
+ ##
53
+ # Whether the supplied location is occupied.
54
+ #
55
+ # @param *coordinates [Location,Hash,String,Array] can be specified as a _Location_ object,
56
+ # hash containing x/y keys, JSON string of such a hash, or a pair of x,y coordinates expressed
57
+ # as a 2-element array or two separate parameters.
58
+ #
59
+ # @return [Boolean] true if location is occupied by snakes, food, hazards, etc.
60
+ def occupied?(*coordinates)
61
+ location = coordinates.first.is_a?(Location) ? coordinates.first : Location.new(*coordinates)
62
+ occupied_locations.include?(location)
63
+ end
64
+
65
+ ##
66
+ # Whether the supplied location is available (unoccupied).
67
+ #
68
+ # @param *coordinates [Location,Hash,String,Array] can be specified as a _Location_ object,
69
+ # hash containing x/y keys, JSON string of such a hash, or a pair of x,y coordinates expressed
70
+ # as a 2-element array or two separate parameters.
71
+ #
72
+ # @return [Boolean] true if location is available (unoccupied by snakes, food, hazards, etc).
73
+ def available?(*coordinates)
74
+ !occupied?(*coordinates)
75
+ end
76
+
77
+ ##
78
+ # List of directions (up, down, left, right) available for moving from given _Location_.
79
+ #
80
+ # @param [Location] location from which moving is desired.
81
+ #
82
+ # @return [Array<String>] list of direction strings ("up", "down", "left", "right")
83
+ def available_directions(location)
84
+ Location::DIRECTIONS.select do |direction|
85
+ available?(location.move(direction))
86
+ end
87
+ end
88
+ end
89
+ end