cellular automata
共 5 篇文章
gas model
%CA driver %HPP-gas clear all clf nx=52; %must be divisible by 4 ny=100; z=zeros(nx,ny); o=ones(nx,ny); sand = z ; sandNew = z; gnd = z ; diag1 = z; diag2 = z; and12 = z; or12 = z; sums = z; orsum = z; gnd(1:nx,ny-3)=1 ; % right ground line gnd(1:nx,3)=1 ; % left ground line gnd(nx/4:nx/2-2,ny/2)=1…
2013-05-29 22:41 · cellular automata
The game of life
%Conway's life with GUI clf clear all %============================================= %build the GUI %define the plot button plotbutton=uicontrol('style','pushbutton',... 'string','Run', ... 'fontsize',12, ... 'position',[100,400,50,20], ... 'callback', 'run=1;'); %define the stop button erasebutton…
2013-05-29 22:25 · cellular automata
Matlab and nonlinear dynamic
clear all; close all; %mu=0.5; mu=2.6:3e-4:4; x=0.6*ones(1,200); %for n=1:200 % x(n+1)=mu*x(n)*(1-x(n)); %end %plot(x(1,:),'k','markersize',10); %xlabel('n'); %ylabel('x(n)'); title('logistic(\mu=0.5)'); mu=2.6:3e-4:4; k=length(mu); x=linspace(0.6,0,k); for n=1:k x(n+1)=mu(n)*x(n)*(1-x(n)); plot(mu…
2013-05-29 22:02 · cellular automata
C++ and Langton's ant
// ant.cpp #include <iostream> using namespace std; int main(void){ int N=5; int **G= new int*[N]; for(int i=0;i<N;i++) G[i] = new int[N]; for(int j=0;j<N;j++){ for(int k=0;k<N;k++){ G[j][k]=1; } } int mold=3;int nold=2;int mnew=2;int nnew=2; int t=0;int T=40; while(t<T){ if((mnew<mold)&&(nnew==nol…
2013-05-29 21:26 · cellular automata
Java and Cellular Automata
import java.awt.Color; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; class JButtonGame extends JFrame implements ActionListener { private int nRows,nC…
2013-05-29 21:04 · cellular automata