diff options
Diffstat (limited to 'sample/mine.rb')
-rw-r--r-- | sample/mine.rb | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/sample/mine.rb b/sample/mine.rb index b9557d54a2..96af32e7e4 100644 --- a/sample/mine.rb +++ b/sample/mine.rb @@ -10,19 +10,19 @@ class Board end def put(x, y, col, str) pos(x,y); colorstr(43,str) - pos(0,@hi); print "$B;D$j(B:",@mc,"/",@total," " + pos(0,@hi); print "�Ĥ�:",@mc,"/",@total," " pos(x,y) end private :clr, :pos, :colorstr, :put - CHR=["$B!&(B","$B#1(B","$B#2(B","$B#3(B","$B#4(B","$B#5(B","$B#6(B","$B#7(B","$B#8(B","$B!z(B","$B!|(B","@@"] + CHR=["��","��","��","��","��","��","��","��","��","��","��","@@"] COL=[46,43,45] # default,opened,over def initialize(h,w,m) - # $B%2!<%`HW$N@8@.(B(h:$B=D!$(Bw:$B2#!$(Bm:$BGzCF$N?t(B) + # �������פ�����(h:�ġ�w:����m:���Ƥο�) @hi=h; @wi=w; @m=m reset end def reset - # $B%2!<%`HW$r(B($B:F(B)$B=i4|2=$9$k(B + # �������פ�(��)��������� srand() @cx=0; @cy=0; @mc=@m @over=false @@ -44,7 +44,7 @@ class Board pos(@cx,@cy) end def mark - # $B8=:_$N%+!<%=%k0LCV$K%^!<%/$r$D$1$k(B + # ���ߤΥ���������֤˥ޡ�����Ĥ��� if @state[@wi*@cy+@cx] != nil then return end @state[@wi*@cy+@cx] = "MARK" @mc=@mc-1; @@ -52,8 +52,8 @@ class Board put(@cx, @cy, COL[1], CHR[9]) end def open(x=@cx,y=@cy) - # $B8=:_$N%+!<%=%k0LCV$r%*!<%W%s$K$9$k(B - # $BGzCF$,$"$l$P%2!<%`%*!<%P!<(B + # ���ߤΥ���������֤��ץ�ˤ��� + # ���Ƥ�����Х����४���С� if @state[@wi*y+x] =="OPEN" then return 0 end if @state[@wi*y+x] == nil then @total=@total-1 end if @state[@wi*y+x] =="MARK" then @mc=@mc+1 end @@ -73,7 +73,7 @@ class Board pos(@cx,@cy) end def fetch(x,y) - # (x,y)$B$N0LCV$NGzCF$N?t(B(0 or 1)$B$rJV$9(B + # (x,y)�ΰ��֤����Ƥο�(0 or 1)���֤� if x < 0 then 0 elsif x >= @wi then 0 elsif y < 0 then 0 @@ -83,13 +83,13 @@ class Board end end def count(x,y) - # (x,y)$B$KNY@\$9$kGzCF$N?t$rJV$9(B + # (x,y)�����ܤ������Ƥο����֤� fetch(x-1,y-1)+fetch(x,y-1)+fetch(x+1,y-1)+ fetch(x-1,y) + fetch(x+1,y)+ fetch(x-1,y+1)+fetch(x,y+1)+fetch(x+1,y+1) end def over(win) - # $B%2!<%`$N=*N;(B + # ������ν�λ quit unless win pos(@cx,@cy); print CHR[11] @@ -100,8 +100,8 @@ class Board end end def over? - # $B%2!<%`$N=*N;%A%'%C%/(B - # $B=*N;=hM}$b8F$S=P$9(B + # ������ν�λ�����å� + # ��λ������ƤӽФ� remain = (@mc+@total == 0) if @over || remain over(remain) @@ -111,8 +111,8 @@ class Board end end def quit - # $B%2!<%`$NCfCG(B($B$^$?$O=*N;(B) - # $BHWLL$rA4$F8+$;$k(B + # �����������(�ޤ��Ͻ�λ) + # ���̤����Ƹ����� @hi.times do|y| pos(0,y) @wi.times do|x| @@ -122,19 +122,19 @@ class Board end end def down - # $B%+!<%=%k$r2<$K(B + # ��������� if @cy < @hi-1 then @cy=@cy+1; pos(@cx, @cy) end end def up - # $B%+!<%=%k$r>e$K(B + # ����������� if @cy > 0 then @cy=@cy-1; pos(@cx, @cy) end end def left - # $B%+!<%=%k$r:8$K(B + # ��������� if @cx > 0 then @cx=@cx-1; pos(@cx, @cy) end end def right - # $B%+!<%=%k$r1&$K(B + # ��������� if @cx < @wi-1 then @cx=@cx+1; pos(@cx, @cy) end end end |