<?php
//移動回数
define('LOOP', 10);

//初期位置
$pos[0] = array('x' => 0, 'y' => 0);

for($time = 1; $time <= LOOP; $time++){
	$rad = deg2rad(mt_rand()%360);
	$x = $pos[$time-1]['x'] + cos($rad);
	$y = $pos[$time-1]['y'] + sin($rad);
	$pos[$time] = array('x' => $x, 'y' => $y);
}

foreach($pos as $key => $val){
	echo $key . " " . $val['x'] . " " . $val['y'] . " " . "\n";
}
