-->
Marches aléatoires
10 étapes
Xmin = -0.2
Xmax = 10.2
Ymin = -10.2
Ymax = 10.2
traceG()
M = [0,0]
point(M)
function deplacement(P){
var n = 2*Math.floor(2*Math.random())-1
return [M[0]+1 , M[1]+n]
}
function marche(){
A = M
M = deplacement(M)
couleur = noir
point(M)
couleur = rouge
segment(A,M)
}
setInterval( function() {marche()},500 )
10 étapes répétées
Xmin = -0.2
Xmax = 10.2
Ymin = -10.2
Ymax = 10.2
traceG()
M2 = [0,0]
point(M2)
function deplacement(P){
var n = 2*Math.floor(2*Math.random())-1
return [P[0]+1 , P[1]+n]
}
function marche(){
if(M2[0] < 10){
A2 = M2
M2 = deplacement(M2)
transparence = 1
couleur = noir
point(M2)
transparence = 0
couleur = "rgba(255,0,0,0.2)"
segment(A2,M2)
}
else{
M2 = [0,0]
}
}
setInterval( function() {marche()},50 )
10 étapes
Xmin = -0.2
Xmax = 10.2
Ymin = -10.2
Ymax = 10.2
M3 = [0,0]
point(M3)
function deplacement(P){
var n = 2*Math.floor(2*Math.random())-1
return [P[0]+1 , P[1]+n]
}
for(var j = 0; j < 11; j = j+1){
n = -j
for(var i = 0; i < 11 ; i++){
couleur = "rgba(200,200,200,1)"
segment( [i+j,n], [i+j+1,n+1] )
segment( [i+j,-n], [i+j+1,-n-1] )
n = n+1
}
}
function marche(){
if(M3[0] < 10){
A3 = M3
M3 = deplacement(M3)
transparence = 1
couleur = noir
point(M3)
transparence = 0
couleur = "rgba(255,0,0,0.2)"
segment(A3,M3)
}
else{
M3 = [0,0]
}
}
setInterval( function() {marche()},50 )
50 étapes
Xmin = -1
Xmax = 51
Ymin = -51
Ymax = 51
M5 = [0,0]
//point(M5)
function deplacement(P){
var n = 2*Math.floor(2*Math.random())-1
return [P[0]+1 , P[1]+n]
}
for(var j = 0; j < 51; j = j+1){
n = -j
for(var i = 0; i < 50-j ; i++){
couleur = "rgba(200,200,200,1)"
segment( [i+j,n], [i+j+1,n+1] )
segment( [i+j,-n], [i+j+1,-n-1] )
n = n+1
}
}
function marche(){
if(M5[0] < 50){
A5 = M5
M5 = deplacement(M5)
transparence = 1
couleur = noir
//point(M5)
transparence = 0
couleur = "rgba(255,0,0,0.2)"
segment(A5,M5)
}
else{
M5 = [0,0]
}
}
setInterval( function() {marche()},50 )
100 étapes
Xmin = -2
Xmax = 102
Ymin = -102
Ymax = 102
M4 = [0,0]
//point(M4)
function deplacement(P){
var n = 2*Math.floor(2*Math.random())-1
return [P[0]+1 , P[1]+n]
}
for(var j = 0; j < 101; j = j+1){
n = -j
for(var i = 0; i < 100-j ; i++){
couleur = "rgba(200,200,200,1)"
segment( [i+j,n], [i+j+1,n+1] )
segment( [i+j,-n], [i+j+1,-n-1] )
n = n+1
}
}
function marche(){
if(M4[0] < 100){
A4 = M4
M4 = deplacement(M4)
transparence = 1
couleur = noir
//point(M4)
transparence = 0
couleur = "rgba(255,0,0,0.2)"
segment(A4,M4)
}
else{
M4 = [0,0]
}
}
setInterval( function() {marche()},50 )
1000 étapes
Xmin = -20
Xmax = 1020
Ymin = -1020
Ymax = 1020
M6 = [0,0]
//point(M6)
function deplacement(P){
var n = 2*Math.floor(2*Math.random())-1
return [P[0]+1 , P[1]+n]
}
peinture = "rgba(200,200,200,1)"
couleur = "rgba(200,200,200,1)"
transparence = 1
triangle([0,0],[1000,1000],[1000,-1000])
function marche(){
if(M6[0] < 1000){
A6 = M6
M6 = deplacement(M6)
transparence = 1
couleur = noir
//point(M6)
transparence = 0
couleur = "rgba(255,0,0,0.4)"
segment(A6,M6)
}
else{
M6 = [0,0]
}
}
setInterval( function() {marche()},50 )