battlesnake 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1217 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Battlesnake::Board
8
+
9
+ &mdash; Documentation by YARD 0.9.28
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Battlesnake::Board";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Battlesnake.html" title="Battlesnake (module)">Battlesnake</a></span></span>
41
+ &raquo;
42
+ <span class="title">Board</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Battlesnake::Board
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></li>
78
+
79
+ <li class="next">Battlesnake::Board</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/battlesnake/board.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>Represents a single iteration (turn) of a Battlesnake board during gameplay.</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div>
116
+
117
+
118
+
119
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
120
+ <ul class="summary">
121
+
122
+ <li class="public ">
123
+ <span class="summary_signature">
124
+
125
+ <a href="#as_json-instance_method" title="#as_json (instance method)">#<strong>as_json</strong> &#x21d2; Hash </a>
126
+
127
+
128
+
129
+ </span>
130
+
131
+
132
+
133
+
134
+ <span class="note title readonly">readonly</span>
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+ <span class="summary_desc"><div class='inline'>
145
+ <p>Board as a data structure usable by other objects.</p>
146
+ </div></span>
147
+
148
+ </li>
149
+
150
+
151
+ <li class="public ">
152
+ <span class="summary_signature">
153
+
154
+ <a href="#food-instance_method" title="#food (instance method)">#<strong>food</strong> &#x21d2; Array&lt;Location&gt; </a>
155
+
156
+
157
+
158
+ </span>
159
+
160
+
161
+
162
+
163
+ <span class="note title readonly">readonly</span>
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+ <span class="summary_desc"><div class='inline'>
174
+ <p>List of food location objects.</p>
175
+ </div></span>
176
+
177
+ </li>
178
+
179
+
180
+ <li class="public ">
181
+ <span class="summary_signature">
182
+
183
+ <a href="#hazards-instance_method" title="#hazards (instance method)">#<strong>hazards</strong> &#x21d2; Array&lt;Location&gt; </a>
184
+
185
+
186
+
187
+ </span>
188
+
189
+
190
+
191
+
192
+ <span class="note title readonly">readonly</span>
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+ <span class="summary_desc"><div class='inline'>
203
+ <p>List of hazard location objects.</p>
204
+ </div></span>
205
+
206
+ </li>
207
+
208
+
209
+ <li class="public ">
210
+ <span class="summary_signature">
211
+
212
+ <a href="#height-instance_method" title="#height (instance method)">#<strong>height</strong> &#x21d2; Integer </a>
213
+
214
+
215
+
216
+ </span>
217
+
218
+
219
+
220
+
221
+ <span class="note title readonly">readonly</span>
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+ <span class="summary_desc"><div class='inline'>
232
+ <p>Height of the board.</p>
233
+ </div></span>
234
+
235
+ </li>
236
+
237
+
238
+ <li class="public ">
239
+ <span class="summary_signature">
240
+
241
+ <a href="#snakes-instance_method" title="#snakes (instance method)">#<strong>snakes</strong> &#x21d2; Array&lt;Snake&gt; </a>
242
+
243
+
244
+
245
+ </span>
246
+
247
+
248
+
249
+
250
+ <span class="note title readonly">readonly</span>
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+ <span class="summary_desc"><div class='inline'>
261
+ <p>List of snake objects.</p>
262
+ </div></span>
263
+
264
+ </li>
265
+
266
+
267
+ <li class="public ">
268
+ <span class="summary_signature">
269
+
270
+ <a href="#width-instance_method" title="#width (instance method)">#<strong>width</strong> &#x21d2; Integer </a>
271
+
272
+
273
+
274
+ </span>
275
+
276
+
277
+
278
+
279
+ <span class="note title readonly">readonly</span>
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+ <span class="summary_desc"><div class='inline'>
290
+ <p>Width of the board.</p>
291
+ </div></span>
292
+
293
+ </li>
294
+
295
+
296
+ </ul>
297
+
298
+
299
+
300
+
301
+
302
+ <h2>
303
+ Instance Method Summary
304
+ <small><a href="#" class="summary_toggle">collapse</a></small>
305
+ </h2>
306
+
307
+ <ul class="summary">
308
+
309
+ <li class="public ">
310
+ <span class="summary_signature">
311
+
312
+ <a href="#available%3F-instance_method" title="#available? (instance method)">#<strong>available?</strong>(*coordinates) &#x21d2; Boolean </a>
313
+
314
+
315
+
316
+ </span>
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+ <span class="summary_desc"><div class='inline'>
327
+ <p>Whether the supplied location is available (unoccupied).</p>
328
+ </div></span>
329
+
330
+ </li>
331
+
332
+
333
+ <li class="public ">
334
+ <span class="summary_signature">
335
+
336
+ <a href="#available_directions-instance_method" title="#available_directions (instance method)">#<strong>available_directions</strong>(location) &#x21d2; Array&lt;String&gt; </a>
337
+
338
+
339
+
340
+ </span>
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+ <span class="summary_desc"><div class='inline'>
351
+ <p>List of directions (up, down, left, right) available for moving from given <em>Location</em>.</p>
352
+ </div></span>
353
+
354
+ </li>
355
+
356
+
357
+ <li class="public ">
358
+ <span class="summary_signature">
359
+
360
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(json_or_hash) &#x21d2; Board </a>
361
+
362
+
363
+
364
+ </span>
365
+
366
+
367
+ <span class="note title constructor">constructor</span>
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+ <span class="summary_desc"><div class='inline'>
377
+ <p>Returns a new instance of Board.</p>
378
+ </div></span>
379
+
380
+ </li>
381
+
382
+
383
+ <li class="public ">
384
+ <span class="summary_signature">
385
+
386
+ <a href="#occupied%3F-instance_method" title="#occupied? (instance method)">#<strong>occupied?</strong>(*coordinates) &#x21d2; Boolean </a>
387
+
388
+
389
+
390
+ </span>
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+ <span class="summary_desc"><div class='inline'>
401
+ <p>Whether the supplied location is occupied.</p>
402
+ </div></span>
403
+
404
+ </li>
405
+
406
+
407
+ <li class="public ">
408
+ <span class="summary_signature">
409
+
410
+ <a href="#occupied_locations-instance_method" title="#occupied_locations (instance method)">#<strong>occupied_locations</strong> &#x21d2; Array&lt;Location&gt; </a>
411
+
412
+
413
+
414
+ </span>
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+ <span class="summary_desc"><div class='inline'>
425
+ <p>List of all occupied locations on the board; snakes, food, hazards, etc.</p>
426
+ </div></span>
427
+
428
+ </li>
429
+
430
+
431
+ </ul>
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></h3>
444
+ <p class="inherited"><span class='object_link'><a href="Base.html#==-instance_method" title="Battlesnake::Base#== (method)">#==</a></span></p>
445
+ <div id="constructor_details" class="method_details_list">
446
+ <h2>Constructor Details</h2>
447
+
448
+ <div class="method_details first">
449
+ <h3 class="signature first" id="initialize-instance_method">
450
+
451
+ #<strong>initialize</strong>(json_or_hash) &#x21d2; <tt><span class='object_link'><a href="" title="Battlesnake::Board (class)">Board</a></span></tt>
452
+
453
+
454
+
455
+
456
+
457
+ </h3><div class="docstring">
458
+ <div class="discussion">
459
+
460
+ <p>Returns a new instance of Board.</p>
461
+
462
+
463
+ </div>
464
+ </div>
465
+ <div class="tags">
466
+ <p class="tag_title">Parameters:</p>
467
+ <ul class="param">
468
+
469
+ <li>
470
+
471
+ <span class='name'>json_or_hash</span>
472
+
473
+
474
+ <span class='type'>(<tt>String</tt>, <tt>Hash</tt>)</span>
475
+
476
+
477
+
478
+ &mdash;
479
+ <div class='inline'>
480
+ <p>can be a hash of attributes, or a JSON string which represents such a structure.</p>
481
+ </div>
482
+
483
+ </li>
484
+
485
+ </ul>
486
+
487
+
488
+ </div><table class="source_code">
489
+ <tr>
490
+ <td>
491
+ <pre class="lines">
492
+
493
+
494
+ 32
495
+ 33
496
+ 34
497
+ 35
498
+ 36
499
+ 37
500
+ 38
501
+ 39
502
+ 40
503
+ 41</pre>
504
+ </td>
505
+ <td>
506
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 32</span>
507
+
508
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_json_or_hash'>json_or_hash</span><span class='rparen'>)</span>
509
+ <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_json_or_hash'>json_or_hash</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_json_or_hash'>json_or_hash</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_json_or_hash'>json_or_hash</span>
510
+
511
+ <span class='ivar'>@as_json</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
512
+ <span class='ivar'>@height</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>height</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
513
+ <span class='ivar'>@width</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>width</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
514
+ <span class='ivar'>@snakes</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>snakes</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_attrs'>attrs</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="Snake.html" title="Battlesnake::Snake (class)">Snake</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Snake.html#initialize-instance_method" title="Battlesnake::Snake#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
515
+ <span class='ivar'>@food</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>food</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_attrs'>attrs</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Location.html#initialize-instance_method" title="Battlesnake::Location#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
516
+ <span class='ivar'>@hazards</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>hazards</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_attrs'>attrs</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Location.html#initialize-instance_method" title="Battlesnake::Location#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
517
+ <span class='kw'>end</span></pre>
518
+ </td>
519
+ </tr>
520
+ </table>
521
+ </div>
522
+
523
+ </div>
524
+
525
+ <div id="instance_attr_details" class="attr_details">
526
+ <h2>Instance Attribute Details</h2>
527
+
528
+
529
+ <span id=""></span>
530
+ <div class="method_details first">
531
+ <h3 class="signature first" id="as_json-instance_method">
532
+
533
+ #<strong>as_json</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
534
+
535
+
536
+
537
+
538
+
539
+ </h3><div class="docstring">
540
+ <div class="discussion">
541
+
542
+ <p>Returns board as a data structure usable by other objects.</p>
543
+
544
+
545
+ </div>
546
+ </div>
547
+ <div class="tags">
548
+
549
+ <p class="tag_title">Returns:</p>
550
+ <ul class="return">
551
+
552
+ <li>
553
+
554
+
555
+ <span class='type'>(<tt>Hash</tt>)</span>
556
+
557
+
558
+
559
+ &mdash;
560
+ <div class='inline'>
561
+ <p>board as a data structure usable by other objects.</p>
562
+ </div>
563
+
564
+ </li>
565
+
566
+ </ul>
567
+
568
+ </div><table class="source_code">
569
+ <tr>
570
+ <td>
571
+ <pre class="lines">
572
+
573
+
574
+ 8
575
+ 9
576
+ 10</pre>
577
+ </td>
578
+ <td>
579
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 8</span>
580
+
581
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span>
582
+ <span class='ivar'>@as_json</span>
583
+ <span class='kw'>end</span></pre>
584
+ </td>
585
+ </tr>
586
+ </table>
587
+ </div>
588
+
589
+
590
+ <span id=""></span>
591
+ <div class="method_details ">
592
+ <h3 class="signature " id="food-instance_method">
593
+
594
+ #<strong>food</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt> <span class="extras">(readonly)</span>
595
+
596
+
597
+
598
+
599
+
600
+ </h3><div class="docstring">
601
+ <div class="discussion">
602
+
603
+ <p>Returns list of food location objects.</p>
604
+
605
+
606
+ </div>
607
+ </div>
608
+ <div class="tags">
609
+
610
+ <p class="tag_title">Returns:</p>
611
+ <ul class="return">
612
+
613
+ <li>
614
+
615
+
616
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt>)</span>
617
+
618
+
619
+
620
+ &mdash;
621
+ <div class='inline'>
622
+ <p>list of food location objects</p>
623
+ </div>
624
+
625
+ </li>
626
+
627
+ </ul>
628
+
629
+ </div><table class="source_code">
630
+ <tr>
631
+ <td>
632
+ <pre class="lines">
633
+
634
+
635
+ 20
636
+ 21
637
+ 22</pre>
638
+ </td>
639
+ <td>
640
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 20</span>
641
+
642
+ <span class='kw'>def</span> <span class='id identifier rubyid_food'>food</span>
643
+ <span class='ivar'>@food</span>
644
+ <span class='kw'>end</span></pre>
645
+ </td>
646
+ </tr>
647
+ </table>
648
+ </div>
649
+
650
+
651
+ <span id=""></span>
652
+ <div class="method_details ">
653
+ <h3 class="signature " id="hazards-instance_method">
654
+
655
+ #<strong>hazards</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt> <span class="extras">(readonly)</span>
656
+
657
+
658
+
659
+
660
+
661
+ </h3><div class="docstring">
662
+ <div class="discussion">
663
+
664
+ <p>Returns list of hazard location objects.</p>
665
+
666
+
667
+ </div>
668
+ </div>
669
+ <div class="tags">
670
+
671
+ <p class="tag_title">Returns:</p>
672
+ <ul class="return">
673
+
674
+ <li>
675
+
676
+
677
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt>)</span>
678
+
679
+
680
+
681
+ &mdash;
682
+ <div class='inline'>
683
+ <p>list of hazard location objects</p>
684
+ </div>
685
+
686
+ </li>
687
+
688
+ </ul>
689
+
690
+ </div><table class="source_code">
691
+ <tr>
692
+ <td>
693
+ <pre class="lines">
694
+
695
+
696
+ 23
697
+ 24
698
+ 25</pre>
699
+ </td>
700
+ <td>
701
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 23</span>
702
+
703
+ <span class='kw'>def</span> <span class='id identifier rubyid_hazards'>hazards</span>
704
+ <span class='ivar'>@hazards</span>
705
+ <span class='kw'>end</span></pre>
706
+ </td>
707
+ </tr>
708
+ </table>
709
+ </div>
710
+
711
+
712
+ <span id=""></span>
713
+ <div class="method_details ">
714
+ <h3 class="signature " id="height-instance_method">
715
+
716
+ #<strong>height</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
717
+
718
+
719
+
720
+
721
+
722
+ </h3><div class="docstring">
723
+ <div class="discussion">
724
+
725
+ <p>Returns height of the board.</p>
726
+
727
+
728
+ </div>
729
+ </div>
730
+ <div class="tags">
731
+
732
+ <p class="tag_title">Returns:</p>
733
+ <ul class="return">
734
+
735
+ <li>
736
+
737
+
738
+ <span class='type'>(<tt>Integer</tt>)</span>
739
+
740
+
741
+
742
+ &mdash;
743
+ <div class='inline'>
744
+ <p>height of the board</p>
745
+ </div>
746
+
747
+ </li>
748
+
749
+ </ul>
750
+
751
+ </div><table class="source_code">
752
+ <tr>
753
+ <td>
754
+ <pre class="lines">
755
+
756
+
757
+ 11
758
+ 12
759
+ 13</pre>
760
+ </td>
761
+ <td>
762
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 11</span>
763
+
764
+ <span class='kw'>def</span> <span class='id identifier rubyid_height'>height</span>
765
+ <span class='ivar'>@height</span>
766
+ <span class='kw'>end</span></pre>
767
+ </td>
768
+ </tr>
769
+ </table>
770
+ </div>
771
+
772
+
773
+ <span id=""></span>
774
+ <div class="method_details ">
775
+ <h3 class="signature " id="snakes-instance_method">
776
+
777
+ #<strong>snakes</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>&gt;</tt> <span class="extras">(readonly)</span>
778
+
779
+
780
+
781
+
782
+
783
+ </h3><div class="docstring">
784
+ <div class="discussion">
785
+
786
+ <p>Returns list of snake objects.</p>
787
+
788
+
789
+ </div>
790
+ </div>
791
+ <div class="tags">
792
+
793
+ <p class="tag_title">Returns:</p>
794
+ <ul class="return">
795
+
796
+ <li>
797
+
798
+
799
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Snake.html" title="Battlesnake::Snake (class)">Snake</a></span>&gt;</tt>)</span>
800
+
801
+
802
+
803
+ &mdash;
804
+ <div class='inline'>
805
+ <p>list of snake objects</p>
806
+ </div>
807
+
808
+ </li>
809
+
810
+ </ul>
811
+
812
+ </div><table class="source_code">
813
+ <tr>
814
+ <td>
815
+ <pre class="lines">
816
+
817
+
818
+ 17
819
+ 18
820
+ 19</pre>
821
+ </td>
822
+ <td>
823
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 17</span>
824
+
825
+ <span class='kw'>def</span> <span class='id identifier rubyid_snakes'>snakes</span>
826
+ <span class='ivar'>@snakes</span>
827
+ <span class='kw'>end</span></pre>
828
+ </td>
829
+ </tr>
830
+ </table>
831
+ </div>
832
+
833
+
834
+ <span id=""></span>
835
+ <div class="method_details ">
836
+ <h3 class="signature " id="width-instance_method">
837
+
838
+ #<strong>width</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
839
+
840
+
841
+
842
+
843
+
844
+ </h3><div class="docstring">
845
+ <div class="discussion">
846
+
847
+ <p>Returns width of the board.</p>
848
+
849
+
850
+ </div>
851
+ </div>
852
+ <div class="tags">
853
+
854
+ <p class="tag_title">Returns:</p>
855
+ <ul class="return">
856
+
857
+ <li>
858
+
859
+
860
+ <span class='type'>(<tt>Integer</tt>)</span>
861
+
862
+
863
+
864
+ &mdash;
865
+ <div class='inline'>
866
+ <p>width of the board</p>
867
+ </div>
868
+
869
+ </li>
870
+
871
+ </ul>
872
+
873
+ </div><table class="source_code">
874
+ <tr>
875
+ <td>
876
+ <pre class="lines">
877
+
878
+
879
+ 14
880
+ 15
881
+ 16</pre>
882
+ </td>
883
+ <td>
884
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 14</span>
885
+
886
+ <span class='kw'>def</span> <span class='id identifier rubyid_width'>width</span>
887
+ <span class='ivar'>@width</span>
888
+ <span class='kw'>end</span></pre>
889
+ </td>
890
+ </tr>
891
+ </table>
892
+ </div>
893
+
894
+ </div>
895
+
896
+
897
+ <div id="instance_method_details" class="method_details_list">
898
+ <h2>Instance Method Details</h2>
899
+
900
+
901
+ <div class="method_details first">
902
+ <h3 class="signature first" id="available?-instance_method">
903
+
904
+ #<strong>available?</strong>(*coordinates) &#x21d2; <tt>Boolean</tt>
905
+
906
+
907
+
908
+
909
+
910
+ </h3><div class="docstring">
911
+ <div class="discussion">
912
+
913
+ <p>Whether the supplied location is available (unoccupied).</p>
914
+
915
+
916
+ </div>
917
+ </div>
918
+ <div class="tags">
919
+ <p class="tag_title">Parameters:</p>
920
+ <ul class="param">
921
+
922
+ <li>
923
+
924
+ <span class='name'>*coordinates</span>
925
+
926
+
927
+ <span class='type'>(<tt><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></tt>, <tt>Hash</tt>, <tt>String</tt>, <tt>Array</tt>)</span>
928
+
929
+
930
+
931
+ &mdash;
932
+ <div class='inline'>
933
+ <p>can be specified as a <em>Location</em> object, hash containing x/y keys, JSON string of such a hash, or a pair of x,y coordinates expressed as a 2-element array or two separate parameters.</p>
934
+ </div>
935
+
936
+ </li>
937
+
938
+ </ul>
939
+
940
+ <p class="tag_title">Returns:</p>
941
+ <ul class="return">
942
+
943
+ <li>
944
+
945
+
946
+ <span class='type'>(<tt>Boolean</tt>)</span>
947
+
948
+
949
+
950
+ &mdash;
951
+ <div class='inline'>
952
+ <p>true if location is available (unoccupied by snakes, food, hazards, etc).</p>
953
+ </div>
954
+
955
+ </li>
956
+
957
+ </ul>
958
+
959
+ </div><table class="source_code">
960
+ <tr>
961
+ <td>
962
+ <pre class="lines">
963
+
964
+
965
+ 73
966
+ 74
967
+ 75</pre>
968
+ </td>
969
+ <td>
970
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 73</span>
971
+
972
+ <span class='kw'>def</span> <span class='id identifier rubyid_available?'>available?</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_coordinates'>coordinates</span><span class='rparen'>)</span>
973
+ <span class='op'>!</span><span class='id identifier rubyid_occupied?'>occupied?</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_coordinates'>coordinates</span><span class='rparen'>)</span>
974
+ <span class='kw'>end</span></pre>
975
+ </td>
976
+ </tr>
977
+ </table>
978
+ </div>
979
+
980
+ <div class="method_details ">
981
+ <h3 class="signature " id="available_directions-instance_method">
982
+
983
+ #<strong>available_directions</strong>(location) &#x21d2; <tt>Array&lt;String&gt;</tt>
984
+
985
+
986
+
987
+
988
+
989
+ </h3><div class="docstring">
990
+ <div class="discussion">
991
+
992
+ <p>List of directions (up, down, left, right) available for moving from given <em>Location</em>.</p>
993
+
994
+
995
+ </div>
996
+ </div>
997
+ <div class="tags">
998
+ <p class="tag_title">Parameters:</p>
999
+ <ul class="param">
1000
+
1001
+ <li>
1002
+
1003
+ <span class='name'>location</span>
1004
+
1005
+
1006
+ <span class='type'>(<tt><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></tt>)</span>
1007
+
1008
+
1009
+
1010
+ &mdash;
1011
+ <div class='inline'>
1012
+ <p>from which moving is desired.</p>
1013
+ </div>
1014
+
1015
+ </li>
1016
+
1017
+ </ul>
1018
+
1019
+ <p class="tag_title">Returns:</p>
1020
+ <ul class="return">
1021
+
1022
+ <li>
1023
+
1024
+
1025
+ <span class='type'>(<tt>Array&lt;String&gt;</tt>)</span>
1026
+
1027
+
1028
+
1029
+ &mdash;
1030
+ <div class='inline'>
1031
+ <p>list of direction strings (“up”, “down”, “left”, “right”)</p>
1032
+ </div>
1033
+
1034
+ </li>
1035
+
1036
+ </ul>
1037
+
1038
+ </div><table class="source_code">
1039
+ <tr>
1040
+ <td>
1041
+ <pre class="lines">
1042
+
1043
+
1044
+ 83
1045
+ 84
1046
+ 85
1047
+ 86
1048
+ 87</pre>
1049
+ </td>
1050
+ <td>
1051
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 83</span>
1052
+
1053
+ <span class='kw'>def</span> <span class='id identifier rubyid_available_directions'>available_directions</span><span class='lparen'>(</span><span class='id identifier rubyid_location'>location</span><span class='rparen'>)</span>
1054
+ <span class='const'><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Location.html#DIRECTIONS-constant" title="Battlesnake::Location::DIRECTIONS (constant)">DIRECTIONS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_direction'>direction</span><span class='op'>|</span>
1055
+ <span class='id identifier rubyid_available?'>available?</span><span class='lparen'>(</span><span class='id identifier rubyid_location'>location</span><span class='period'>.</span><span class='id identifier rubyid_move'>move</span><span class='lparen'>(</span><span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span><span class='rparen'>)</span>
1056
+ <span class='kw'>end</span>
1057
+ <span class='kw'>end</span></pre>
1058
+ </td>
1059
+ </tr>
1060
+ </table>
1061
+ </div>
1062
+
1063
+ <div class="method_details ">
1064
+ <h3 class="signature " id="occupied?-instance_method">
1065
+
1066
+ #<strong>occupied?</strong>(*coordinates) &#x21d2; <tt>Boolean</tt>
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+ </h3><div class="docstring">
1073
+ <div class="discussion">
1074
+
1075
+ <p>Whether the supplied location is occupied.</p>
1076
+
1077
+
1078
+ </div>
1079
+ </div>
1080
+ <div class="tags">
1081
+ <p class="tag_title">Parameters:</p>
1082
+ <ul class="param">
1083
+
1084
+ <li>
1085
+
1086
+ <span class='name'>*coordinates</span>
1087
+
1088
+
1089
+ <span class='type'>(<tt><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></tt>, <tt>Hash</tt>, <tt>String</tt>, <tt>Array</tt>)</span>
1090
+
1091
+
1092
+
1093
+ &mdash;
1094
+ <div class='inline'>
1095
+ <p>can be specified as a <em>Location</em> object, hash containing x/y keys, JSON string of such a hash, or a pair of x,y coordinates expressed as a 2-element array or two separate parameters.</p>
1096
+ </div>
1097
+
1098
+ </li>
1099
+
1100
+ </ul>
1101
+
1102
+ <p class="tag_title">Returns:</p>
1103
+ <ul class="return">
1104
+
1105
+ <li>
1106
+
1107
+
1108
+ <span class='type'>(<tt>Boolean</tt>)</span>
1109
+
1110
+
1111
+
1112
+ &mdash;
1113
+ <div class='inline'>
1114
+ <p>true if location is occupied by snakes, food, hazards, etc.</p>
1115
+ </div>
1116
+
1117
+ </li>
1118
+
1119
+ </ul>
1120
+
1121
+ </div><table class="source_code">
1122
+ <tr>
1123
+ <td>
1124
+ <pre class="lines">
1125
+
1126
+
1127
+ 60
1128
+ 61
1129
+ 62
1130
+ 63</pre>
1131
+ </td>
1132
+ <td>
1133
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 60</span>
1134
+
1135
+ <span class='kw'>def</span> <span class='id identifier rubyid_occupied?'>occupied?</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_coordinates'>coordinates</span><span class='rparen'>)</span>
1136
+ <span class='id identifier rubyid_location'>location</span> <span class='op'>=</span> <span class='id identifier rubyid_coordinates'>coordinates</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_coordinates'>coordinates</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='op'>:</span> <span class='const'><span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Location.html#initialize-instance_method" title="Battlesnake::Location#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_coordinates'>coordinates</span><span class='rparen'>)</span>
1137
+ <span class='id identifier rubyid_occupied_locations'>occupied_locations</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_location'>location</span><span class='rparen'>)</span>
1138
+ <span class='kw'>end</span></pre>
1139
+ </td>
1140
+ </tr>
1141
+ </table>
1142
+ </div>
1143
+
1144
+ <div class="method_details ">
1145
+ <h3 class="signature " id="occupied_locations-instance_method">
1146
+
1147
+ #<strong>occupied_locations</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt>
1148
+
1149
+
1150
+
1151
+
1152
+
1153
+ </h3><div class="docstring">
1154
+ <div class="discussion">
1155
+
1156
+ <p>List of all occupied locations on the board; snakes, food, hazards, etc</p>
1157
+
1158
+
1159
+ </div>
1160
+ </div>
1161
+ <div class="tags">
1162
+
1163
+ <p class="tag_title">Returns:</p>
1164
+ <ul class="return">
1165
+
1166
+ <li>
1167
+
1168
+
1169
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Location.html" title="Battlesnake::Location (class)">Location</a></span>&gt;</tt>)</span>
1170
+
1171
+
1172
+
1173
+ &mdash;
1174
+ <div class='inline'>
1175
+ <p>list of occupied locations</p>
1176
+ </div>
1177
+
1178
+ </li>
1179
+
1180
+ </ul>
1181
+
1182
+ </div><table class="source_code">
1183
+ <tr>
1184
+ <td>
1185
+ <pre class="lines">
1186
+
1187
+
1188
+ 47
1189
+ 48
1190
+ 49
1191
+ 50</pre>
1192
+ </td>
1193
+ <td>
1194
+ <pre class="code"><span class="info file"># File 'lib/battlesnake/board.rb', line 47</span>
1195
+
1196
+ <span class='kw'>def</span> <span class='id identifier rubyid_occupied_locations'>occupied_locations</span>
1197
+ <span class='kw'>return</span> <span class='ivar'>@occupied_locations</span> <span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='ivar'>@occupied_locations</span><span class='rparen'>)</span>
1198
+ <span class='ivar'>@occupied_locations</span> <span class='op'>=</span> <span class='id identifier rubyid_snakes'>snakes</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:body</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span> <span class='op'>+</span> <span class='id identifier rubyid_food'>food</span> <span class='op'>+</span> <span class='id identifier rubyid_hazards'>hazards</span>
1199
+ <span class='kw'>end</span></pre>
1200
+ </td>
1201
+ </tr>
1202
+ </table>
1203
+ </div>
1204
+
1205
+ </div>
1206
+
1207
+ </div>
1208
+
1209
+ <div id="footer">
1210
+ Generated on Sat Nov 5 20:09:02 2022 by
1211
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1212
+ 0.9.28 (ruby-2.7.2).
1213
+ </div>
1214
+
1215
+ </div>
1216
+ </body>
1217
+ </html>