[#6219] Ruby連載 第4話 — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

32 messages 1998/02/04
[#6221] Re: Ruby連載 第4話 — Shin-ichiro HARA <sinara@...> 1998/02/04

原です。

[#6224] Re: Ruby連載 第4話 — Yasunari Momoi <conan@...> 1998/02/04

ももちゃん@あるもにこすです.

[#6225] Re: Ruby連載 第4話 — matz@... (Yukihiro Matsumoto) 1998/02/04

まつもと ゆきひろです

[#6249] Re: i++ — 助田 雅紀 <masaki.suketa@...>

助田です。

33 messages 1998/02/04
[#6252] Re: i++ — gotoken@... (GOTO Kentaro) 1998/02/05

ことけんです

[#6255] Re: i++ — matz@... (Yukihiro Matsumoto) 1998/02/05

まつもと ゆきひろです

[#6260] Re: i++ — Yuji Shigehiro <sigehiro@...> 1998/02/05

しげひろです.

[#6314] RE: ruby's design policy (Re: I'd like to subscr ibe this ML) — 助田 雅紀 <masaki.suketa@...>

オブジェクト指向周辺をぶらぶらしている助田です。

11 messages 1998/02/06

[#6333] ruby 流に添削して下さい — nkon@...2.3web.ne.jp

13 messages 1998/02/07
[#6335] Re: ruby 流に添削して下さい — OZAWA Sakuro <crouton@...> 1998/02/07

さくです.

[#6372] ruby 1.1b7 released — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

24 messages 1998/02/10
[#6402] parsedate (Re: ruby 1.1b7 released) — WATANABE Hirofumi <watanabe@...> 1998/02/13

わたなべです.

[#6405] Re: parsedate (Re: ruby 1.1b7 released) — Tadayoshi Funaba <tadf@...> 1998/02/13

ふなばです。

[#6407] Re: parsedate (Re: ruby 1.1b7 released) — matz@... (Yukihiro Matsumoto) 1998/02/13

まつもと ゆきひろです

[#6373] call for scripts — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

133 messages 1998/02/10
[#6414] Re: call for scripts — Terutuoshi Kaneshiro <k-teru@...06.odn.ne.jp> 1998/02/14

金城です.

[#6428] Re: call for scripts — matz@... (Yukihiro Matsumoto) 1998/02/16

まつもと ゆきひろです

[#6448] Re: call for scripts — Terutuoshi Kaneshiro <k-teru@...06.odn.ne.jp> 1998/02/16

金城です.

[#6452] Re: call for scripts — matz@... (Yukihiro Matsumoto) 1998/02/17

まつもと ゆきひろです

[#6481] Re: call for scripts — Kikutani Makoto <kikutani@...> 1998/02/17

きくたに@ぷ〜たろ〜です。

[#6483] Re: call for scripts — OZAWA Sakuro <crouton@...> 1998/02/17

さくです.

[#6495] Re: call for scripts — WATANABE Hirofumi <watanabe@...> 1998/02/18

わたなべです.

[#6416] Re: call for scripts — shugo@... (Shugo Maeda) 1998/02/14

前田です。

[#6417] rgrep (Re: call for scripts) — shugo@... (Shugo Maeda) 1998/02/15

前田です。

[#6423] Re: rgrep (Re: call for scripts) — matz@... (Yukihiro Matsumoto) 1998/02/16

まつもと ゆきひろです

[#6612] Re: call for scripts — Tadayoshi Funaba <tadf@...> 1998/02/21

ふなばです。

[#6582] File::Separator on cygwin — OZAWA Sakuro <ozawa@...>

小澤さくです。

19 messages 1998/02/20
[#6583] Re: File::Separator on cygwin — WATANABE Hirofumi <watanabe@...> 1998/02/20

わたなべです.

[#6586] Re: File::Separator on cygwin — OZAWA Sakuro <ozawa@...> 1998/02/20

小澤さくです。

[#6591] ruby 1.1b8 released — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

32 messages 1998/02/20
[#6620] rbc.rb and binding — shugo@... (Shugo Maeda) 1998/02/22

前田です。

[#6629] Re: rbc.rb and binding — keiju@... (石塚圭樹 ) 1998/02/23

けいじゅ@日本ラショナルソフトウェアです.

[#6643] Re: rbc.rb and binding — shugo@... (Shugo Maeda) 1998/02/23

前田です。

[#6649] Re: rbc.rb and binding — keiju@... (石塚圭樹 ) 1998/02/23

けいじゅ@日本ラショナルソフトウェアです.

[#6650] Re: rbc.rb and binding — matz@... (Yukihiro Matsumoto) 1998/02/23

まつもと ゆきひろです

[#6667] JRI 0.5 worked (was Re: rbc.rb and binding) — OZAWA Sakuro <crouton@...> 1998/02/23

さくです.

[#6687] Re: JRI 0.5 worked (was Re: rbc.rb and binding) — shugo@... (Shugo Maeda) 1998/02/24

前田です。

[#6712] JRI and JDBC — OZAWA Sakuro <ozawa@...> 1998/02/24

小澤さくです。

[#6635] hello — WATANABE Tetsuya <tetsu@...>

渡辺哲也と申します。

15 messages 1998/02/23

[#6706] Re: Counter class — toyofuku@...

豊福@パパイヤです。

12 messages 1998/02/24

[#6735] Mutex/ConditionVariable/Queue — shugo@... (Shugo Maeda)

前田です。

27 messages 1998/02/24
[#6746] Re: Mutex/ConditionVariable/Queue — keiju@... (石塚圭樹 ) 1998/02/25

けいじゅ@日本ラショナルソフトウェアです.

[#6747] Re: Mutex/ConditionVariable/Queue — shugo@... (Shugo Maeda) 1998/02/25

前田です。

[#6752] Re: Mutex/ConditionVariable/Queue — senda@... 1998/02/25

From: shugo@po.aianet.ne.jp (Shugo Maeda)

[#6754] Re: Mutex/ConditionVariable/Queue — shugo@... (Shugo Maeda) 1998/02/25

前田です。

[#6756] Re: Mutex/ConditionVariable/Queue — senda@... 1998/02/25

From: shugo@po.aianet.ne.jp (Shugo Maeda)

[#6786] Re: Mutex/ConditionVariable/Queue — senda@...

From: shugo@po.aianet.ne.jp (Shugo Maeda)

33 messages 1998/02/26
[#6791] Re: Mutex/ConditionVariable/Queue — shugo@... (Shugo Maeda) 1998/02/26

前田です。

[#6794] Re: Mutex/ConditionVariable/Queue — shugo@... (Shugo Maeda) 1998/02/26

前田です。

[#6796] Re: Mutex/ConditionVariable/Queue — keiju@... (石塚圭樹 ) 1998/02/26

けいじゅ@日本ラショナルソフトウェアです.

[ruby-list:6616] Re: Game of Life

From: Noritsugu Nakamura <nnakamur@...>
Date: 1998-02-22 06:58:42 UTC
List: ruby-list #6616
中村です。

In article <199802211722.CAA01450@niagara.shiojiri.ne.jp> 
OZAWA Sakuro <crouton@po.shiojiri.ne.jp> wrote:
> 8-Queensはもう出てますし,あとは騎士巡回とハノイの塔で主要なパズルもの
> は網羅したことになりますかね.

Python 1.4 の Demo の下にあった hanoi.py を
コンバートしてみました。(オリジナリティー 0 )
だいたいは動いているように見えます。

  width, height = tk.getint(c['width']), tk.getint(c['height'])
をどうやったら良いのか分からなかったので、
値を直接入れてしまいました。

----------------------------------------------------------------------
#!/usr/local/bin/ruby
#
# Usage: tkhanoi [n [bitmapfile]]
#
# from 1998.02.22
# converted by Noritsugu Nakamura

require "tkclass"

class Tkhanoi
  def initialize(n, bitmap = nil)
	@n = n
	@c = Canvas.new
	@c.pack
	width = 300
	height = 211

	if bitmap
	  Bitmap.new(@c, width/2, height/2,
				 'bitmap' => bitmap,
				 'foreground' => 'blue')
	end

	pegwidth = 10
	pegheight = height / 2
	pegdist = width / 3
	x1, y1 = (pegdist - pegwidth) / 2, height * 1 / 3
	x2, y2 = x1 + pegwidth, y1 + pegheight
	@pegs = []
	for i in 0..2
	  p = Rectangle.new(@c, x1, y1, x2, y2, 'fill' => 'black')
	  @pegs.push(p)
	  x1, x2 = x1 + pegdist, x2 + pegdist
	end

	pieceheight = pegheight / 16
	maxpiecewidth = pegdist * 2 / 3
	minpiecewidth = 2 * pegwidth
	@pegstate = [[], [], []]
	@pieces = {}
	x1, y1 = (pegdist - maxpiecewidth) / 2, y2 - pieceheight - 2
	x2, y2 = x1 + maxpiecewidth, y1 + pieceheight
	dx = (maxpiecewidth - minpiecewidth) / (2 * [1 , @n -1].max)
	for i in 0..@n-1
	  p = Rectangle.new(@c, x1, y1, x2, y2, 'fill' => 'red')
	  @pieces[@n - i] = p
	  @pegstate[0].push(@n - i)
	  x1, x2 = x1 + dx, x2-dx
	  y1, y2 = y1 - pieceheight - 2, y2 - pieceheight - 2
	  Tk.root.update
#	  Tk.root.after(25)
	end
	run
	Tk.root.title("Hanoi")
	Tk.root.iconname("Hanoi")
	Tk.mainloop
  end
  def run
	while 1
	  hanoi(@n, 0, 1, 2)
	  hanoi(@n, 1, 2, 0)
	  hanoi(@n, 2, 0, 1)
	  hanoi(@n, 0, 2, 1)
	  hanoi(@n, 2, 1, 0)
	  hanoi(@n, 1, 0, 2)
	end
  end
  def report(i, a, b)
	@pegstate[a].pop
	p = @pieces[i]

	ax1, ay1, ax2, ay2 = @c.bbox(@pegs[a])
	while 1
	  x1, y1, x2, y2 = @c.bbox(p)
	  break if y2 < ay1
	  @c.move(p, 0, -1)
	  Tk.root.update
	end

	bx1, by1, bx2, by2 = @c.bbox(@pegs[b])
	newcenter = (bx1 + bx2) / 2
	while 1
	  x1, y1, x2, y2 = @c.bbox(p)
	  center = (x1 + x2) / 2
	  break if center == newcenter
	  if center > newcenter
		@c.move(p, -1, 0)
	  else
		@c.move(p, 1, 0)
	  end
	  Tk.root.update
	end

	pieceheight = y2 - y1 - 2
	newbottom = by2 - pieceheight * @pegstate[b].length - 2

	while 1
	  x1, y1, x2, y2 = @c.bbox(p)
	  break if y2 >= newbottom
	  @c.move(p, 0, 1)
	  Tk.root.update
	end

	@pegstate[b].push(i)
  end
  def hanoi(n, a, b, c)
	return if n <= 0
	hanoi(n-1, a, c, b)
	report(n, a, b)
	hanoi(n-1, c, b, a)
  end
end

if ARGV[0]
  n = ARGV[0].to_i
else
  n = 4
end

if ARGV[1]
  bitmap = ARGV[1]
  if bitmap[0,1] != '@'
	bitmap = '@' + bitmap
  end
else
  bitmap = nil
end

Tkhanoi.new(n, bitmap)


       中村典嗣  E-mail: nnakamur@mxq.meshnet.or.jp

In This Thread