1<!DOCTYPE html> 2<html lang="en"> 3<head> 4<meta charset="UTF-8"> 5<title>sampleFile - OpenGrok cross reference for /sampleFile</title></head><body> 6<script type="text/javascript">/* <![CDATA[ */ 7function get_sym_list(){return [["Class","xc",[["Board",4]]],["Method","xmt",[["clr",5],["colorstr",11],["count",88],["down",127],["fetch",78],["initialize",22],["left",135],["mark",49],["open",57],["over",94],["over?",105],["pos",8],["put",14],["quit",116],["reset",27],["right",139],["up",131]]]];} /* ]]> */</script><a class="l" name="1" href="#1">1</a><span class="c">#! /<a href="/source/s?path=/usr/">usr</a>/<a href="/source/s?path=/usr/bin/">bin</a>/<a href="/source/s?path=/usr/bin/ruby">ruby</a> -Ku</span> 8<a class="l" name="2" href="#2">2</a><span class="c"># -*- coding: utf-8 -*-</span> 9<a class="l" name="3" href="#3">3</a> 10<a class="l" name="4" href="#4">4</a><b>class</b> <a class="xc" name="Board"/><a href="/source/s?refs=Board" class="xc intelliWindow-symbol" data-definition-place="def">Board</a> 11<a class="l" name="5" href="#5">5</a> <b>def</b> <a class="xmt" name="clr"/><a href="/source/s?refs=clr" class="xmt intelliWindow-symbol" data-definition-place="def">clr</a> 12<a class="l" name="6" href="#6">6</a> <b>print</b> <span class="s">"\e[2J"</span> 13<a class="l" name="7" href="#7">7</a> <b>end</b> 14<a class="l" name="8" href="#8">8</a> <b>def</b> <b>pos</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) 15<a class="l" name="9" href="#9">9</a> <b>printf</b> <span class="s">"\e[%d;%dH"</span>, <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<span class="n">1</span>, <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>*<span class="n">2</span>+<span class="n">1</span> 16<a class="hl" name="10" href="#10">10</a> <b>end</b> 17<a class="l" name="11" href="#11">11</a> <b>def</b> <a class="xmt" name="colorstr"/><a href="/source/s?refs=colorstr" class="xmt intelliWindow-symbol" data-definition-place="def">colorstr</a>(<a href="/source/s?defs=id" class="intelliWindow-symbol" data-definition-place="undefined-in-file">id</a>,<a href="/source/s?defs=s" class="intelliWindow-symbol" data-definition-place="undefined-in-file">s</a>) 18<a class="l" name="12" href="#12">12</a> <b>printf</b> <span class="s">"\e[%dm%s\e[0m"</span>, <a href="/source/s?defs=id" class="intelliWindow-symbol" data-definition-place="undefined-in-file">id</a>, <a href="/source/s?defs=s" class="intelliWindow-symbol" data-definition-place="undefined-in-file">s</a> 19<a class="l" name="13" href="#13">13</a> <b>end</b> 20<a class="l" name="14" href="#14">14</a> <b>def</b> <a class="xmt" name="put"/><a href="/source/s?refs=put" class="xmt intelliWindow-symbol" data-definition-place="def">put</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>, <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>, <a href="/source/s?defs=col" class="intelliWindow-symbol" data-definition-place="undefined-in-file">col</a>, <a href="/source/s?defs=str" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>) 21<a class="l" name="15" href="#15">15</a> <b>pos</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>); <a class="d intelliWindow-symbol" href="#colorstr" data-definition-place="defined-in-file">colorstr</a>(<span class="n">43</span>,<a href="/source/s?defs=str" class="intelliWindow-symbol" data-definition-place="undefined-in-file">str</a>) 22<a class="l" name="16" href="#16">16</a> <b>pos</b>(<span class="n">0</span>,<a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>); <b>print</b> <span class="s">"残り:"</span>,<a href="/source/s?defs=%40mc" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@mc</a>,<span class="s">"/"</span>,<a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>,<span class="s">" "</span> 23<a class="l" name="17" href="#17">17</a> <b>pos</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) 24<a class="l" name="18" href="#18">18</a> <b>end</b> 25<a class="l" name="19" href="#19">19</a> <a href="/source/s?defs=private" class="intelliWindow-symbol" data-definition-place="undefined-in-file">private</a> <a href="/source/s?defs=%5C%3Aclr" class="intelliWindow-symbol" data-definition-place="undefined-in-file">:clr</a>, <a href="/source/s?defs=%5C%3Apos" class="intelliWindow-symbol" data-definition-place="undefined-in-file">:pos</a>, <a href="/source/s?defs=%5C%3Acolorstr" class="intelliWindow-symbol" data-definition-place="undefined-in-file">:colorstr</a>, <a href="/source/s?defs=%5C%3Aput" class="intelliWindow-symbol" data-definition-place="undefined-in-file">:put</a> 26<a class="hl" name="20" href="#20">20</a> <a href="/source/s?defs=CHR" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CHR</a>=[<span class="s">"・"</span>,<span class="s">"1"</span>,<span class="s">"2"</span>,<span class="s">"3"</span>,<span class="s">"4"</span>,<span class="s">"5"</span>,<span class="s">"6"</span>,<span class="s">"7"</span>,<span class="s">"8"</span>,<span class="s">"★"</span>,<span class="s">"●"</span>,<span class="s">"@@"</span>] 27<a class="l" name="21" href="#21">21</a> <a href="/source/s?defs=COL" class="intelliWindow-symbol" data-definition-place="undefined-in-file">COL</a>=[<span class="n">46</span>,<span class="n">43</span>,<span class="n">45</span>] <span class="c"># default,opened,over</span> 28<a class="l" name="22" href="#22">22</a> <b>def</b> <a class="xmt" name="initialize"/><a href="/source/s?refs=initialize" class="xmt intelliWindow-symbol" data-definition-place="def">initialize</a>(<a href="/source/s?defs=h" class="intelliWindow-symbol" data-definition-place="undefined-in-file">h</a>,<a href="/source/s?defs=w" class="intelliWindow-symbol" data-definition-place="undefined-in-file">w</a>,<a href="/source/s?defs=m" class="intelliWindow-symbol" data-definition-place="undefined-in-file">m</a>) 29<a class="l" name="23" href="#23">23</a> <span class="c"># ゲーム盤の生成(h:縦,w:横,m:爆弾の数)</span> 30<a class="l" name="24" href="#24">24</a> <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>=<a href="/source/s?defs=h" class="intelliWindow-symbol" data-definition-place="undefined-in-file">h</a>; <a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>=<a href="/source/s?defs=w" class="intelliWindow-symbol" data-definition-place="undefined-in-file">w</a>; <a href="/source/s?defs=%40m" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@m</a>=<a href="/source/s?defs=m" class="intelliWindow-symbol" data-definition-place="undefined-in-file">m</a> 31<a class="l" name="25" href="#25">25</a> <a class="d intelliWindow-symbol" href="#reset" data-definition-place="defined-in-file">reset</a> 32<a class="l" name="26" href="#26">26</a> <b>end</b> 33<a class="l" name="27" href="#27">27</a> <b>def</b> <a class="xmt" name="reset"/><a href="/source/s?refs=reset" class="xmt intelliWindow-symbol" data-definition-place="def">reset</a> 34<a class="l" name="28" href="#28">28</a> <span class="c"># ゲーム盤を(再)初期化する</span> 35<a class="l" name="29" href="#29">29</a> <b>srand</b>() 36<a class="hl" name="30" href="#30">30</a> <a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>=<span class="n">0</span>; <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>=<span class="n">0</span>; <a href="/source/s?defs=%40mc" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@mc</a>=<a href="/source/s?defs=%40m" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@m</a> 37<a class="l" name="31" href="#31">31</a> <a href="/source/s?defs=%40over" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@over</a>=<b>false</b> 38<a class="l" name="32" href="#32">32</a> <a href="/source/s?defs=%40data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@data</a>=<b>Array</b>.<b>new</b>(<a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>*<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>) 39<a class="l" name="33" href="#33">33</a> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>=<b>Array</b>.<b>new</b>(<a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>*<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>) 40<a class="l" name="34" href="#34">34</a> <a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>=<a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>*<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a> 41<a class="l" name="35" href="#35">35</a> <a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>.<b>times</b> {|<a href="/source/s?defs=i" class="intelliWindow-symbol" data-definition-place="undefined-in-file">i</a>| <a href="/source/s?defs=%40data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@data</a>[<a href="/source/s?defs=i" class="intelliWindow-symbol" data-definition-place="undefined-in-file">i</a>]=<span class="n">0</span>} 42<a class="l" name="36" href="#36">36</a> <a href="/source/s?defs=%40m" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@m</a>.<b>times</b> <b>do</b> 43<a class="l" name="37" href="#37">37</a> <b>loop</b> <b>do</b> 44<a class="l" name="38" href="#38">38</a> <a href="/source/s?defs=j" class="intelliWindow-symbol" data-definition-place="undefined-in-file">j</a>=<b>rand</b>(<a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>-<span class="n">1</span>) 45<a class="l" name="39" href="#39">39</a> <b>if</b> <a href="/source/s?defs=%40data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@data</a>[<a href="/source/s?defs=j" class="intelliWindow-symbol" data-definition-place="undefined-in-file">j</a>] == <span class="n">0</span> <b>then</b> 46<a class="hl" name="40" href="#40">40</a> <a href="/source/s?defs=%40data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@data</a>[<a href="/source/s?defs=j" class="intelliWindow-symbol" data-definition-place="undefined-in-file">j</a>]=<span class="n">1</span> 47<a class="l" name="41" href="#41">41</a> <b>break</b> 48<a class="l" name="42" href="#42">42</a> <b>end</b> 49<a class="l" name="43" href="#43">43</a> <b>end</b> 50<a class="l" name="44" href="#44">44</a> <b>end</b> 51<a class="l" name="45" href="#45">45</a> <a class="d intelliWindow-symbol" href="#clr" data-definition-place="defined-in-file">clr</a>; <b>pos</b>(<span class="n">0</span>,<span class="n">0</span>) 52<a class="l" name="46" href="#46">46</a> <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>.<b>times</b>{|<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>| <b>pos</b>(<span class="n">0</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>); <a class="d intelliWindow-symbol" href="#colorstr" data-definition-place="defined-in-file">colorstr</a>(<a href="/source/s?defs=COL" class="intelliWindow-symbol" data-definition-place="undefined-in-file">COL</a>[<span class="n">0</span>],<a href="/source/s?defs=CHR" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CHR</a>[<span class="n">0</span>]*<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>)} 53<a class="l" name="47" href="#47">47</a> <b>pos</b>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>,<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>) 54<a class="l" name="48" href="#48">48</a> <b>end</b> 55<a class="l" name="49" href="#49">49</a> <b>def</b> <a class="xmt" name="mark"/><a href="/source/s?refs=mark" class="xmt intelliWindow-symbol" data-definition-place="def">mark</a> 56<a class="hl" name="50" href="#50">50</a> <span class="c"># 現在のカーソル位置にマークをつける</span> 57<a class="l" name="51" href="#51">51</a> <b>if</b> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>[<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>*<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>+<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>] != <b>nil</b> <b>then</b> <b>return</b> <b>end</b> 58<a class="l" name="52" href="#52">52</a> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>[<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>*<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>+<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>] = <span class="s">"MARK"</span> 59<a class="l" name="53" href="#53">53</a> <a href="/source/s?defs=%40mc" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@mc</a>=<a href="/source/s?defs=%40mc" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@mc</a>-<span class="n">1</span>; 60<a class="l" name="54" href="#54">54</a> <a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>=<a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>-<span class="n">1</span>; 61<a class="l" name="55" href="#55">55</a> <a class="d intelliWindow-symbol" href="#put" data-definition-place="defined-in-file">put</a>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>, <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>, <a href="/source/s?defs=COL" class="intelliWindow-symbol" data-definition-place="undefined-in-file">COL</a>[<span class="n">1</span>], <a href="/source/s?defs=CHR" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CHR</a>[<span class="n">9</span>]) 62<a class="l" name="56" href="#56">56</a> <b>end</b> 63<a class="l" name="57" href="#57">57</a> <b>def</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>=<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>=<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>) 64<a class="l" name="58" href="#58">58</a> <span class="c"># 現在のカーソル位置をオープンにする</span> 65<a class="l" name="59" href="#59">59</a> <span class="c"># 爆弾があればゲームオーバー</span> 66<a class="hl" name="60" href="#60">60</a> <b>if</b> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>[<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>*<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>] ==<span class="s">"OPEN"</span> <b>then</b> <b>return</b> <span class="n">0</span> <b>end</b> 67<a class="l" name="61" href="#61">61</a> <b>if</b> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>[<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>*<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>] == <b>nil</b> <b>then</b> <a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>=<a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a>-<span class="n">1</span> <b>end</b> 68<a class="l" name="62" href="#62">62</a> <b>if</b> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>[<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>*<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>] ==<span class="s">"MARK"</span> <b>then</b> <a href="/source/s?defs=%40mc" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@mc</a>=<a href="/source/s?defs=%40mc" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@mc</a>+<span class="n">1</span> <b>end</b> 69<a class="l" name="63" href="#63">63</a> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>[<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>*<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>]=<span class="s">"OPEN"</span> 70<a class="l" name="64" href="#64">64</a> <b>if</b> <a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) == <span class="n">1</span> <b>then</b> <a href="/source/s?defs=%40over" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@over</a> = <span class="n">1</span>; <b>return</b> <b>end</b> 71<a class="l" name="65" href="#65">65</a> <a href="/source/s?defs=c" class="intelliWindow-symbol" data-definition-place="undefined-in-file">c</a> = <b>count</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) 72<a class="l" name="66" href="#66">66</a> <a class="d intelliWindow-symbol" href="#put" data-definition-place="defined-in-file">put</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>, <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>, <a href="/source/s?defs=COL" class="intelliWindow-symbol" data-definition-place="undefined-in-file">COL</a>[<span class="n">1</span>], <a href="/source/s?defs=CHR" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CHR</a>[<a href="/source/s?defs=c" class="intelliWindow-symbol" data-definition-place="undefined-in-file">c</a>]) 73<a class="l" name="67" href="#67">67</a> <b>return</b> <span class="n">0</span> <b>if</b> <a href="/source/s?defs=c" class="intelliWindow-symbol" data-definition-place="undefined-in-file">c</a> != <span class="n">0</span> 74<a class="l" name="68" href="#68">68</a> <b>if</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> > <span class="n">0</span> && <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> > <span class="n">0</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>-<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>-<span class="n">1</span>) <b>end</b> 75<a class="l" name="69" href="#69">69</a> <b>if</b> <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> > <span class="n">0</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>, <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>-<span class="n">1</span>) <b>end</b> 76<a class="hl" name="70" href="#70">70</a> <b>if</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> < <a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>-<span class="n">1</span> && <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> > <span class="n">0</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>+<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>-<span class="n">1</span>) <b>end</b> 77<a class="l" name="71" href="#71">71</a> <b>if</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> > <span class="n">0</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>-<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) <b>end</b> 78<a class="l" name="72" href="#72">72</a> <b>if</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> < <a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>-<span class="n">1</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>+<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) <b>end</b> 79<a class="l" name="73" href="#73">73</a> <b>if</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> > <span class="n">0</span> && <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> < <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>-<span class="n">1</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>-<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<span class="n">1</span>) <b>end</b> 80<a class="l" name="74" href="#74">74</a> <b>if</b> <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> < <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a> -<span class="n">1</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<span class="n">1</span>) <b>end</b> 81<a class="l" name="75" href="#75">75</a> <b>if</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> < <a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>-<span class="n">1</span> && <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> < <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>-<span class="n">1</span> <b>then</b> <b>open</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>+<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<span class="n">1</span>) <b>end</b> 82<a class="l" name="76" href="#76">76</a> <b>pos</b>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>,<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>) 83<a class="l" name="77" href="#77">77</a> <b>end</b> 84<a class="l" name="78" href="#78">78</a> <b>def</b> <a class="xmt" name="fetch"/><a href="/source/s?refs=fetch" class="xmt intelliWindow-symbol" data-definition-place="def">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) 85<a class="l" name="79" href="#79">79</a> <span class="c"># (x,y)の位置の爆弾の数(0 or 1)を返す</span> 86<a class="hl" name="80" href="#80">80</a> <b>if</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> < <span class="n">0</span> <b>then</b> <span class="n">0</span> 87<a class="l" name="81" href="#81">81</a> <b>elsif</b> <a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a> >= <a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a> <b>then</b> <span class="n">0</span> 88<a class="l" name="82" href="#82">82</a> <b>elsif</b> <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> < <span class="n">0</span> <b>then</b> <span class="n">0</span> 89<a class="l" name="83" href="#83">83</a> <b>elsif</b> <a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a> >= <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a> <b>then</b> <span class="n">0</span> 90<a class="l" name="84" href="#84">84</a> <b>else</b> 91<a class="l" name="85" href="#85">85</a> <a href="/source/s?defs=%40data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@data</a>[<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>*<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>+<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>] 92<a class="l" name="86" href="#86">86</a> <b>end</b> 93<a class="l" name="87" href="#87">87</a> <b>end</b> 94<a class="l" name="88" href="#88">88</a> <b>def</b> <b>count</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) 95<a class="l" name="89" href="#89">89</a> <span class="c"># (x,y)に隣接する爆弾の数を返す</span> 96<a class="hl" name="90" href="#90">90</a> <a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>-<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>-<span class="n">1</span>)+<a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>-<span class="n">1</span>)+<a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>+<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>-<span class="n">1</span>)+ 97<a class="l" name="91" href="#91">91</a> <a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>-<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) + <a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>+<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>)+ 98<a class="l" name="92" href="#92">92</a> <a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>-<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<span class="n">1</span>)+<a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<span class="n">1</span>)+<a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>+<span class="n">1</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>+<span class="n">1</span>) 99<a class="l" name="93" href="#93">93</a> <b>end</b> 100<a class="l" name="94" href="#94">94</a> <b>def</b> <a class="xmt" name="over"/><a href="/source/s?refs=over" class="xmt intelliWindow-symbol" data-definition-place="def">over</a>(<a href="/source/s?defs=win" class="intelliWindow-symbol" data-definition-place="undefined-in-file">win</a>) 101<a class="l" name="95" href="#95">95</a> <span class="c"># ゲームの終了</span> 102<a class="l" name="96" href="#96">96</a> <a class="d intelliWindow-symbol" href="#quit" data-definition-place="defined-in-file">quit</a> 103<a class="l" name="97" href="#97">97</a> <b>unless</b> <a href="/source/s?defs=win" class="intelliWindow-symbol" data-definition-place="undefined-in-file">win</a> 104<a class="l" name="98" href="#98">98</a> <b>pos</b>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>,<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>); <b>print</b> <a href="/source/s?defs=CHR" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CHR</a>[<span class="n">11</span>] 105<a class="l" name="99" href="#99">99</a> <b>end</b> 106<a class="hl" name="100" href="#100">100</a> <b>pos</b>(<span class="n">0</span>,<a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>) 107<a class="l" name="101" href="#101">101</a> <b>if</b> <a href="/source/s?defs=win" class="intelliWindow-symbol" data-definition-place="undefined-in-file">win</a> <b>then</b> <b>print</b> <span class="s">"*** YOU WIN !! ***"</span> 108<a class="l" name="102" href="#102">102</a> <b>else</b> <b>print</b> <span class="s">"*** GAME OVER ***"</span> 109<a class="l" name="103" href="#103">103</a> <b>end</b> 110<a class="l" name="104" href="#104">104</a> <b>end</b> 111<a class="l" name="105" href="#105">105</a> <b>def</b> <a class="xmt" name="over?"/><a href="/source/s?refs=over%5C%3F" class="xmt intelliWindow-symbol" data-definition-place="def">over?</a> 112<a class="l" name="106" href="#106">106</a> <span class="c"># ゲームの終了チェック</span> 113<a class="l" name="107" href="#107">107</a> <span class="c"># 終了処理も呼び出す</span> 114<a class="l" name="108" href="#108">108</a> <a href="/source/s?defs=remain" class="intelliWindow-symbol" data-definition-place="undefined-in-file">remain</a> = (<a href="/source/s?defs=%40mc" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@mc</a>+<a href="/source/s?defs=%40total" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@total</a> == <span class="n">0</span>) 115<a class="l" name="109" href="#109">109</a> <b>if</b> <a href="/source/s?defs=%40over" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@over</a> || <a href="/source/s?defs=remain" class="intelliWindow-symbol" data-definition-place="undefined-in-file">remain</a> 116<a class="hl" name="110" href="#110">110</a> <a class="d intelliWindow-symbol" href="#over" data-definition-place="defined-in-file">over</a>(<a href="/source/s?defs=remain" class="intelliWindow-symbol" data-definition-place="undefined-in-file">remain</a>) 117<a class="l" name="111" href="#111">111</a> <b>true</b> 118<a class="l" name="112" href="#112">112</a> <b>else</b> 119<a class="l" name="113" href="#113">113</a> <b>false</b> 120<a class="l" name="114" href="#114">114</a> <b>end</b> 121<a class="l" name="115" href="#115">115</a> <b>end</b> 122<a class="l" name="116" href="#116">116</a> <b>def</b> <a class="xmt" name="quit"/><a href="/source/s?refs=quit" class="xmt intelliWindow-symbol" data-definition-place="def">quit</a> 123<a class="l" name="117" href="#117">117</a> <span class="c"># ゲームの中断(または終了)</span> 124<a class="l" name="118" href="#118">118</a> <span class="c"># 盤面を全て見せる</span> 125<a class="l" name="119" href="#119">119</a> <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>.<b>times</b> <b>do</b>|<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>| 126<a class="hl" name="120" href="#120">120</a> <b>pos</b>(<span class="n">0</span>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>) 127<a class="l" name="121" href="#121">121</a> <a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>.<b>times</b> <b>do</b>|<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>| 128<a class="l" name="122" href="#122">122</a> <a class="d intelliWindow-symbol" href="#colorstr" data-definition-place="defined-in-file">colorstr</a>(<b>if</b> <a href="/source/s?defs=%40state" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@state</a>[<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>*<a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>+<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>] == <span class="s">"MARK"</span> <b>then</b> <a href="/source/s?defs=COL" class="intelliWindow-symbol" data-definition-place="undefined-in-file">COL</a>[<span class="n">1</span>] <b>else</b> <a href="/source/s?defs=COL" class="intelliWindow-symbol" data-definition-place="undefined-in-file">COL</a>[<span class="n">2</span>] <b>end</b>, 129<a class="l" name="123" href="#123">123</a> <b>if</b> <a class="d intelliWindow-symbol" href="#fetch" data-definition-place="defined-in-file">fetch</a>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>)==<span class="n">1</span> <b>then</b> <a href="/source/s?defs=CHR" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CHR</a>[<span class="n">10</span>] <b>else</b> <a href="/source/s?defs=CHR" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CHR</a>[<b>count</b>(<a href="/source/s?defs=x" class="intelliWindow-symbol" data-definition-place="undefined-in-file">x</a>,<a href="/source/s?defs=y" class="intelliWindow-symbol" data-definition-place="undefined-in-file">y</a>)] <b>end</b>) 130<a class="l" name="124" href="#124">124</a> <b>end</b> 131<a class="l" name="125" href="#125">125</a> <b>end</b> 132<a class="l" name="126" href="#126">126</a> <b>end</b> 133<a class="l" name="127" href="#127">127</a> <b>def</b> <a class="xmt" name="down"/><a href="/source/s?refs=down" class="xmt intelliWindow-symbol" data-definition-place="def">down</a> 134<a class="l" name="128" href="#128">128</a> <span class="c"># カーソルを下に</span> 135<a class="l" name="129" href="#129">129</a> <b>if</b> <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a> < <a href="/source/s?defs=%40hi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@hi</a>-<span class="n">1</span> <b>then</b> <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>=<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>+<span class="n">1</span>; <b>pos</b>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>, <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>) <b>end</b> 136<a class="hl" name="130" href="#130">130</a> <b>end</b> 137<a class="l" name="131" href="#131">131</a> <b>def</b> <a class="xmt" name="up"/><a href="/source/s?refs=up" class="xmt intelliWindow-symbol" data-definition-place="def">up</a> 138<a class="l" name="132" href="#132">132</a> <span class="c"># カーソルを上に</span> 139<a class="l" name="133" href="#133">133</a> <b>if</b> <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a> > <span class="n">0</span> <b>then</b> <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>=<a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>-<span class="n">1</span>; <b>pos</b>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>, <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>) <b>end</b> 140<a class="l" name="134" href="#134">134</a> <b>end</b> 141<a class="l" name="135" href="#135">135</a> <b>def</b> <a class="xmt" name="left"/><a href="/source/s?refs=left" class="xmt intelliWindow-symbol" data-definition-place="def">left</a> 142<a class="l" name="136" href="#136">136</a> <span class="c"># カーソルを左に</span> 143<a class="l" name="137" href="#137">137</a> <b>if</b> <a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a> > <span class="n">0</span> <b>then</b> <a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>=<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>-<span class="n">1</span>; <b>pos</b>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>, <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>) <b>end</b> 144<a class="l" name="138" href="#138">138</a> <b>end</b> 145<a class="l" name="139" href="#139">139</a> <b>def</b> <a class="xmt" name="right"/><a href="/source/s?refs=right" class="xmt intelliWindow-symbol" data-definition-place="def">right</a> 146<a class="hl" name="140" href="#140">140</a> <span class="c"># カーソルを右に</span> 147<a class="l" name="141" href="#141">141</a> <b>if</b> <a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a> < <a href="/source/s?defs=%40wi" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@wi</a>-<span class="n">1</span> <b>then</b> <a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>=<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>+<span class="n">1</span>; <b>pos</b>(<a href="/source/s?defs=%40cx" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cx</a>, <a href="/source/s?defs=%40cy" class="intelliWindow-symbol" data-definition-place="undefined-in-file">@cy</a>) <b>end</b> 148<a class="l" name="142" href="#142">142</a> <b>end</b> 149<a class="l" name="143" href="#143">143</a><b>end</b> 150<a class="l" name="144" href="#144">144</a> 151<a class="l" name="145" href="#145">145</a><a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>=<a class="d intelliWindow-symbol" href="#Board" data-definition-place="defined-in-file">Board</a>.<b>new</b>(<span class="n">10</span>,<span class="n">10</span>,<span class="n">10</span>) 152<a class="l" name="146" href="#146">146</a><b>system</b>(<span class="s">"stty raw -echo"</span>) 153<a class="l" name="147" href="#147">147</a><b>begin</b> 154<a class="l" name="148" href="#148">148</a> <b>loop</b> <b>do</b> 155<a class="l" name="149" href="#149">149</a> <b>case</b> <a href="/source/s?defs=STDIN" class="intelliWindow-symbol" data-definition-place="undefined-in-file">STDIN</a>.<b>getc</b> 156<a class="hl" name="150" href="#150">150</a> <b>when</b> <span class="s">?n</span> <span class="c"># new game</span> 157<a class="l" name="151" href="#151">151</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#reset" data-definition-place="defined-in-file">reset</a> 158<a class="l" name="152" href="#152">152</a> <b>when</b> <span class="s">?m</span> <span class="c"># mark</span> 159<a class="l" name="153" href="#153">153</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#mark" data-definition-place="defined-in-file">mark</a> 160<a class="l" name="154" href="#154">154</a> <b>when</b> <span class="s">?j</span> 161<a class="l" name="155" href="#155">155</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#down" data-definition-place="defined-in-file">down</a> 162<a class="l" name="156" href="#156">156</a> <b>when</b> <span class="s">?k</span> 163<a class="l" name="157" href="#157">157</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#up" data-definition-place="defined-in-file">up</a> 164<a class="l" name="158" href="#158">158</a> <b>when</b> <span class="s">?h</span> 165<a class="l" name="159" href="#159">159</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#left" data-definition-place="defined-in-file">left</a> 166<a class="hl" name="160" href="#160">160</a> <b>when</b> <span class="s">?l</span> 167<a class="l" name="161" href="#161">161</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#right" data-definition-place="defined-in-file">right</a> 168<a class="l" name="162" href="#162">162</a> <b>when</b> <span class="s">?\s</span> 169<a class="l" name="163" href="#163">163</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<b>open</b> 170<a class="l" name="164" href="#164">164</a> <b>when</b> <span class="s">?q</span>,<span class="s">?\C-c</span> <span class="c"># quit game</span> 171<a class="l" name="165" href="#165">165</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#quit" data-definition-place="defined-in-file">quit</a> 172<a class="l" name="166" href="#166">166</a> <b>break</b> 173<a class="l" name="167" href="#167">167</a> <b>end</b> 174<a class="l" name="168" href="#168">168</a> <b>if</b> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#over%3F" data-definition-place="defined-in-file">over?</a> 175<a class="l" name="169" href="#169">169</a> <b>if</b> <a href="/source/s?defs=STDIN" class="intelliWindow-symbol" data-definition-place="undefined-in-file">STDIN</a>.<b>getc</b> == <span class="s">?q</span> <b>then</b> <b>break</b> <b>end</b> 176<a class="hl" name="170" href="#170">170</a> <a href="/source/s?defs=bd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bd</a>.<a class="d intelliWindow-symbol" href="#reset" data-definition-place="defined-in-file">reset</a> 177<a class="l" name="171" href="#171">171</a> <b>end</b> 178<a class="l" name="172" href="#172">172</a> <b>end</b> 179<a class="l" name="173" href="#173">173</a><b>ensure</b> 180<a class="l" name="174" href="#174">174</a> <b>system</b>(<span class="s">"stty -raw echo"</span>) 181<a class="l" name="175" href="#175">175</a><b>end</b> 182<a class="l" name="176" href="#176">176</a><b>print</b> <span class="s">"\n"</span> 183<a class="l" name="177" href="#177">177</a><b>print</b> <span class="s">'<a href="http://example.com">http://example.com</a>'</span> 184<a class="l" name="178" href="#178">178</a><b>puts</b> <span class="s">"Last #{</span><a href="/source/s?defs=log_lines" class="intelliWindow-symbol" data-definition-place="undefined-in-file">log_lines</a><span class="s">} lines from #{</span><a href="/source/s?defs=logfn" class="intelliWindow-symbol" data-definition-place="undefined-in-file">logfn</a><span class="s">}:"</span> 185<a class="l" name="179" href="#179">179</a><b>print</b> <span class="s">"\n"</span> 186<a class="hl" name="180" href="#180">180</a>; 187<a class="l" name="181" href="#181">181</a>; 188<a class="l" name="182" href="#182">182</a></body> 189</html> 190