Skip to content

Instantly share code, notes, and snippets.

@zeptometer
Created August 26, 2012 01:31
Show Gist options
  • Select an option

  • Save zeptometer/3472994 to your computer and use it in GitHub Desktop.

Select an option

Save zeptometer/3472994 to your computer and use it in GitHub Desktop.
//15*15のorigamiによるシミュレーション
a = [1,1,1,1,1,1]; //aのスポットは6個
b = [0,0,0,0,0,0,0]; //bのスポットは7個
k1=1;k2=1;kd=0.1; //平衡定数
y0=[3;2.9;0;0]; //各成分の初期値
deff("ydot=f(x,y)",..
"ydot=[y(1)*(k1/(1+y(1)+2*y(3))-kd);y(2)*(k1/(1+y(2)+2*y(4))-kd);..
y(2)*k2/(1+y(2))-y(3)*kd;y(1)*k2/(1+y(1))-y(4)*kd]");
Inc0=[0,15,0,0]';
Inc1=[15,0,0,0]';
z0=ode(y0,0,0:1:399,f);
y1=ode(y0,0,400,f);
z1=ode(y1+Inc0,400,400:1:799,f);
y2=ode(y1+Inc0,400,800,f);
z2=ode(y2+Inc1,800,800:1:1200,f);
z=cat(2,z0,z1,z2);
ca=z(1,:);
cb=z(2,:);
//15*15のorigami
paper=[0,0,2,2,2,4,4,4,1,1,0,2,2,0,0;
0,0,0,1,4,0,0,2,2,2,1,1,2,2,0;
0,0,4,2,0,0,0,2,2,2,2,2,1,2,0;
0,4,0,2,0,0,0,2,2,2,2,2,2,1,0;
0,4,0,1,4,4,0,0,2,1,1,1,2,4,0;
4,0,4,2,0,0,4,0,4,2,2,2,4,0,4;
4,0,1,2,2,4,4,0,4,0,2,4,4,0,4;
4,0,4,0,4,4,4,0,4,0,4,4,4,0,4;
1,2,2,4,4,1,0,0,2,4,4,4,2,0,4;
1,0,0,2,0,2,2,0,2,0,0,2,0,2,4;
1,0,0,2,0,2,2,0,2,0,2,0,0,0,1;
1,0,0,2,0,2,0,2,2,0,2,2,2,2,1;
1,0,4,2,0,2,0,1,2,0,2,0,4,0,1;
1,1,2,4,0,2,4,0,1,0,2,4,0,4,1;
4,0,0,0,4,4,0,0,0,4,4,0,0,0,4;]
//高速化のためのおまじない
screen = gcf();
screen.pixmap = "on"
function disppict() //絵の表示
clf()
plot2d(0,0,-1,"010"," ",[0,0,17,17]); //キャンバスの決定
for i=1:15
for j=1:15
if modulo(paper(i,j),2)==1 then
xset("color",2)
xfarc(1.1*(j-1),1.1*(15-i)+1,1,1,0,360*64)
end
end
end
show_pixmap()
endfunction
for x=1:1200
//if modulo(x,50) == 0 then printf("x = %d\n",x)
//end
printf("x = %d\n",x)
for i=1:15
for j=1:15
k=rand()
if paper(i,j) == 2
if k<0.05*ca(x) then
paper(i,j)=3
end
elseif paper(i,j)==3
if k<0.1 then
paper(i,j)=2
end
elseif paper(i,j)==4
if k<0.05*cb(x) then
paper(i,j)=5
xset("color",2)
end
elseif paper(i,j)==5
if k<0.1 then
paper(i,j)=4
end
end
end
end
disppict()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment