Comment detail

2次元ランダムウォーク (Nested Flatten)

BASICで。グラフィック機能が組み込まれた言語の見せ所だと思って、アニメーション。同時にファイルにも書きます。

N88互換BASICで動作を確認。Microsoft BASIC系依存なので(仮称)十進BASICでは動きません。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
100 cls 3
110 x=320 : y=200 : t=0
120 open "c:\RandomWalk.dat" for output as #1
130 print #1, t; x; y
140 *loop
150   circle(x,y),2,0
160   if rnd(1)<0.5 then x=x+1 else x=x-1
170   if rnd(1)<0.5 then y=y+1 else y=y-1
180   t=t+1
190   circle(x,y),2,7
200   print #1, t; x; y
210   if inkey$<>"" then goto *quit
220   goto *loop
230 *quit
240   close #1

Index

Feed

Other

Link

Pathtraq

loading...