■
3/13
このままじゃ、動かないと思うけど。
pythonによる
[py:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import random
from turtle import *
# ウインドウをスクリーンの 75% x 50% にして、センタリング(startx=None, starty=None)。
setup(width=700, height=400, startx=0, starty=0)
up()
speed(100)
posi=[]
speed(1)
x=0
y=0
N=1000000
cnt0=0
cnt1=0
cnt2=0
cnt3=0
cnt=[cnt0,cnt1,cnt2,cnt3]
goto(x,y)
i=0
down()
for i in range(1,N):
p=random.random()
#print p
if(p<0.25):
x=x+5
y=y+5
goto(x,y)
cnt[0]=cnt[0]+1
elif(0.25<=p and p<0.5):
x=x+5
y=y-5
goto(x,y)
cnt[1]=cnt[1]+1
elif(0.5<=p and p<0.75):
x=x-5
y=y+5
goto(x,y)
cnt[2]=cnt[2]+1
else:
x=x-5
y=y-5
goto(x,y)
cnt[3]=cnt[3]+1
print cnt
exitonclick()
]