[#6862] Re: http_get.rb — 青山 和光 <PXN11625@...>
In-Reply-To: [ruby-list:6844] Re: http_get.rb
藤本です、こんにちは。
まつもと ゆきひろです
藤本です、こんにちは。
まつもと ゆきひろです
[#6889] lib/date.rb — Tadayoshi Funaba <tadf@...>
ふなばです。
まつもと ゆきひろです
[#6906] ruby's Icon ? — 藤本尚邦 / FUJIMOTO Hisakuni <hisa@...>
藤本です、こんにちは。
まつもと ゆきひろです
藤本です、こんにちは。
小澤さくです。
藤本です、こんにちは。
藤本です、こんばんは。
まつもと ゆきひろです
にしなです。
[#6918] manual 1.18b index — WATANABE Tetsuya <tetsu@...>
ruby-man-1.1b8 で、name タグがついているものを拾い集めて
まつもと ゆきひろです
小澤さくです。
まつもと ゆきひろです
小澤さくです。
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
前田です。
[#6929] Expect lib for ruby — nosuzuki@... (Norio Suzuki)
はじめまして。Perl から ruby or python に乗り換えようと考えている鈴木
[#6954] Re: ruby's Icon ? — nosuzuki@... (Norio Suzuki)
こんばんは。鈴木教郎です。
まつもと ゆきひろです
小澤さくです。
Thu, Mar 05, 1998 at 02:52:26PM +0900 において
まつもと ゆきひろです
原です。
[#6978] win32 版 ruby の getc について — ARIMA Yasuhiro <fit0298@...>
はじめまして。有馬と申します。
[#6983] ext POSIX.setsid — WATANABE Tetsuya <tetsu@...>
拡張ライブラリの作り方はこんな感じでいいでしょうか?
[#7004] gtk 0.99.4 and gtk module — Noritsugu Nakamura <nnakamur@...>
[#7008] builtin class inherit — TEI meiki <tei@...>
鄭です。
前田です。
まつもと ゆきひろです
鄭です。
まつもと ゆきひろです
[#7022] スレッドの終了待ち — densuke@...2.so-net.or.jp
佐藤@東邦大です。
[#7023] infinity — Tadayoshi Funaba <tadf@...>
ふなばです。
前田です。
けいじゅ@日本ラショナルソフトウェアです.
In message <199803091741.CAA05774.keiju@cupmail0.rational.com>
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
けいじゅ@日本ラショナルソフトウェアです.
In message <199803100359.MAA08628.keiju@cupmail0.rational.com>
けいじゅ@日本ラショナルソフトウェアです.
[#7083] about rbc — Kazuhisa YANAGAWA <katze@...>
rbc について二つ質問があります.
けいじゅ@日本ラショナルソフトウェアです.
けいじゅ@日本ラショナルソフトウェアです.
[#7107] calender-html.rb (Re: call for scripts) — Shin-ichiro HARA <sinara@...>
原です。
原です。
原です。
ごとけんです
原です。
原です。
[#7111] How to simulate Perl's DATA file handle — OZAWA Sakuro <crouton@...>
小澤さくです.
[#7126] do end or {} — Eiji-usagi-MATSUmoto <ematsu@...>
うさぎです
[#7145] gsub — WATANABE Tetsuya <tetsu@...>
gsub について
[#7147] each_char — TEI meiki <tei@...>
鄭です。
[#7153] please apply me — SHUDOH Kazuyuki <shudoh@...>
首藤といいます。
まつもと ゆきひろです
[#7192] I hope join. — Takashi Shimizu <simtak@...>
清水と申します。
[#7208] for in bsh — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
まつもと ゆきひろです
小澤さくです。
まつもと ゆきひろです
前田です。
けいじゅ@日本ラショナルソフトウェアです.
[#7222] jcode.rb — NAGAI Hidetoshi <nagai@...>
はじめまして.永井@知能.九工大と申します.
[#7232] final.rb error? — tateishi@...
立石です。
まつもと ゆきひろです
立石です。
In message <19980326102918.3974.qmail@localhost>
まつもと ゆきひろです
In message <199803270403.NAA00909@picachu.netlab.co.jp>
[#7244] [Q] test file1 -nt file2 — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
[#7257] TkScale.new(parent){to -0.1} — gotoken@... (GOTO Kentaro)
ごとけんです
[#7259] Socket#shutdown — keiju@... (Keiju ISHITSUKA)
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
[ruby-list:6920] Re: call for scripts
酒本です。
漢字、カラー対応の端末でないと遊べませんが、
マインスイーパのキャラクタ版です。
モデルとビューも使っていませんし、クラスにする
必要もないかもしれません。
でも、作るの楽しかったです。
息抜きにどうぞ。
おきて破りのエスケープシーケンスを使っています。
移動 :h j k l
マーク :m
newゲーム :n
終了 :q
開ける : スペース
#!/usr/local/bin/ruby
def clr
"\e[2J"
end
def pos(x,y)
"\e["+(y+1)+";"+(x*2+1)+"H"
end
def clrstr(id,s)
"\e["+id+"m"+s+"\e[0m"
end
class Board
def initialize(h,w,m)
@num=["・","1","2","3","4","5","6","7","8"]
@hi=h; @wi=w; @m=m
reset
end
def reset
srand()
@cx=0; @cy=0; @mc=@m
@data=Array.new(@hi*@wi)
@state=Array.new(@hi*@wi)
@total=@hi*@wi
0.upto(@hi*@wi-1){|i| @data[i]=0; @state[i]="NULL"; }
@m.times{
while true
j=rand(@hi*@wi-1)
if @data[j] == 0 then
@data[j]=1
break
end
end
}
print clr , pos(0,0)
0.upto(@hi-1){|y| print pos(0,y),clrstr(46,"・"*@wi)}
print pos(@cx,@cy)
end
def mark
if @state[@wi*@cy+@cx] !="NULL" then return end
print pos(@cx,@cy),clrstr(43,"★")
@state[@wi*@cy+@cx] = "MARK"
@mc=@mc-1;
@total=@total-1;
move
end
def open(x=@cx,y=@cy)
if @state[@wi*y+x] =="OPEN" then return 0 end
if @state[@wi*y+x]=="NULL" then @total=@total-1 end
if @state[@wi*y+x]=="MARK" then @mc=@mc+1 end
@state[@wi*y+x]="OPEN"
if fetch(x,y) == 1 then return 1 end
c= count(x,y)
print pos(x,y),clrstr(43,@num[c])
if c != 0 then move; return 0 end
if x > 0 && y > 0 then open(x-1,y-1) end
if y > 0 then open(x, y-1) end
if x < @wi-1 && y > 0 then open(x+1,y-1) end
if x > 0 then open(x-1,y) end
if x < @wi-1 then open(x+1,y) end
if x > 0 && y < @hi-1 then open(x-1,y+1) end
if y < @hi -1 then open(x,y+1) end
if x < @wi -1 && y < @hi -1 then open(x+1,y+1) end
move
end
def count(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 fetch(x,y)
if x < 0 then 0
elsif x >= @wi then 0
elsif y < 0 then 0
elsif y >= @hi then 0
else
@data[x*@wi+y]
end
end
def over(e)
0.upto(@hi-1){ |y|
print pos(0,y)
0.upto(@wi-1){ |x|
st=@state[y*@wi+x]
if (@cx==x) &&( @cy==y) && e==1 then
print "@@"
elsif st != "MARK" then
if fetch(x,y)==1 then
m= "●"
else
m= @num[count(x,y)]
end
print clrstr(45,m)
else
if fetch(x,y)==1 then
m= "●"
else
m= @num[count(x,y)]
end
print clrstr(43,m)
end
}
}
if e==1 then print pos(0,@hi),"*** OVER ***"
else print pos(0,@hi),"*** YOU WIN !! ***"
end
end
def down
if @cy < @hi-1 then @cy=@cy+1; move end
end
def up
if @cy > 0 then @cy=@cy-1; move end
end
def left
if @cx > 0 then @cx=@cx-1; move end
end
def right
if @cx < @wi-1 then @cx=@cx+1; move end
end
def move
print pos(0,@hi),"残り:",@mc,"/",@total," "
print pos(@cx,@cy)
end
def quit
print pos(0,@hi)
end
def remain
@mc+@total
end
end
bd=Board.new(10,10,10)
system("stty raw -echo")
while(c=getc).chr != "q"
case c.chr
when "n" # new game
bd.reset
when "m" # mark
bd.mark
when "j"
bd.down
when "k"
bd.up
when "h"
bd.left
when "l"
bd.right
when " "
if bd.open == 1 then bd.over(1)
if (c=getc).chr == "q" then break end
bd.reset
end
end
if bd.remain==0 then
bd.over(0)
if (c=getc).chr == "q" then break end
bd.reset
end
end
bd.quit
system("stty -raw echo")
print "\n"
--
酒本 定幸