the-swarm 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.yardopts +8 -0
  4. data/Gemfile +24 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +35 -0
  7. data/Rakefile +26 -0
  8. data/bin/swarm +11 -0
  9. data/docs/Swarm.html +296 -0
  10. data/docs/Swarm/Catalog.html +819 -0
  11. data/docs/Swarm/Console.html +1050 -0
  12. data/docs/Swarm/Console/Color.html +160 -0
  13. data/docs/Swarm/Console/NormalKey.html +410 -0
  14. data/docs/Swarm/Console/PopUp.html +236 -0
  15. data/docs/Swarm/Console/VIKey.html +410 -0
  16. data/docs/Swarm/Five.html +421 -0
  17. data/docs/Swarm/Four.html +389 -0
  18. data/docs/Swarm/Game.html +1197 -0
  19. data/docs/Swarm/Intro.html +419 -0
  20. data/docs/Swarm/Level.html +700 -0
  21. data/docs/Swarm/Map.html +2336 -0
  22. data/docs/Swarm/One.html +353 -0
  23. data/docs/Swarm/Three.html +383 -0
  24. data/docs/Swarm/Tile.html +3823 -0
  25. data/docs/Swarm/Two.html +355 -0
  26. data/docs/_index.html +313 -0
  27. data/docs/class_list.html +51 -0
  28. data/docs/css/common.css +1 -0
  29. data/docs/css/full_list.css +58 -0
  30. data/docs/css/style.css +492 -0
  31. data/docs/file.LICENSE.html +70 -0
  32. data/docs/file.README.html +101 -0
  33. data/docs/file_list.html +61 -0
  34. data/docs/frames.html +17 -0
  35. data/docs/index.html +101 -0
  36. data/docs/js/app.js +248 -0
  37. data/docs/js/full_list.js +216 -0
  38. data/docs/js/jquery.js +4 -0
  39. data/docs/method_list.html +1195 -0
  40. data/docs/top-level-namespace.html +110 -0
  41. data/lib/swarm.rb +60 -0
  42. data/lib/swarm/catalog.rb +71 -0
  43. data/lib/swarm/console.rb +165 -0
  44. data/lib/swarm/game.rb +173 -0
  45. data/lib/swarm/level.rb +58 -0
  46. data/lib/swarm/levels/five.rb +71 -0
  47. data/lib/swarm/levels/four.rb +55 -0
  48. data/lib/swarm/levels/intro.rb +36 -0
  49. data/lib/swarm/levels/one.rb +35 -0
  50. data/lib/swarm/levels/three.rb +51 -0
  51. data/lib/swarm/levels/two.rb +38 -0
  52. data/lib/swarm/map.rb +254 -0
  53. data/lib/swarm/tile.rb +149 -0
  54. data/lib/swarm/version.rb +5 -0
  55. data/swarm.gemspec +24 -0
  56. metadata +112 -0
