battlesnake 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -69,11 +69,13 @@
69
69
  <dl>
70
70
  <dt>Inherits:</dt>
71
71
  <dd>
72
- <span class="inheritName">Object</span>
72
+ <span class="inheritName"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></span>
73
73
 
74
74
  <ul class="fullTree">
75
75
  <li>Object</li>
76
76
 
77
+ <li class="next"><span class='object_link'><a href="Base.html" title="Battlesnake::Base (class)">Base</a></span></li>
78
+
77
79
  <li class="next">Battlesnake::Board</li>
78
80
 
79
81
  </ul>
@@ -307,6 +309,54 @@
307
309
  <li class="public ">
308
310
  <span class="summary_signature">
309
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
+
310
360
  <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(json_or_hash) &#x21d2; Board </a>
311
361
 
312
362
 
@@ -327,12 +377,71 @@
327
377
  <p>Returns a new instance of Board.</p>
328
378
  </div></span>
329
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
+
330
428
  </li>
331
429
 
332
430
 
333
431
  </ul>
334
432
 
335
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>
336
445
  <div id="constructor_details" class="method_details_list">
337
446
  <h2>Constructor Details</h2>
338
447
 
@@ -785,10 +894,320 @@
785
894
  </div>
786
895
 
787
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
+
788
1207
  </div>
789
1208
 
790
1209
  <div id="footer">
791
- Generated on Fri Nov 4 19:07:50 2022 by
1210
+ Generated on Sat Nov 5 20:09:02 2022 by
792
1211
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
793
1212
  0.9.28 (ruby-2.7.2).
794
1213
  </div>
@@ -125,7 +125,7 @@
125
125
  </div>
126
126
 
127
127
  <div id="footer">
128
- Generated on Fri Nov 4 19:07:49 2022 by
128
+ Generated on Sat Nov 5 20:09:02 2022 by
129
129
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
130
  0.9.28 (ruby-2.7.2).
131
131
  </div>