@@ -0,0 +1,2336 @@
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: Swarm::Map
8
+
9
+ &mdash; &quot;Swarm&quot; Source Code Documentation
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "Swarm::Map";
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 (M)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Swarm.html" title="Swarm (module)">Swarm</a></span></span>
41
+ &raquo;
42
+ <span class="title">Map</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: Swarm::Map
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Swarm::Map</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <dl>
91
+ <dt>Includes:</dt>
92
+ <dd>Enumerable</dd>
93
+ </dl>
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <dl>
101
+ <dt>Defined in:</dt>
102
+ <dd>lib/swarm/map.rb</dd>
103
+ </dl>
104
+
105
+ </div>
106
+
107
+ <h2>Overview</h2><div class="docstring">
108
+ <div class="discussion">
109
+
110
+
111
+ </div>
112
+ </div>
113
+ <div class="tags">
114
+
115
+ <div class="examples">
116
+ <p class="tag_title">Examples:</p>
117
+
118
+
119
+ <p class="example_title"><div class='inline'>
120
+ <p>The <code>Map</code> Layout</p>
121
+ </div></p>
122
+
123
+ <pre class="example code"><code>+-------------------------------------------+
124
+ | |
125
+ | [0,0] [1,0] [2,0] [3,0] [4,0] [5,0] [6,0] |
126
+ | |
127
+ | [0,1] [1,1] [2,1] [3,1] [4,1] [5,1] [6,1] |
128
+ | |
129
+ | [0,2] [1,2] [2,2] [3,2] [4,2] [5,2] [6,2] |
130
+ | |
131
+ | [0,3] [1,3] [2,3] [3,3] [4,3] [5,3] [6,3] |
132
+ | |
133
+ | [0,4] [1,4] [2,4] [3,4] [4,4] [5,4] [6,4] |
134
+ | |
135
+ | [0,5] [1,5] [2,5] [3,5] [4,5] [5,5] [6,5] |
136
+ | |
137
+ | [0,6] [1,6] [2,6] [3,6] [4,6] [5,6] [6,6] |
138
+ | |
139
+ +-------------------------------------------+</code></pre>
140
+
141
+ </div>
142
+
143
+
144
+ </div>
145
+
146
+
147
+
148
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
149
+ <ul class="summary">
150
+
151
+ <li class="public ">
152
+ <span class="summary_signature">
153
+
154
+ <a href="#height-instance_method" title="#height (instance method)">#<strong>height</strong> &#x21d2; Integer </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>The <code>height</code> of the <code>Map</code>.</p>
175
+ </div></span>
176
+
177
+ </li>
178
+
179
+
180
+ <li class="public ">
181
+ <span class="summary_signature">
182
+
183
+ <a href="#width-instance_method" title="#width (instance method)">#<strong>width</strong> &#x21d2; Integer </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>The <code>width</code> of the <code>Map</code>.</p>
204
+ </div></span>
205
+
206
+ </li>
207
+
208
+
209
+ </ul>
210
+
211
+
212
+
213
+
214
+
215
+ <h2>
216
+ Instance Method Summary
217
+ <small><a href="#" class="summary_toggle">collapse</a></small>
218
+ </h2>
219
+
220
+ <ul class="summary">
221
+
222
+ <li class="public ">
223
+ <span class="summary_signature">
224
+
225
+ <a href="#[]-instance_method" title="#[] (instance method)">#<strong>[]</strong>(x, y) &#x21d2; Tile </a>
226
+
227
+
228
+
229
+ </span>
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+ <span class="summary_desc"><div class='inline'></div></span>
240
+
241
+ </li>
242
+
243
+
244
+ <li class="public ">
245
+ <span class="summary_signature">
246
+
247
+ <a href="#[]=-instance_method" title="#[]= (instance method)">#<strong>[]=</strong>(x, y, tile) &#x21d2; Tile </a>
248
+
249
+
250
+
251
+ </span>
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ <span class="summary_desc"><div class='inline'></div></span>
262
+
263
+ </li>
264
+
265
+
266
+ <li class="public ">
267
+ <span class="summary_signature">
268
+
269
+ <a href="#aggressive_moves-instance_method" title="#aggressive_moves (instance method)">#<strong>aggressive_moves</strong>(this, that) &#x21d2; Array&lt;Symbol, ...&gt; </a>
270
+
271
+
272
+
273
+ </span>
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+ <span class="summary_desc"><div class='inline'>
284
+ <p>Find the closest route from <code>this</code> to <code>that</code> based
285
+ only on position (ignoring all obstacles between <code>this</code> and
286
+ <code>that</code>).</p>
287
+ </div></span>
288
+
289
+ </li>
290
+
291
+
292
+ <li class="public ">
293
+ <span class="summary_signature">
294
+
295
+ <a href="#available_moves-instance_method" title="#available_moves (instance method)">#<strong>available_moves</strong>(tile) &#x21d2; Array&lt;Symbol, ...&gt; </a>
296
+
297
+
298
+
299
+ </span>
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+ <span class="summary_desc"><div class='inline'>
310
+ <p>Find “open” (non-blocking) moves for a <code>worker</code> or
311
+ <code>soldier</code>.</p>
312
+ </div></span>
313
+
314
+ </li>
315
+
316
+
317
+ <li class="public ">
318
+ <span class="summary_signature">
319
+
320
+ <a href="#center-instance_method" title="#center (instance method)">#<strong>center</strong> &#x21d2; Tile </a>
321
+
322
+
323
+
324
+ </span>
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+ <span class="summary_desc"><div class='inline'>
335
+ <p>A center tile.</p>
336
+ </div></span>
337
+
338
+ </li>
339
+
340
+
341
+ <li class="public ">
342
+ <span class="summary_signature">
343
+
344
+ <a href="#column-instance_method" title="#column (instance method)">#<strong>column</strong>(tile) &#x21d2; Array&lt;Tile, ...&gt; </a>
345
+
346
+
347
+
348
+ </span>
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+ <span class="summary_desc"><div class='inline'>
359
+ <p>The column of tiles that the <code>tile</code> resides on.</p>
360
+ </div></span>
361
+
362
+ </li>
363
+
364
+
365
+ <li class="public ">
366
+ <span class="summary_signature">
367
+
368
+ <a href="#each-instance_method" title="#each (instance method)">#<strong>each</strong>(&amp;block) &#x21d2; Object </a>
369
+
370
+
371
+
372
+ </span>
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+ <span class="summary_desc"><div class='inline'></div></span>
383
+
384
+ </li>
385
+
386
+
387
+ <li class="public ">
388
+ <span class="summary_signature">
389
+
390
+ <a href="#east-instance_method" title="#east (instance method)">#<strong>east</strong>(tile) &#x21d2; Array&lt;Tile, ...&gt; </a>
391
+
392
+
393
+
394
+ </span>
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+ <span class="summary_desc"><div class='inline'>
405
+ <p><code>column</code> or <code>row</code> of tiles starting with
406
+ <code>tile</code> headed east until the end of the map.</p>
407
+ </div></span>
408
+
409
+ </li>
410
+
411
+
412
+ <li class="public ">
413
+ <span class="summary_signature">
414
+
415
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(width, height, tile_width: 1, tile_height: 1) &#x21d2; Map </a>
416
+
417
+
418
+
419
+ </span>
420
+
421
+
422
+ <span class="note title constructor">constructor</span>
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+ <span class="summary_desc"><div class='inline'>
432
+ <p>A 2 dimensional array of tiles.</p>
433
+ </div></span>
434
+
435
+ </li>
436
+
437
+
438
+ <li class="public ">
439
+ <span class="summary_signature">
440
+
441
+ <a href="#last-instance_method" title="#last (instance method)">#<strong>last</strong> &#x21d2; Tile </a>
442
+
443
+
444
+
445
+ </span>
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+ <span class="summary_desc"><div class='inline'>
456
+ <p>The last tile (highest <code>x</code> and <code>y</code> value).</p>
457
+ </div></span>
458
+
459
+ </li>
460
+
461
+
462
+ <li class="public ">
463
+ <span class="summary_signature">
464
+
465
+ <a href="#move-instance_method" title="#move (instance method)">#<strong>move</strong>(tile, direction) &#x21d2; Boolean </a>
466
+
467
+
468
+
469
+ </span>
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+ <span class="summary_desc"><div class='inline'>
480
+ <p>Move a <code>Tile</code> on the <code>Map</code>.</p>
481
+ </div></span>
482
+
483
+ </li>
484
+
485
+
486
+ <li class="public ">
487
+ <span class="summary_signature">
488
+
489
+ <a href="#neighbors-instance_method" title="#neighbors (instance method)">#<strong>neighbors</strong>(tile) &#x21d2; Object </a>
490
+
491
+
492
+
493
+ </span>
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+ <span class="summary_desc"><div class='inline'></div></span>
504
+
505
+ </li>
506
+
507
+
508
+ <li class="public ">
509
+ <span class="summary_signature">
510
+
511
+ <a href="#north-instance_method" title="#north (instance method)">#<strong>north</strong>(tile) &#x21d2; Array&lt;Tile, ...&gt; </a>
512
+
513
+
514
+
515
+ </span>
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+ <span class="summary_desc"><div class='inline'>
526
+ <p><code>column</code> or <code>row</code> of tiles starting with
527
+ <code>tile</code> headed north until the end of the map.</p>
528
+ </div></span>
529
+
530
+ </li>
531
+
532
+
533
+ <li class="public ">
534
+ <span class="summary_signature">
535
+
536
+ <a href="#row-instance_method" title="#row (instance method)">#<strong>row</strong>(tile) &#x21d2; Array&lt;Tile, ...&gt; </a>
537
+
538
+
539
+
540
+ </span>
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+ <span class="summary_desc"><div class='inline'>
551
+ <p>The row of tiles that the <code>tile</code> resides on.</p>
552
+ </div></span>
553
+
554
+ </li>
555
+
556
+
557
+ <li class="public ">
558
+ <span class="summary_signature">
559
+
560
+ <a href="#sample-instance_method" title="#sample (instance method)">#<strong>sample</strong> &#x21d2; Tile </a>
561
+
562
+
563
+
564
+ </span>
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+ <span class="summary_desc"><div class='inline'>
575
+ <p>A random tile.</p>
576
+ </div></span>
577
+
578
+ </li>
579
+
580
+
581
+ <li class="public ">
582
+ <span class="summary_signature">
583
+
584
+ <a href="#score-instance_method" title="#score (instance method)">#<strong>score</strong>(key) &#x21d2; Object </a>
585
+
586
+
587
+
588
+ </span>
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+ <span class="summary_desc"><div class='inline'></div></span>
599
+
600
+ </li>
601
+
602
+
603
+ <li class="public ">
604
+ <span class="summary_signature">
605
+
606
+ <a href="#south-instance_method" title="#south (instance method)">#<strong>south</strong>(tile) &#x21d2; Array&lt;Tile, ...&gt; </a>
607
+
608
+
609
+
610
+ </span>
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+ <span class="summary_desc"><div class='inline'>
621
+ <p><code>column</code> or <code>row</code> of tiles starting with
622
+ <code>tile</code> headed south until the end of the map.</p>
623
+ </div></span>
624
+
625
+ </li>
626
+
627
+
628
+ <li class="public ">
629
+ <span class="summary_signature">
630
+
631
+ <a href="#spawn-instance_method" title="#spawn (instance method)">#<strong>spawn</strong>(flag, percent = 0.0) &#x21d2; Object </a>
632
+
633
+
634
+
635
+ </span>
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+ <span class="summary_desc"><div class='inline'></div></span>
646
+
647
+ </li>
648
+
649
+
650
+ <li class="public ">
651
+ <span class="summary_signature">
652
+
653
+ <a href="#update-instance_method" title="#update (instance method)">#<strong>update</strong> &#x21d2; Object </a>
654
+
655
+
656
+
657
+ </span>
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+ <span class="summary_desc"><div class='inline'></div></span>
668
+
669
+ </li>
670
+
671
+
672
+ <li class="public ">
673
+ <span class="summary_signature">
674
+
675
+ <a href="#west-instance_method" title="#west (instance method)">#<strong>west</strong>(tile) &#x21d2; Array&lt;Tile, ...&gt; </a>
676
+
677
+
678
+
679
+ </span>
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+ <span class="summary_desc"><div class='inline'>
690
+ <p><code>column</code> or <code>row</code> of tiles starting with
691
+ <code>tile</code> headed west until the end of the map.</p>
692
+ </div></span>
693
+
694
+ </li>
695
+
696
+
697
+ </ul>
698
+
699
+
700
+
701
+ <div id="constructor_details" class="method_details_list">
702
+ <h2>Constructor Details</h2>
703
+
704
+ <div class="method_details first">
705
+ <h3 class="signature first" id="initialize-instance_method">
706
+
707
+ #<strong>initialize</strong>(width, height, tile_width: 1, tile_height: 1) &#x21d2; <tt><span class='object_link'><a href="" title="Swarm::Map (class)">Map</a></span></tt>
708
+
709
+
710
+
711
+
712
+
713
+ </h3><div class="docstring">
714
+ <div class="discussion">
715
+
716
+ <p>A 2 dimensional array of tiles.</p>
717
+
718
+
719
+ </div>
720
+ </div>
721
+ <div class="tags">
722
+
723
+
724
+ </div><table class="source_code">
725
+ <tr>
726
+ <td>
727
+ <pre class="lines">
728
+
729
+
730
+ 33
731
+ 34
732
+ 35
733
+ 36
734
+ 37
735
+ 38
736
+ 39
737
+ 40
738
+ 41
739
+ 42
740
+ 43
741
+ 44</pre>
742
+ </td>
743
+ <td>
744
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 33</span>
745
+
746
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span><span class='comma'>,</span> <span class='label'>tile_width:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>tile_height:</span> <span class='int'>1</span><span class='rparen'>)</span>
747
+ <span class='ivar'>@tiles</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='int'>0</span><span class='op'>...</span><span class='id identifier rubyid_height'>height</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span><span class='lparen'>(</span><span class='id identifier rubyid_tile_height'>tile_height</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='period'>.</span><span class='id identifier rubyid_with_index'>with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_console_y'>console_y</span><span class='comma'>,</span> <span class='id identifier rubyid_map_y'>map_y</span><span class='op'>|</span>
748
+ <span class='lparen'>(</span><span class='int'>0</span><span class='op'>...</span><span class='id identifier rubyid_width'>width</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span><span class='lparen'>(</span><span class='id identifier rubyid_tile_width'>tile_width</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='period'>.</span><span class='id identifier rubyid_with_index'>with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_console_x'>console_x</span><span class='comma'>,</span> <span class='id identifier rubyid_map_x'>map_x</span><span class='op'>|</span>
749
+ <span class='const'><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Tile.html#initialize-instance_method" title="Swarm::Tile#initialize (method)">new</a></span></span> <span class='id identifier rubyid_map_x'>map_x</span><span class='comma'>,</span>
750
+ <span class='id identifier rubyid_map_y'>map_y</span><span class='comma'>,</span>
751
+ <span class='lbracket'>[</span><span class='id identifier rubyid_console_y'>console_y</span><span class='comma'>,</span> <span class='id identifier rubyid_console_x'>console_x</span><span class='rbracket'>]</span> <span class='comment'># reversed for Console::setpos
752
+ </span> <span class='kw'>end</span>
753
+ <span class='kw'>end</span>
754
+
755
+ <span class='ivar'>@height</span> <span class='op'>=</span> <span class='id identifier rubyid_height'>height</span> <span class='op'>/</span> <span class='id identifier rubyid_tile_height'>tile_height</span>
756
+ <span class='ivar'>@width</span> <span class='op'>=</span> <span class='id identifier rubyid_width'>width</span> <span class='op'>/</span> <span class='id identifier rubyid_tile_width'>tile_width</span>
757
+ <span class='kw'>end</span></pre>
758
+ </td>
759
+ </tr>
760
+ </table>
761
+ </div>
762
+
763
+ </div>
764
+
765
+ <div id="instance_attr_details" class="attr_details">
766
+ <h2>Instance Attribute Details</h2>
767
+
768
+
769
+ <span id=""></span>
770
+ <div class="method_details first">
771
+ <h3 class="signature first" id="height-instance_method">
772
+
773
+ #<strong>height</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
774
+
775
+
776
+
777
+
778
+
779
+ </h3><div class="docstring">
780
+ <div class="discussion">
781
+
782
+ <p>Returns the <code>height</code> of the <code>Map</code>.</p>
783
+
784
+
785
+ </div>
786
+ </div>
787
+ <div class="tags">
788
+
789
+ <p class="tag_title">Returns:</p>
790
+ <ul class="return">
791
+
792
+ <li>
793
+
794
+
795
+ <span class='type'>(<tt>Integer</tt>)</span>
796
+
797
+
798
+
799
+ &mdash;
800
+ <div class='inline'>
801
+ <p>the <code>height</code> of the <code>Map</code>.</p>
802
+ </div>
803
+
804
+ </li>
805
+
806
+ </ul>
807
+
808
+ </div><table class="source_code">
809
+ <tr>
810
+ <td>
811
+ <pre class="lines">
812
+
813
+
814
+ 30
815
+ 31
816
+ 32</pre>
817
+ </td>
818
+ <td>
819
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 30</span>
820
+
821
+ <span class='kw'>def</span> <span class='id identifier rubyid_height'>height</span>
822
+ <span class='ivar'>@height</span>
823
+ <span class='kw'>end</span></pre>
824
+ </td>
825
+ </tr>
826
+ </table>
827
+ </div>
828
+
829
+
830
+ <span id=""></span>
831
+ <div class="method_details ">
832
+ <h3 class="signature " id="width-instance_method">
833
+
834
+ #<strong>width</strong> &#x21d2; <tt>Integer</tt> <span class="extras">(readonly)</span>
835
+
836
+
837
+
838
+
839
+
840
+ </h3><div class="docstring">
841
+ <div class="discussion">
842
+
843
+ <p>Returns the <code>width</code> of the <code>Map</code>.</p>
844
+
845
+
846
+ </div>
847
+ </div>
848
+ <div class="tags">
849
+
850
+ <p class="tag_title">Returns:</p>
851
+ <ul class="return">
852
+
853
+ <li>
854
+
855
+
856
+ <span class='type'>(<tt>Integer</tt>)</span>
857
+
858
+
859
+
860
+ &mdash;
861
+ <div class='inline'>
862
+ <p>the <code>width</code> of the <code>Map</code>.</p>
863
+ </div>
864
+
865
+ </li>
866
+
867
+ </ul>
868
+
869
+ </div><table class="source_code">
870
+ <tr>
871
+ <td>
872
+ <pre class="lines">
873
+
874
+
875
+ 27
876
+ 28
877
+ 29</pre>
878
+ </td>
879
+ <td>
880
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 27</span>
881
+
882
+ <span class='kw'>def</span> <span class='id identifier rubyid_width'>width</span>
883
+ <span class='ivar'>@width</span>
884
+ <span class='kw'>end</span></pre>
885
+ </td>
886
+ </tr>
887
+ </table>
888
+ </div>
889
+
890
+ </div>
891
+
892
+
893
+ <div id="instance_method_details" class="method_details_list">
894
+ <h2>Instance Method Details</h2>
895
+
896
+
897
+ <div class="method_details first">
898
+ <h3 class="signature first" id="[]-instance_method">
899
+
900
+ #<strong>[]</strong>(x, y) &#x21d2; <tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>
901
+
902
+
903
+
904
+
905
+
906
+ </h3><div class="docstring">
907
+ <div class="discussion">
908
+
909
+
910
+ </div>
911
+ </div>
912
+ <div class="tags">
913
+ <p class="tag_title">Parameters:</p>
914
+ <ul class="param">
915
+
916
+ <li>
917
+
918
+ <span class='name'>x</span>
919
+
920
+
921
+ <span class='type'>(<tt>Integer</tt>)</span>
922
+
923
+
924
+
925
+ </li>
926
+
927
+ <li>
928
+
929
+ <span class='name'>y</span>
930
+
931
+
932
+ <span class='type'>(<tt>Integer</tt>)</span>
933
+
934
+
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><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
947
+
948
+
949
+
950
+ </li>
951
+
952
+ </ul>
953
+
954
+ </div><table class="source_code">
955
+ <tr>
956
+ <td>
957
+ <pre class="lines">
958
+
959
+
960
+ 65
961
+ 66
962
+ 67</pre>
963
+ </td>
964
+ <td>
965
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 65</span>
966
+
967
+ <span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span>
968
+ <span class='ivar'>@tiles</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='id identifier rubyid_x'>x</span><span class='rbracket'>]</span>
969
+ <span class='kw'>end</span></pre>
970
+ </td>
971
+ </tr>
972
+ </table>
973
+ </div>
974
+
975
+ <div class="method_details ">
976
+ <h3 class="signature " id="[]=-instance_method">
977
+
978
+ #<strong>[]=</strong>(x, y, tile) &#x21d2; <tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>
979
+
980
+
981
+
982
+
983
+
984
+ </h3><div class="docstring">
985
+ <div class="discussion">
986
+
987
+
988
+ </div>
989
+ </div>
990
+ <div class="tags">
991
+ <p class="tag_title">Parameters:</p>
992
+ <ul class="param">
993
+
994
+ <li>
995
+
996
+ <span class='name'>x</span>
997
+
998
+
999
+ <span class='type'>(<tt>Integer</tt>)</span>
1000
+
1001
+
1002
+
1003
+ </li>
1004
+
1005
+ <li>
1006
+
1007
+ <span class='name'>y</span>
1008
+
1009
+
1010
+ <span class='type'>(<tt>Integer</tt>)</span>
1011
+
1012
+
1013
+
1014
+ </li>
1015
+
1016
+ <li>
1017
+
1018
+ <span class='name'>tile</span>
1019
+
1020
+
1021
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1022
+
1023
+
1024
+
1025
+ </li>
1026
+
1027
+ </ul>
1028
+
1029
+ <p class="tag_title">Returns:</p>
1030
+ <ul class="return">
1031
+
1032
+ <li>
1033
+
1034
+
1035
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1036
+
1037
+
1038
+
1039
+ </li>
1040
+
1041
+ </ul>
1042
+
1043
+ </div><table class="source_code">
1044
+ <tr>
1045
+ <td>
1046
+ <pre class="lines">
1047
+
1048
+
1049
+ 73
1050
+ 74
1051
+ 75
1052
+ 76</pre>
1053
+ </td>
1054
+ <td>
1055
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 73</span>
1056
+
1057
+ <span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1058
+ <span class='ivar'>@tiles</span><span class='lbracket'>[</span><span class='id identifier rubyid_y'>y</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1059
+ <span class='ivar'>@tiles</span><span class='lbracket'>[</span><span class='id identifier rubyid_y'>y</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_x'>x</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_tile'>tile</span>
1060
+ <span class='kw'>end</span></pre>
1061
+ </td>
1062
+ </tr>
1063
+ </table>
1064
+ </div>
1065
+
1066
+ <div class="method_details ">
1067
+ <h3 class="signature " id="aggressive_moves-instance_method">
1068
+
1069
+ #<strong>aggressive_moves</strong>(this, that) &#x21d2; <tt>Array&lt;Symbol, ...&gt;</tt>
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+ </h3><div class="docstring">
1076
+ <div class="discussion">
1077
+
1078
+ <p>Find the closest route from <code>this</code> to <code>that</code> based
1079
+ only on position (ignoring all obstacles between <code>this</code> and
1080
+ <code>that</code>).</p>
1081
+
1082
+
1083
+ </div>
1084
+ </div>
1085
+ <div class="tags">
1086
+ <p class="tag_title">Parameters:</p>
1087
+ <ul class="param">
1088
+
1089
+ <li>
1090
+
1091
+ <span class='name'>this</span>
1092
+
1093
+
1094
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1095
+
1096
+
1097
+
1098
+ &mdash;
1099
+ <div class='inline'>
1100
+ <p>origin tile</p>
1101
+ </div>
1102
+
1103
+ </li>
1104
+
1105
+ <li>
1106
+
1107
+ <span class='name'>that</span>
1108
+
1109
+
1110
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1111
+
1112
+
1113
+
1114
+ &mdash;
1115
+ <div class='inline'>
1116
+ <p>destination tile</p>
1117
+ </div>
1118
+
1119
+ </li>
1120
+
1121
+ </ul>
1122
+
1123
+ <p class="tag_title">Returns:</p>
1124
+ <ul class="return">
1125
+
1126
+ <li>
1127
+
1128
+
1129
+ <span class='type'>(<tt>Array&lt;Symbol, ...&gt;</tt>)</span>
1130
+
1131
+
1132
+
1133
+ &mdash;
1134
+ <div class='inline'>
1135
+ <p><code>:north</code>, <code>:east</code>, <code>:west</code> and/or
1136
+ <code>:south</code></p>
1137
+ </div>
1138
+
1139
+ </li>
1140
+
1141
+ </ul>
1142
+
1143
+ </div><table class="source_code">
1144
+ <tr>
1145
+ <td>
1146
+ <pre class="lines">
1147
+
1148
+
1149
+ 162
1150
+ 163
1151
+ 164
1152
+ 165
1153
+ 166
1154
+ 167
1155
+ 168
1156
+ 169</pre>
1157
+ </td>
1158
+ <td>
1159
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 162</span>
1160
+
1161
+ <span class='kw'>def</span> <span class='id identifier rubyid_aggressive_moves'>aggressive_moves</span><span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='comma'>,</span> <span class='id identifier rubyid_that'>that</span><span class='rparen'>)</span>
1162
+ <span class='id identifier rubyid_directions'>directions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
1163
+ <span class='id identifier rubyid_directions'>directions</span> <span class='op'>&lt;&lt;</span> <span class='symbol'>:north</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span> <span class='op'>-</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span> <span class='op'>&lt;</span> <span class='int'>10</span><span class='rparen'>)</span>
1164
+ <span class='id identifier rubyid_directions'>directions</span> <span class='op'>&lt;&lt;</span> <span class='symbol'>:south</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span> <span class='op'>-</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span> <span class='op'>&lt;</span> <span class='int'>10</span><span class='rparen'>)</span>
1165
+ <span class='id identifier rubyid_directions'>directions</span> <span class='op'>&lt;&lt;</span> <span class='symbol'>:west</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span> <span class='op'>-</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='rparen'>)</span> <span class='op'>&lt;</span> <span class='int'>10</span><span class='rparen'>)</span>
1166
+ <span class='id identifier rubyid_directions'>directions</span> <span class='op'>&lt;&lt;</span> <span class='symbol'>:east</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span> <span class='op'>-</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='rparen'>)</span> <span class='op'>&lt;</span> <span class='int'>10</span><span class='rparen'>)</span>
1167
+ <span class='id identifier rubyid_directions'>directions</span>
1168
+ <span class='kw'>end</span></pre>
1169
+ </td>
1170
+ </tr>
1171
+ </table>
1172
+ </div>
1173
+
1174
+ <div class="method_details ">
1175
+ <h3 class="signature " id="available_moves-instance_method">
1176
+
1177
+ #<strong>available_moves</strong>(tile) &#x21d2; <tt>Array&lt;Symbol, ...&gt;</tt>
1178
+
1179
+
1180
+
1181
+
1182
+
1183
+ </h3><div class="docstring">
1184
+ <div class="discussion">
1185
+
1186
+ <p>Find “open” (non-blocking) moves for a <code>worker</code> or
1187
+ <code>soldier</code>.</p>
1188
+
1189
+
1190
+ </div>
1191
+ </div>
1192
+ <div class="tags">
1193
+ <p class="tag_title">Parameters:</p>
1194
+ <ul class="param">
1195
+
1196
+ <li>
1197
+
1198
+ <span class='name'>tile</span>
1199
+
1200
+
1201
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1202
+
1203
+
1204
+
1205
+ &mdash;
1206
+ <div class='inline'>
1207
+ <p>a <code>worker</code> or <code>soldier</code></p>
1208
+ </div>
1209
+
1210
+ </li>
1211
+
1212
+ </ul>
1213
+
1214
+ <p class="tag_title">Returns:</p>
1215
+ <ul class="return">
1216
+
1217
+ <li>
1218
+
1219
+
1220
+ <span class='type'>(<tt>Array&lt;Symbol, ...&gt;</tt>)</span>
1221
+
1222
+
1223
+
1224
+ &mdash;
1225
+ <div class='inline'>
1226
+ <p><code>:north</code>, <code>:east</code>, <code>:west</code> and/or
1227
+ <code>:south</code></p>
1228
+ </div>
1229
+
1230
+ </li>
1231
+
1232
+ </ul>
1233
+
1234
+ <p class="tag_title">See Also:</p>
1235
+ <ul class="see">
1236
+
1237
+ <li>Swarm::Map.{Map{Map#north}</li>
1238
+
1239
+ <li>Swarm::Map.{Map{Map#south}</li>
1240
+
1241
+ <li>Swarm::Map.{Map{Map#east}</li>
1242
+
1243
+ <li>Swarm::Map.{Map{Map#west}</li>
1244
+
1245
+ </ul>
1246
+
1247
+ </div><table class="source_code">
1248
+ <tr>
1249
+ <td>
1250
+ <pre class="lines">
1251
+
1252
+
1253
+ 180
1254
+ 181
1255
+ 182
1256
+ 183
1257
+ 184
1258
+ 185
1259
+ 186
1260
+ 187
1261
+ 188</pre>
1262
+ </td>
1263
+ <td>
1264
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 180</span>
1265
+
1266
+ <span class='kw'>def</span> <span class='id identifier rubyid_available_moves'>available_moves</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1267
+ <span class='qsymbols_beg'>%i(</span><span class='tstring_content'>north</span><span class='words_sep'> </span><span class='tstring_content'>south</span><span class='words_sep'> </span><span class='tstring_content'>east</span><span class='words_sep'> </span><span class='tstring_content'>west</span><span class='words_sep'>)</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>
1268
+ <span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_neighbor'>neighbor</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span> <span class='op'>=</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_direction'>direction</span><span class='comma'>,</span> <span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1269
+
1270
+ <span class='kw'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_neighbor'>neighbor</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
1271
+
1272
+ <span class='id identifier rubyid_neighbor'>neighbor</span><span class='period'>.</span><span class='id identifier rubyid_player?'>player?</span> <span class='op'>||</span> <span class='id identifier rubyid_neighbor'>neighbor</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_queen?'>queen?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_neighbor'>neighbor</span><span class='period'>.</span><span class='id identifier rubyid_dirt?'>dirt?</span><span class='rparen'>)</span>
1273
+ <span class='kw'>end</span>
1274
+ <span class='kw'>end</span></pre>
1275
+ </td>
1276
+ </tr>
1277
+ </table>
1278
+ </div>
1279
+
1280
+ <div class="method_details ">
1281
+ <h3 class="signature " id="center-instance_method">
1282
+
1283
+ #<strong>center</strong> &#x21d2; <tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>
1284
+
1285
+
1286
+
1287
+
1288
+
1289
+ </h3><div class="docstring">
1290
+ <div class="discussion">
1291
+
1292
+ <p>Returns a center tile</p>
1293
+
1294
+
1295
+ </div>
1296
+ </div>
1297
+ <div class="tags">
1298
+
1299
+ <p class="tag_title">Returns:</p>
1300
+ <ul class="return">
1301
+
1302
+ <li>
1303
+
1304
+
1305
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1306
+
1307
+
1308
+
1309
+ &mdash;
1310
+ <div class='inline'>
1311
+ <p>a center tile</p>
1312
+ </div>
1313
+
1314
+ </li>
1315
+
1316
+ </ul>
1317
+
1318
+ </div><table class="source_code">
1319
+ <tr>
1320
+ <td>
1321
+ <pre class="lines">
1322
+
1323
+
1324
+ 53
1325
+ 54
1326
+ 55</pre>
1327
+ </td>
1328
+ <td>
1329
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 53</span>
1330
+
1331
+ <span class='kw'>def</span> <span class='id identifier rubyid_center'>center</span>
1332
+ <span class='ivar'>@tiles</span><span class='lbracket'>[</span><span class='id identifier rubyid_height'>height</span> <span class='op'>/</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_width'>width</span> <span class='op'>/</span> <span class='int'>2</span><span class='rbracket'>]</span>
1333
+ <span class='kw'>end</span></pre>
1334
+ </td>
1335
+ </tr>
1336
+ </table>
1337
+ </div>
1338
+
1339
+ <div class="method_details ">
1340
+ <h3 class="signature " id="column-instance_method">
1341
+
1342
+ #<strong>column</strong>(tile) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>
1343
+
1344
+
1345
+
1346
+
1347
+
1348
+ </h3><div class="docstring">
1349
+ <div class="discussion">
1350
+
1351
+ <p>Returns the column of tiles that the <code>tile</code> resides on</p>
1352
+
1353
+
1354
+ </div>
1355
+ </div>
1356
+ <div class="tags">
1357
+ <p class="tag_title">Parameters:</p>
1358
+ <ul class="param">
1359
+
1360
+ <li>
1361
+
1362
+ <span class='name'>tile</span>
1363
+
1364
+
1365
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1366
+
1367
+
1368
+
1369
+ </li>
1370
+
1371
+ </ul>
1372
+
1373
+ <p class="tag_title">Returns:</p>
1374
+ <ul class="return">
1375
+
1376
+ <li>
1377
+
1378
+
1379
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>)</span>
1380
+
1381
+
1382
+
1383
+ &mdash;
1384
+ <div class='inline'>
1385
+ <p>the column of tiles that the <code>tile</code> resides on</p>
1386
+ </div>
1387
+
1388
+ </li>
1389
+
1390
+ </ul>
1391
+
1392
+ </div><table class="source_code">
1393
+ <tr>
1394
+ <td>
1395
+ <pre class="lines">
1396
+
1397
+
1398
+ 250
1399
+ 251
1400
+ 252</pre>
1401
+ </td>
1402
+ <td>
1403
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 250</span>
1404
+
1405
+ <span class='kw'>def</span> <span class='id identifier rubyid_column'>column</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1406
+ <span class='ivar'>@tiles</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_row'>row</span><span class='op'>|</span> <span class='id identifier rubyid_row'>row</span><span class='lbracket'>[</span><span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
1407
+ <span class='kw'>end</span></pre>
1408
+ </td>
1409
+ </tr>
1410
+ </table>
1411
+ </div>
1412
+
1413
+ <div class="method_details ">
1414
+ <h3 class="signature " id="each-instance_method">
1415
+
1416
+ #<strong>each</strong>(&amp;block) &#x21d2; <tt>Object</tt>
1417
+
1418
+
1419
+
1420
+
1421
+
1422
+ </h3><table class="source_code">
1423
+ <tr>
1424
+ <td>
1425
+ <pre class="lines">
1426
+
1427
+
1428
+ 48
1429
+ 49
1430
+ 50</pre>
1431
+ </td>
1432
+ <td>
1433
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 48</span>
1434
+
1435
+ <span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
1436
+ <span class='ivar'>@tiles</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='op'>|</span> <span class='id identifier rubyid_row'>row</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span> <span class='rbrace'>}</span>
1437
+ <span class='kw'>end</span></pre>
1438
+ </td>
1439
+ </tr>
1440
+ </table>
1441
+ </div>
1442
+
1443
+ <div class="method_details ">
1444
+ <h3 class="signature " id="east-instance_method">
1445
+
1446
+ #<strong>east</strong>(tile) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>
1447
+
1448
+
1449
+
1450
+
1451
+
1452
+ </h3><div class="docstring">
1453
+ <div class="discussion">
1454
+
1455
+ <p>Returns <code>column</code> or <code>row</code> of tiles starting with
1456
+ <code>tile</code> headed east until the end of the map</p>
1457
+
1458
+
1459
+ </div>
1460
+ </div>
1461
+ <div class="tags">
1462
+ <p class="tag_title">Parameters:</p>
1463
+ <ul class="param">
1464
+
1465
+ <li>
1466
+
1467
+ <span class='name'>tile</span>
1468
+
1469
+
1470
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1471
+
1472
+
1473
+
1474
+ </li>
1475
+
1476
+ </ul>
1477
+
1478
+ <p class="tag_title">Returns:</p>
1479
+ <ul class="return">
1480
+
1481
+ <li>
1482
+
1483
+
1484
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>)</span>
1485
+
1486
+
1487
+
1488
+ &mdash;
1489
+ <div class='inline'>
1490
+ <p><code>column</code> or <code>row</code> of tiles starting with
1491
+ <code>tile</code> headed east until the end of the map</p>
1492
+ </div>
1493
+
1494
+ </li>
1495
+
1496
+ </ul>
1497
+
1498
+ <p class="tag_title">See Also:</p>
1499
+ <ul class="see">
1500
+
1501
+ <li><span class='object_link'><a href="#column-instance_method" title="Swarm::Map#column (method)">#column</a></span></li>
1502
+
1503
+ <li><span class='object_link'><a href="#row-instance_method" title="Swarm::Map#row (method)">#row</a></span></li>
1504
+
1505
+ </ul>
1506
+
1507
+ </div><table class="source_code">
1508
+ <tr>
1509
+ <td>
1510
+ <pre class="lines">
1511
+
1512
+
1513
+ 229
1514
+ 230
1515
+ 231
1516
+ 232</pre>
1517
+ </td>
1518
+ <td>
1519
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 229</span>
1520
+
1521
+ <span class='kw'>def</span> <span class='id identifier rubyid_east'>east</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1522
+ <span class='id identifier rubyid_tiles'>tiles</span> <span class='op'>=</span> <span class='id identifier rubyid_row'>row</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1523
+ <span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_rotate'>rotate</span><span class='lparen'>(</span><span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span> <span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1524
+ <span class='kw'>end</span></pre>
1525
+ </td>
1526
+ </tr>
1527
+ </table>
1528
+ </div>
1529
+
1530
+ <div class="method_details ">
1531
+ <h3 class="signature " id="last-instance_method">
1532
+
1533
+ #<strong>last</strong> &#x21d2; <tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>
1534
+
1535
+
1536
+
1537
+
1538
+
1539
+ </h3><div class="docstring">
1540
+ <div class="discussion">
1541
+
1542
+ <p>Returns the last tile (highest <code>x</code> and <code>y</code> value)</p>
1543
+
1544
+
1545
+ </div>
1546
+ </div>
1547
+ <div class="tags">
1548
+
1549
+ <p class="tag_title">Returns:</p>
1550
+ <ul class="return">
1551
+
1552
+ <li>
1553
+
1554
+
1555
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1556
+
1557
+
1558
+
1559
+ &mdash;
1560
+ <div class='inline'>
1561
+ <p>the last tile (highest <code>x</code> and <code>y</code> value)</p>
1562
+ </div>
1563
+
1564
+ </li>
1565
+
1566
+ </ul>
1567
+
1568
+ </div><table class="source_code">
1569
+ <tr>
1570
+ <td>
1571
+ <pre class="lines">
1572
+
1573
+
1574
+ 79
1575
+ 80
1576
+ 81</pre>
1577
+ </td>
1578
+ <td>
1579
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 79</span>
1580
+
1581
+ <span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
1582
+ <span class='kw'>self</span><span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
1583
+ <span class='kw'>end</span></pre>
1584
+ </td>
1585
+ </tr>
1586
+ </table>
1587
+ </div>
1588
+
1589
+ <div class="method_details ">
1590
+ <h3 class="signature " id="move-instance_method">
1591
+
1592
+ #<strong>move</strong>(tile, direction) &#x21d2; <tt>Boolean</tt>
1593
+
1594
+
1595
+
1596
+
1597
+
1598
+ </h3><div class="docstring">
1599
+ <div class="discussion">
1600
+
1601
+ <p>Move a <code>Tile</code> on the <code>Map</code>. This movement action
1602
+ causes a chain reaction potentially moving (or killing) tiles down the map
1603
+ in that same direction.</p>
1604
+
1605
+ <p>It does this by comparing each neighboring pair</p>
1606
+
1607
+ <pre class="code ruby"><code class="ruby">tile_1 -&gt; tile_2
1608
+ tile_2 -&gt; tile_3
1609
+ tile_3 -&gt; tile_4</code></pre>
1610
+
1611
+ <p>And follows these rules</p>
1612
+ <ul><li>
1613
+ <p>empty tiles don&#39;t transfer movement</p>
1614
+ </li><li>
1615
+ <p>enemies block enemies</p>
1616
+ </li><li>
1617
+ <p>playeras are turned into eggs when touching enemies</p>
1618
+ </li><li>
1619
+ <p>enemies get squished by players</p>
1620
+ </li><li>
1621
+ <p>players get squished by soldiers</p>
1622
+ </li><li>
1623
+ <p>rocks block everything</p>
1624
+ </li></ul>
1625
+
1626
+
1627
+ </div>
1628
+ </div>
1629
+ <div class="tags">
1630
+ <p class="tag_title">Parameters:</p>
1631
+ <ul class="param">
1632
+
1633
+ <li>
1634
+
1635
+ <span class='name'>tile</span>
1636
+
1637
+
1638
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1639
+
1640
+
1641
+
1642
+ </li>
1643
+
1644
+ <li>
1645
+
1646
+ <span class='name'>direction</span>
1647
+
1648
+
1649
+ <span class='type'>(<tt>Symbol</tt>)</span>
1650
+
1651
+
1652
+
1653
+ &mdash;
1654
+ <div class='inline'>
1655
+ <p><code>:north</code>, <code>:south</code>, <code>:east</code> or
1656
+ <code>:west</code></p>
1657
+ </div>
1658
+
1659
+ </li>
1660
+
1661
+ </ul>
1662
+
1663
+ <p class="tag_title">Returns:</p>
1664
+ <ul class="return">
1665
+
1666
+ <li>
1667
+
1668
+
1669
+ <span class='type'>(<tt>Boolean</tt>)</span>
1670
+
1671
+
1672
+
1673
+ &mdash;
1674
+ <div class='inline'>
1675
+ <p><code>true</code> if the <code>tile</code> is moved successfully,
1676
+ <code>false</code> if it is not</p>
1677
+ </div>
1678
+
1679
+ </li>
1680
+
1681
+ </ul>
1682
+
1683
+ </div><table class="source_code">
1684
+ <tr>
1685
+ <td>
1686
+ <pre class="lines">
1687
+
1688
+
1689
+ 113
1690
+ 114
1691
+ 115
1692
+ 116
1693
+ 117
1694
+ 118
1695
+ 119
1696
+ 120
1697
+ 121
1698
+ 122
1699
+ 123
1700
+ 124
1701
+ 125
1702
+ 126
1703
+ 127
1704
+ 128
1705
+ 129
1706
+ 130
1707
+ 131
1708
+ 132
1709
+ 133
1710
+ 134
1711
+ 135
1712
+ 136
1713
+ 137
1714
+ 138
1715
+ 139
1716
+ 140
1717
+ 141
1718
+ 142
1719
+ 143
1720
+ 144
1721
+ 145
1722
+ 146
1723
+ 147
1724
+ 148
1725
+ 149
1726
+ 150
1727
+ 151
1728
+ 152
1729
+ 153
1730
+ 154</pre>
1731
+ </td>
1732
+ <td>
1733
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 113</span>
1734
+
1735
+ <span class='kw'>def</span> <span class='id identifier rubyid_move'>move</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1736
+ <span class='id identifier rubyid_tiles'>tiles</span> <span class='op'>=</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_direction'>direction</span><span class='comma'>,</span> <span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1737
+ <span class='id identifier rubyid_move'>move</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
1738
+
1739
+ <span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_each_cons'>each_cons</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_this'>this</span><span class='comma'>,</span> <span class='id identifier rubyid_that'>that</span><span class='op'>|</span>
1740
+ <span class='kw'>break</span> <span class='kw'>if</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1741
+ <span class='comment'># break move.clear if (tile == this) &amp;&amp; this.enemy? &amp;&amp; that.empty?
1742
+ </span> <span class='kw'>break</span> <span class='id identifier rubyid_move'>move</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> <span class='kw'>if</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_enemy?'>enemy?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_enemy?'>enemy?</span>
1743
+
1744
+ <span class='kw'>break</span> <span class='id identifier rubyid_move'>move</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> <span class='kw'>if</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_egg?'>egg?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_enemy?'>enemy?</span>
1745
+ <span class='kw'>break</span> <span class='id identifier rubyid_move'>move</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> <span class='kw'>if</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_enemy?'>enemy?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_egg?'>egg?</span>
1746
+
1747
+ <span class='kw'>break</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_destroy!'>destroy!</span> <span class='kw'>if</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_player?'>player?</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_enemy?'>enemy?</span> <span class='op'>||</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_egg?'>egg?</span><span class='rparen'>)</span>
1748
+ <span class='kw'>break</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_destroy!'>destroy!</span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_enemy?'>enemy?</span> <span class='op'>||</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_egg?'>egg?</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_player?'>player?</span>
1749
+
1750
+ <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_worker?'>worker?</span> <span class='op'>||</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_queen?'>queen?</span> <span class='op'>||</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_egg?'>egg?</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_player?'>player?</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_dirt?'>dirt?</span> <span class='op'>||</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_rock?'>rock?</span><span class='rparen'>)</span>
1751
+ <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_destroy!'>destroy!</span>
1752
+ <span class='kw'>break</span>
1753
+ <span class='kw'>end</span>
1754
+
1755
+ <span class='kw'>if</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_soldier?'>soldier?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_player?'>player?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_rock?'>rock?</span>
1756
+ <span class='lparen'>(</span><span class='id identifier rubyid_neighbors'>neighbors</span><span class='lparen'>(</span><span class='id identifier rubyid_this'>this</span><span class='rparen'>)</span> <span class='op'>-</span> <span class='id identifier rubyid_neighbors'>neighbors</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='op'>&amp;</span><span class='symbol'>:worker!</span>
1757
+
1758
+ <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_destroy!'>destroy!</span>
1759
+ <span class='kw'>break</span>
1760
+ <span class='kw'>end</span>
1761
+
1762
+ <span class='kw'>if</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_player?'>player?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_queen?'>queen?</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1763
+ <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_destroy!'>destroy!</span>
1764
+ <span class='kw'>break</span>
1765
+ <span class='kw'>end</span>
1766
+
1767
+ <span class='kw'>break</span> <span class='id identifier rubyid_move'>move</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> <span class='kw'>if</span> <span class='id identifier rubyid_that'>that</span><span class='period'>.</span><span class='id identifier rubyid_rock?'>rock?</span>
1768
+
1769
+ <span class='id identifier rubyid_move'>move</span> <span class='op'>&lt;&lt;</span> <span class='lbracket'>[</span><span class='id identifier rubyid_that'>that</span><span class='comma'>,</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_this'>this</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='rbracket'>]</span>
1770
+ <span class='kw'>end</span>
1771
+
1772
+ <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_move'>move</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1773
+
1774
+ <span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_empty!'>empty!</span>
1775
+ <span class='id identifier rubyid_move'>move</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_t'>t</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_age'>age</span><span class='op'>|</span> <span class='id identifier rubyid_t'>t</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_age'>age</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
1776
+ <span class='kw'>end</span></pre>
1777
+ </td>
1778
+ </tr>
1779
+ </table>
1780
+ </div>
1781
+
1782
+ <div class="method_details ">
1783
+ <h3 class="signature " id="neighbors-instance_method">
1784
+
1785
+ #<strong>neighbors</strong>(tile) &#x21d2; <tt>Object</tt>
1786
+
1787
+
1788
+
1789
+
1790
+
1791
+ </h3><table class="source_code">
1792
+ <tr>
1793
+ <td>
1794
+ <pre class="lines">
1795
+
1796
+
1797
+ 190
1798
+ 191
1799
+ 192
1800
+ 193
1801
+ 194
1802
+ 195
1803
+ 196
1804
+ 197
1805
+ 198
1806
+ 199
1807
+ 200
1808
+ 201
1809
+ 202
1810
+ 203
1811
+ 204</pre>
1812
+ </td>
1813
+ <td>
1814
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 190</span>
1815
+
1816
+ <span class='kw'>def</span> <span class='id identifier rubyid_neighbors'>neighbors</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1817
+ <span class='lbracket'>[</span>
1818
+ <span class='lbracket'>[</span> <span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span>
1819
+ <span class='lbracket'>[</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span>
1820
+ <span class='lbracket'>[</span> <span class='int'>0</span><span class='comma'>,</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span>
1821
+ <span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span>
1822
+ <span class='comment'># [ 0, 0], &lt;- self
1823
+ </span> <span class='lbracket'>[</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span>
1824
+ <span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span>
1825
+ <span class='lbracket'>[</span> <span class='int'>1</span><span class='comma'>,</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='comma'>,</span>
1826
+ <span class='lbracket'>[</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>1</span><span class='rbracket'>]</span>
1827
+ <span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='op'>|</span>
1828
+ <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span> <span class='op'>+</span> <span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span> <span class='op'>+</span> <span class='id identifier rubyid_y'>y</span><span class='rbracket'>]</span>
1829
+ <span class='kw'>end</span>
1830
+ <span class='kw'>end</span></pre>
1831
+ </td>
1832
+ </tr>
1833
+ </table>
1834
+ </div>
1835
+
1836
+ <div class="method_details ">
1837
+ <h3 class="signature " id="north-instance_method">
1838
+
1839
+ #<strong>north</strong>(tile) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>
1840
+
1841
+
1842
+
1843
+
1844
+
1845
+ </h3><div class="docstring">
1846
+ <div class="discussion">
1847
+
1848
+ <p>Returns <code>column</code> or <code>row</code> of tiles starting with
1849
+ <code>tile</code> headed north until the end of the map</p>
1850
+
1851
+
1852
+ </div>
1853
+ </div>
1854
+ <div class="tags">
1855
+ <p class="tag_title">Parameters:</p>
1856
+ <ul class="param">
1857
+
1858
+ <li>
1859
+
1860
+ <span class='name'>tile</span>
1861
+
1862
+
1863
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1864
+
1865
+
1866
+
1867
+ </li>
1868
+
1869
+ </ul>
1870
+
1871
+ <p class="tag_title">Returns:</p>
1872
+ <ul class="return">
1873
+
1874
+ <li>
1875
+
1876
+
1877
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>)</span>
1878
+
1879
+
1880
+
1881
+ &mdash;
1882
+ <div class='inline'>
1883
+ <p><code>column</code> or <code>row</code> of tiles starting with
1884
+ <code>tile</code> headed north until the end of the map</p>
1885
+ </div>
1886
+
1887
+ </li>
1888
+
1889
+ </ul>
1890
+
1891
+ <p class="tag_title">See Also:</p>
1892
+ <ul class="see">
1893
+
1894
+ <li><span class='object_link'><a href="#column-instance_method" title="Swarm::Map#column (method)">#column</a></span></li>
1895
+
1896
+ <li><span class='object_link'><a href="#row-instance_method" title="Swarm::Map#row (method)">#row</a></span></li>
1897
+
1898
+ </ul>
1899
+
1900
+ </div><table class="source_code">
1901
+ <tr>
1902
+ <td>
1903
+ <pre class="lines">
1904
+
1905
+
1906
+ 217
1907
+ 218
1908
+ 219
1909
+ 220</pre>
1910
+ </td>
1911
+ <td>
1912
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 217</span>
1913
+
1914
+ <span class='kw'>def</span> <span class='id identifier rubyid_north'>north</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1915
+ <span class='id identifier rubyid_tiles'>tiles</span> <span class='op'>=</span> <span class='id identifier rubyid_column'>column</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reverse'>reverse</span>
1916
+ <span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_rotate'>rotate</span><span class='lparen'>(</span><span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span> <span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1917
+ <span class='kw'>end</span></pre>
1918
+ </td>
1919
+ </tr>
1920
+ </table>
1921
+ </div>
1922
+
1923
+ <div class="method_details ">
1924
+ <h3 class="signature " id="row-instance_method">
1925
+
1926
+ #<strong>row</strong>(tile) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>
1927
+
1928
+
1929
+
1930
+
1931
+
1932
+ </h3><div class="docstring">
1933
+ <div class="discussion">
1934
+
1935
+ <p>Returns the row of tiles that the <code>tile</code> resides on</p>
1936
+
1937
+
1938
+ </div>
1939
+ </div>
1940
+ <div class="tags">
1941
+ <p class="tag_title">Parameters:</p>
1942
+ <ul class="param">
1943
+
1944
+ <li>
1945
+
1946
+ <span class='name'>tile</span>
1947
+
1948
+
1949
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
1950
+
1951
+
1952
+
1953
+ </li>
1954
+
1955
+ </ul>
1956
+
1957
+ <p class="tag_title">Returns:</p>
1958
+ <ul class="return">
1959
+
1960
+ <li>
1961
+
1962
+
1963
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>)</span>
1964
+
1965
+
1966
+
1967
+ &mdash;
1968
+ <div class='inline'>
1969
+ <p>the row of tiles that the <code>tile</code> resides on</p>
1970
+ </div>
1971
+
1972
+ </li>
1973
+
1974
+ </ul>
1975
+
1976
+ </div><table class="source_code">
1977
+ <tr>
1978
+ <td>
1979
+ <pre class="lines">
1980
+
1981
+
1982
+ 245
1983
+ 246
1984
+ 247</pre>
1985
+ </td>
1986
+ <td>
1987
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 245</span>
1988
+
1989
+ <span class='kw'>def</span> <span class='id identifier rubyid_row'>row</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
1990
+ <span class='ivar'>@tiles</span><span class='lbracket'>[</span><span class='id identifier rubyid_tile'>tile</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span><span class='rbracket'>]</span>
1991
+ <span class='kw'>end</span></pre>
1992
+ </td>
1993
+ </tr>
1994
+ </table>
1995
+ </div>
1996
+
1997
+ <div class="method_details ">
1998
+ <h3 class="signature " id="sample-instance_method">
1999
+
2000
+ #<strong>sample</strong> &#x21d2; <tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>
2001
+
2002
+
2003
+
2004
+
2005
+
2006
+ </h3><div class="docstring">
2007
+ <div class="discussion">
2008
+
2009
+ <p>Returns a random tile</p>
2010
+
2011
+
2012
+ </div>
2013
+ </div>
2014
+ <div class="tags">
2015
+
2016
+ <p class="tag_title">Returns:</p>
2017
+ <ul class="return">
2018
+
2019
+ <li>
2020
+
2021
+
2022
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
2023
+
2024
+
2025
+
2026
+ &mdash;
2027
+ <div class='inline'>
2028
+ <p>a random tile</p>
2029
+ </div>
2030
+
2031
+ </li>
2032
+
2033
+ </ul>
2034
+
2035
+ </div><table class="source_code">
2036
+ <tr>
2037
+ <td>
2038
+ <pre class="lines">
2039
+
2040
+
2041
+ 58
2042
+ 59
2043
+ 60</pre>
2044
+ </td>
2045
+ <td>
2046
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 58</span>
2047
+
2048
+ <span class='kw'>def</span> <span class='id identifier rubyid_sample'>sample</span>
2049
+ <span class='ivar'>@tiles</span><span class='period'>.</span><span class='id identifier rubyid_sample'>sample</span><span class='period'>.</span><span class='id identifier rubyid_sample'>sample</span>
2050
+ <span class='kw'>end</span></pre>
2051
+ </td>
2052
+ </tr>
2053
+ </table>
2054
+ </div>
2055
+
2056
+ <div class="method_details ">
2057
+ <h3 class="signature " id="score-instance_method">
2058
+
2059
+ #<strong>score</strong>(key) &#x21d2; <tt>Object</tt>
2060
+
2061
+
2062
+
2063
+
2064
+
2065
+ </h3><table class="source_code">
2066
+ <tr>
2067
+ <td>
2068
+ <pre class="lines">
2069
+
2070
+
2071
+ 83
2072
+ 84
2073
+ 85</pre>
2074
+ </td>
2075
+ <td>
2076
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 83</span>
2077
+
2078
+ <span class='kw'>def</span> <span class='id identifier rubyid_score'>score</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
2079
+ <span class='const'><span class='object_link'><a href="Catalog.html" title="Swarm::Catalog (class)">Catalog</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch'><span class='object_link'><a href="Catalog.html#fetch-class_method" title="Swarm::Catalog.fetch (method)">fetch</a></span></span> <span class='symbol'>:destroyed</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='int'>0</span>
2080
+ <span class='kw'>end</span></pre>
2081
+ </td>
2082
+ </tr>
2083
+ </table>
2084
+ </div>
2085
+
2086
+ <div class="method_details ">
2087
+ <h3 class="signature " id="south-instance_method">
2088
+
2089
+ #<strong>south</strong>(tile) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>
2090
+
2091
+
2092
+
2093
+
2094
+
2095
+ </h3><div class="docstring">
2096
+ <div class="discussion">
2097
+
2098
+ <p>Returns <code>column</code> or <code>row</code> of tiles starting with
2099
+ <code>tile</code> headed south until the end of the map</p>
2100
+
2101
+
2102
+ </div>
2103
+ </div>
2104
+ <div class="tags">
2105
+ <p class="tag_title">Parameters:</p>
2106
+ <ul class="param">
2107
+
2108
+ <li>
2109
+
2110
+ <span class='name'>tile</span>
2111
+
2112
+
2113
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
2114
+
2115
+
2116
+
2117
+ </li>
2118
+
2119
+ </ul>
2120
+
2121
+ <p class="tag_title">Returns:</p>
2122
+ <ul class="return">
2123
+
2124
+ <li>
2125
+
2126
+
2127
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>)</span>
2128
+
2129
+
2130
+
2131
+ &mdash;
2132
+ <div class='inline'>
2133
+ <p><code>column</code> or <code>row</code> of tiles starting with
2134
+ <code>tile</code> headed south until the end of the map</p>
2135
+ </div>
2136
+
2137
+ </li>
2138
+
2139
+ </ul>
2140
+
2141
+ <p class="tag_title">See Also:</p>
2142
+ <ul class="see">
2143
+
2144
+ <li><span class='object_link'><a href="#column-instance_method" title="Swarm::Map#column (method)">#column</a></span></li>
2145
+
2146
+ <li><span class='object_link'><a href="#row-instance_method" title="Swarm::Map#row (method)">#row</a></span></li>
2147
+
2148
+ </ul>
2149
+
2150
+ </div><table class="source_code">
2151
+ <tr>
2152
+ <td>
2153
+ <pre class="lines">
2154
+
2155
+
2156
+ 223
2157
+ 224
2158
+ 225
2159
+ 226</pre>
2160
+ </td>
2161
+ <td>
2162
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 223</span>
2163
+
2164
+ <span class='kw'>def</span> <span class='id identifier rubyid_south'>south</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
2165
+ <span class='id identifier rubyid_tiles'>tiles</span> <span class='op'>=</span> <span class='id identifier rubyid_column'>column</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
2166
+ <span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_rotate'>rotate</span><span class='lparen'>(</span><span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span> <span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
2167
+ <span class='kw'>end</span></pre>
2168
+ </td>
2169
+ </tr>
2170
+ </table>
2171
+ </div>
2172
+
2173
+ <div class="method_details ">
2174
+ <h3 class="signature " id="spawn-instance_method">
2175
+
2176
+ #<strong>spawn</strong>(flag, percent = 0.0) &#x21d2; <tt>Object</tt>
2177
+
2178
+
2179
+
2180
+
2181
+
2182
+ </h3><table class="source_code">
2183
+ <tr>
2184
+ <td>
2185
+ <pre class="lines">
2186
+
2187
+
2188
+ 87
2189
+ 88
2190
+ 89
2191
+ 90
2192
+ 91</pre>
2193
+ </td>
2194
+ <td>
2195
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 87</span>
2196
+
2197
+ <span class='kw'>def</span> <span class='id identifier rubyid_spawn'>spawn</span><span class='lparen'>(</span><span class='id identifier rubyid_flag'>flag</span><span class='comma'>,</span> <span class='id identifier rubyid_percent'>percent</span> <span class='op'>=</span> <span class='float'>0.0</span><span class='rparen'>)</span>
2198
+ <span class='id identifier rubyid_total'>total</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_percent'>percent</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span> <span class='op'>/</span> <span class='int'>100</span><span class='rparen'>)</span> <span class='op'>*</span> <span class='id identifier rubyid_count'>count</span><span class='rparen'>)</span>
2199
+
2200
+ <span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:empty?</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_sample'>sample</span><span class='lparen'>(</span><span class='id identifier rubyid_total'>total</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='op'>&amp;</span><span class='id identifier rubyid_flag'>flag</span>
2201
+ <span class='kw'>end</span></pre>
2202
+ </td>
2203
+ </tr>
2204
+ </table>
2205
+ </div>
2206
+
2207
+ <div class="method_details ">
2208
+ <h3 class="signature " id="update-instance_method">
2209
+
2210
+ #<strong>update</strong> &#x21d2; <tt>Object</tt>
2211
+
2212
+
2213
+
2214
+
2215
+
2216
+ </h3><table class="source_code">
2217
+ <tr>
2218
+ <td>
2219
+ <pre class="lines">
2220
+
2221
+
2222
+ 206
2223
+ 207
2224
+ 208</pre>
2225
+ </td>
2226
+ <td>
2227
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 206</span>
2228
+
2229
+ <span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span>
2230
+ <span class='const'><span class='object_link'><a href="Console.html" title="Swarm::Console (module)">Console</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update'><span class='object_link'><a href="Console.html#update-instance_method" title="Swarm::Console#update (method)">update</a></span></span> <span class='const'><span class='object_link'><a href="Catalog.html" title="Swarm::Catalog (class)">Catalog</a></span></span><span class='period'>.</span><span class='id identifier rubyid_flush'><span class='object_link'><a href="Catalog.html#flush-class_method" title="Swarm::Catalog.flush (method)">flush</a></span></span><span class='lparen'>(</span><span class='symbol'>:changed</span><span class='rparen'>)</span>
2231
+ <span class='kw'>end</span></pre>
2232
+ </td>
2233
+ </tr>
2234
+ </table>
2235
+ </div>
2236
+
2237
+ <div class="method_details ">
2238
+ <h3 class="signature " id="west-instance_method">
2239
+
2240
+ #<strong>west</strong>(tile) &#x21d2; <tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>
2241
+
2242
+
2243
+
2244
+
2245
+
2246
+ </h3><div class="docstring">
2247
+ <div class="discussion">
2248
+
2249
+ <p>Returns <code>column</code> or <code>row</code> of tiles starting with
2250
+ <code>tile</code> headed west until the end of the map</p>
2251
+
2252
+
2253
+ </div>
2254
+ </div>
2255
+ <div class="tags">
2256
+ <p class="tag_title">Parameters:</p>
2257
+ <ul class="param">
2258
+
2259
+ <li>
2260
+
2261
+ <span class='name'>tile</span>
2262
+
2263
+
2264
+ <span class='type'>(<tt><span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span></tt>)</span>
2265
+
2266
+
2267
+
2268
+ </li>
2269
+
2270
+ </ul>
2271
+
2272
+ <p class="tag_title">Returns:</p>
2273
+ <ul class="return">
2274
+
2275
+ <li>
2276
+
2277
+
2278
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="Tile.html" title="Swarm::Tile (class)">Tile</a></span>, ...&gt;</tt>)</span>
2279
+
2280
+
2281
+
2282
+ &mdash;
2283
+ <div class='inline'>
2284
+ <p><code>column</code> or <code>row</code> of tiles starting with
2285
+ <code>tile</code> headed west until the end of the map</p>
2286
+ </div>
2287
+
2288
+ </li>
2289
+
2290
+ </ul>
2291
+
2292
+ <p class="tag_title">See Also:</p>
2293
+ <ul class="see">
2294
+
2295
+ <li><span class='object_link'><a href="#column-instance_method" title="Swarm::Map#column (method)">#column</a></span></li>
2296
+
2297
+ <li><span class='object_link'><a href="#row-instance_method" title="Swarm::Map#row (method)">#row</a></span></li>
2298
+
2299
+ </ul>
2300
+
2301
+ </div><table class="source_code">
2302
+ <tr>
2303
+ <td>
2304
+ <pre class="lines">
2305
+
2306
+
2307
+ 235
2308
+ 236
2309
+ 237
2310
+ 238</pre>
2311
+ </td>
2312
+ <td>
2313
+ <pre class="code"><span class="info file"># File 'lib/swarm/map.rb', line 235</span>
2314
+
2315
+ <span class='kw'>def</span> <span class='id identifier rubyid_west'>west</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
2316
+ <span class='id identifier rubyid_tiles'>tiles</span> <span class='op'>=</span> <span class='id identifier rubyid_row'>row</span><span class='lparen'>(</span><span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reverse'>reverse</span>
2317
+ <span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_rotate'>rotate</span><span class='lparen'>(</span><span class='id identifier rubyid_tiles'>tiles</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span> <span class='id identifier rubyid_tile'>tile</span><span class='rparen'>)</span>
2318
+ <span class='kw'>end</span></pre>
2319
+ </td>
2320
+ </tr>
2321
+ </table>
2322
+ </div>
2323
+
2324
+ </div>
2325
+
2326
+ </div>
2327
+
2328
+ <div id="footer">
2329
+ Generated on Wed Aug 30 07:17:58 2017 by
2330
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2331
+ 0.9.9 (ruby-2.4.1).
2332
+ </div>
2333
+
2334
+ </div>
2335
+ </body>
2336
+ </html>