Search this site
Embedded Files
Skip to main content
Skip to navigation
Imperfect Permutable Elementary Cellular Automata
Home
2
3
4
5
6
7
8
Contact
Imperfect Permutable Elementary Cellular Automata
Home
2
3
4
5
6
7
8
Contact
More
Home
2
3
4
5
6
7
8
Contact
2.1
2.1: Perfect Permutable 3-space Ternary Midwise ECA
If an output is 0: draw " "
If output is 1: draw "
□
"
If output is 2: draw "
■
"
package com.flotow;
import java.util.Scanner;
import java.lang.Math.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.
in
);
String shape;
int r000;
int r001;
int r002;
int r010;
int r011;
int r012;
int r020;
int r021;
int r022;
int r100;
int r101;
int r102;
int r110;
int r111;
int r112;
int r120;
int r121;
int r122;
int r200;
int r201;
int r202;
int r210;
int r211;
int r212;
int r220;
int r221;
int r222;
int runs = 0;
int[] in = new int[1002];
for(int i = 0; i < in.length; i++){
if(i==250){
in[i] = 1;
}else{
in[i] = 0;
}
if(i==750){
in[i] = 2;
}
}
System.
out
.println("----------------------------------");
System.
out
.println("----------------------------------");
System.
out
.println("Enter number of iterations.");
System.
out
.println("----------------------------------");
System.
out
.println("----------------------------------");
int cycles = scan.nextInt();
int nums = 0;
System.
out
.println("Choose the rule set. For the following cases\nEnter 2 if the rule should output a 2\nEnter a 1 if it should output 1,\nEnter 0 to output 0.");
System.
out
.println("000 -> ");
r000 = scan.nextInt();
System.
out
.println("001 -> ");
r001 = scan.nextInt();
System.
out
.println("002 -> ");
r002 = scan.nextInt();
System.
out
.println("020 -> ");
r020 = scan.nextInt();
System.
out
.println("021 -> ");
r021 = scan.nextInt();
System.
out
.println("022 -> ");
r022 = scan.nextInt();
System.
out
.println("010 -> ");
r010 = scan.nextInt();
System.
out
.println("011 -> ");
r011 = scan.nextInt();
System.
out
.println("012 -> ");
r012 = scan.nextInt();
System.
out
.println("020 -> ");
r020 = scan.nextInt();
System.
out
.println("021 -> ");
r021 = scan.nextInt();
System.
out
.println("022 -> ");
r022 = scan.nextInt();
System.
out
.println("100 -> ");
r100 = scan.nextInt();
System.
out
.println("101 -> ");
r101 = scan.nextInt();
System.
out
.println("102 -> ");
r102 = scan.nextInt();
System.
out
.println("110 -> ");
r110 = scan.nextInt();
System.
out
.println("111 -> ");
r111 = scan.nextInt();
System.
out
.println("112 -> ");
r112 = scan.nextInt();
System.
out
.println("120 -> ");
r120 = scan.nextInt();
System.
out
.println("121 -> ");
r121 = scan.nextInt();
System.
out
.println("122 -> ");
r122 = scan.nextInt();
System.
out
.println("200 -> ");
r200 = scan.nextInt();
System.
out
.println("201 -> ");
r201 = scan.nextInt();
System.
out
.println("202 -> ");
r202 = scan.nextInt();
System.
out
.println("210 -> ");
r210 = scan.nextInt();
System.
out
.println("211 -> ");
r211 = scan.nextInt();
System.
out
.println("212 -> ");
r212 = scan.nextInt();
System.
out
.println("220 -> ");
r220 = scan.nextInt();
System.
out
.println("221 -> ");
r221 = scan.nextInt();
System.
out
.println("222 -> ");
r222 = scan.nextInt();
System.
out
.println("");
System.
out
.println("Starting...");
System.
out
.println("----------------------------------");
while (true) {
while (nums < cycles) {
if(runs == 0) {
Automata a = new Automata(in,r020, r021, r022, r000,r222,r221,r220,r212,r211,r210,r202,r201, r200, r122, r121, r120, r112, r102, r012, r002, r001, r010, r011, r100, r101, r110, r111);
nums++;
in = a.arrayOut();
}
if(runs>0){
if(runs == 1){
RandomizeArray r = new RandomizeArray();
in = r.out();
}
Automata b = new Automata(in,r020, r021, r022, r000,r222,r221,r220,r212,r211,r210,r202,r201, r200, r122, r121, r120, r112, r102, r012, r002, r001, r010, r011, r100, r101, r110, r111);
in = b.arrayOut();
nums++;
runs = 2;
}
}
runs = 1;
System.
out
.println("Go Again? ENTER 1 for yes or 0 for no.");
int again = scan.nextInt();
if(again != 1){
break;
}
System.
out
.println("----------------------------------");
System.
out
.println("----------------------------------");
System.
out
.println("Enter number of iterations:");
System.
out
.println("----------------------------------");
System.
out
.println("----------------------------------");
cycles = scan.nextInt();
nums = 0;
System.
out
.println("Choose the rule set. For the following cases\nEnter 2 if the rule should output a 2\nEnter a 1 if it should output 1,\nEnter 0 to output 0.");
System.
out
.println("000 -> ");
r000 = scan.nextInt();
System.
out
.println("001 -> ");
r001 = scan.nextInt();
System.
out
.println("002 -> ");
r002 = scan.nextInt();
System.
out
.println("020 -> ");
r020 = scan.nextInt();
System.
out
.println("021 -> ");
r021 = scan.nextInt();
System.
out
.println("022 -> ");
r022 = scan.nextInt();
System.
out
.println("010 -> ");
r010 = scan.nextInt();
System.
out
.println("011 -> ");
r011 = scan.nextInt();
System.
out
.println("012 -> ");
r012 = scan.nextInt();
System.
out
.println("020 -> ");
r020 = scan.nextInt();
System.
out
.println("021 -> ");
r021 = scan.nextInt();
System.
out
.println("022 -> ");
r022 = scan.nextInt();
System.
out
.println("100 -> ");
r100 = scan.nextInt();
System.
out
.println("101 -> ");
r101 = scan.nextInt();
System.
out
.println("102 -> ");
r102 = scan.nextInt();
System.
out
.println("110 -> ");
r110 = scan.nextInt();
System.
out
.println("111 -> ");
r111 = scan.nextInt();
System.
out
.println("112 -> ");
r112 = scan.nextInt();
System.
out
.println("120 -> ");
r120 = scan.nextInt();
System.
out
.println("121 -> ");
r121 = scan.nextInt();
System.
out
.println("122 -> ");
r122 = scan.nextInt();
System.
out
.println("200 -> ");
r200 = scan.nextInt();
System.
out
.println("201 -> ");
r201 = scan.nextInt();
System.
out
.println("202 -> ");
r202 = scan.nextInt();
System.
out
.println("210 -> ");
r210 = scan.nextInt();
System.
out
.println("211 -> ");
r211 = scan.nextInt();
System.
out
.println("212 -> ");
r212 = scan.nextInt();
System.
out
.println("220 -> ");
r220 = scan.nextInt();
System.
out
.println("221 -> ");
r221 = scan.nextInt();
System.
out
.println("222 -> ");
r222 = scan.nextInt();
System.
out
.println("");
System.
out
.println("Starting...");
System.
out
.println("----------------------------------");
}
}
}
class Automata{
int[] X = new int[1002];
int[] newX = new int[1002];
int r000;
int r001;
int r002;
int r010;
int r011;
int r012;
int r100;
int r101;
int r102;
int r110;
int r111;
int r112;
int r120;
int r121;
int r122;
int r200;
int r201;
int r202;
int r210;
int r211;
int r212;
int r220;
int r221;
int r222;
int r020;
int r021;
int r022;
public Automata(int[] X,int r020, int r021, int r022, int r000,int r222,int r221,int r220,int r212,int r211,int r210,int r202,int r201,int r200,int r122,int r121,int r120,int r112,int r102,int r012,int r002, int r001, int r010, int r011, int r100, int r101, int r110, int r111) {
this.r000 = r000;
this.r001 = r001;
this.r002 = r002;
this.r010 = r010;
this.r011 = r011;
this.r012 = r012;
this.r020 = r020;
this.r021 = r021;
this.r022 = r022;
this.r100 = r100;
this.r101 = r101;
this.r102 = r102;
this.r110 = r110;
this.r111 = r111;
this.r112 = r112;
this.r120 = r120;
this.r121 = r121;
this.r122 = r122;
this.r200 = r200;
this.r201 = r201;
this.r202 = r202;
this.r210 = r210;
this.r211 = r211;
this.r212 = r212;
this.r220 = r220;
this.r221 = r221;
this.r222 = r222;
this.X = this.newX;
for(int j = 0; j < X.length-1; j++){
if(X[j]==0){
System.
out
.print(" ");
}else if(X[j]==1){
System.
out
.print("□");
}else{
System.
out
.print("■");
}
}
for (int i = 0; i < X.length-1; i++) {
if (i == 0) {
if ((X[i + 1000] == 0 && X[i] == 0 && X[i + 1] == 0)) {
this.newX[i] = this.r000;
} else if ((X[i + 1000] == 0 && X[i] == 0 && X[i + 1] == 1)) {
this.newX[i] = this.r001;
}else if ((X[i + 1000] == 0 && X[i] == 0 && X[i + 1] == 2)) {
this.newX[i] = this.r002;
} else if ((X[i + 1000] == 0 && X[i] == 1 && X[i + 1] == 0)) {
this.newX[i] = this.r010;
} else if ((X[i + 1000] == 0 && X[i] == 1 && X[i + 1] == 1)) {
this.newX[i] = this.r011;
}else if ((X[i + 1000] == 0 && X[i] == 1 && X[i + 1] == 2)) {
this.newX[i] = this.r012;
} else if ((X[i + 1000] == 1 && X[i] == 0 && X[i + 1] == 0)) {
this.newX[i] = this.r100;
} else if ((X[i + 1000] == 1 && X[i] == 0 && X[i + 1] == 1)) {
this.newX[i] = this.r101;;
} else if ((X[i + 1000] == 1 && X[i] == 0 && X[i + 1] == 2)) {
this.newX[i] = this.r102;;
} else if ((X[i + 1000] == 1 && X[i] == 1 && X[i + 1] == 0)) {
this.newX[i] = this.r110;
} else if ((X[i + 1000] == 1 && X[i] == 1 && X[i + 1] == 1)) {
this.newX[i] = this.r111;
} else if ((X[i + 1000] == 1 && X[i] == 1 && X[i + 1] == 2)) {
this.newX[i] = this.r112;
} else if ((X[i + 1000] == 1 && X[i] == 2 && X[i + 1] == 0)) {
this.newX[i] = this.r120;
} else if ((X[i + 1000] == 1 && X[i] == 2 && X[i + 1] == 1)) {
this.newX[i] = this.r121;
} else if ((X[i + 1000] == 1 && X[i] == 2 && X[i + 1] == 2)) {
this.newX[i] = this.r122;
} else if ((X[i + 1000] == 2 && X[i] == 0 && X[i + 1] == 0)) {
this.newX[i] = this.r200;
} else if ((X[i + 1000] == 2 && X[i] == 0 && X[i + 1] == 1)) {
this.newX[i] = this.r201;
} else if ((X[i + 1000] == 2 && X[i] == 0 && X[i + 1] == 2)) {
this.newX[i] = this.r202;
} else if ((X[i + 1000] == 2 && X[i] == 1 && X[i + 1] == 0)) {
this.newX[i] = this.r210;
} else if ((X[i + 1000] == 2 && X[i] == 1 && X[i + 1] == 1)) {
this.newX[i] = this.r211;
} else if ((X[i + 1000] == 2 && X[i] == 1 && X[i + 1] == 2)) {
this.newX[i] = this.r212;
} else if ((X[i + 1000] == 2 && X[i] == 2 && X[i + 1] == 0)) {
this.newX[i] = this.r220;
} else if ((X[i + 1000] == 2 && X[i] == 2 && X[i + 1] == 1)) {
this.newX[i] = this.r221;
}else if ((X[i + 1000] == 2 && X[i] == 2 && X[i + 1] == 2)) {
this.newX[i] = this.r222;
}
} else if (i >= 1 && i <= 998) {
if ((X[i - 1] == 0 && X[i] == 0 && X[i + 1] == 0)) {
this.newX[i] = this.r000;
} else if ((X[i - 1] == 0 && X[i] == 0 && X[i + 1] == 1)) {
this.newX[i] = this.r001;
}else if ((X[i - 1] == 0 && X[i] == 0 && X[i + 1] == 2)) {
this.newX[i] = this.r002;
} else if ((X[i - 1] == 0 && X[i] == 1 && X[i + 1] == 0)) {
this.newX[i] = this.r010;
} else if ((X[i - 1] == 0 && X[i] == 1 && X[i + 1] == 1)) {
this.newX[i] = this.r011;
}else if ((X[i - 1] == 0 && X[i] == 1 && X[i + 1] == 2)) {
this.newX[i] = this.r012;
} else if ((X[i - 1] == 1 && X[i] == 0 && X[i + 1] == 0)) {
this.newX[i] = this.r100;
} else if ((X[i - 1] == 1 && X[i] == 0 && X[i + 1] == 1)) {
this.newX[i] = this.r101;;
} else if ((X[i - 1] == 1 && X[i] == 0 && X[i + 1] == 2)) {
this.newX[i] = this.r102;;
} else if ((X[i - 1] == 1 && X[i] == 1 && X[i + 1] == 0)) {
this.newX[i] = this.r110;
} else if ((X[i - 1] == 1 && X[i] == 1 && X[i + 1] == 1)) {
this.newX[i] = this.r111;
} else if ((X[i - 1] == 1 && X[i] == 1 && X[i + 1] == 2)) {
this.newX[i] = this.r112;
} else if ((X[i - 1] == 1 && X[i] == 2 && X[i + 1] == 0)) {
this.newX[i] = this.r120;
} else if ((X[i - 1] == 1 && X[i] == 2 && X[i + 1] == 1)) {
this.newX[i] = this.r121;
} else if ((X[i - 1] == 1 && X[i] == 2 && X[i + 1] == 2)) {
this.newX[i] = this.r122;
} else if ((X[i - 1] == 2 && X[i] == 0 && X[i + 1] == 0)) {
this.newX[i] = this.r200;
} else if ((X[i - 1] == 2 && X[i] == 0 && X[i + 1] == 1)) {
this.newX[i] = this.r201;
} else if ((X[i - 1] == 2 && X[i] == 0 && X[i + 1] == 2)) {
this.newX[i] = this.r202;
} else if ((X[i - 1] == 2 && X[i] == 1 && X[i + 1] == 0)) {
this.newX[i] = this.r210;
} else if ((X[i - 1] == 2 && X[i] == 1 && X[i + 1] == 1)) {
this.newX[i] = this.r211;
} else if ((X[i - 1] == 2 && X[i] == 1 && X[i + 1] == 2)) {
this.newX[i] = this.r212;
} else if ((X[i - 1] == 2 && X[i] == 2 && X[i + 1] == 0)) {
this.newX[i] = this.r220;
} else if ((X[i - 1] == 2 && X[i] == 2 && X[i + 1] == 1)) {
this.newX[i] = this.r221;
}else if ((X[i - 1] == 2 && X[i] == 2 && X[i + 1] == 2)) {
this.newX[i] = this.r222;
}
} else if (i == 999) {
if ((X[i - 1] == 0 && X[i] == 0 && X[i + 1] == 0)) {
this.newX[i] = this.r000;
} else if ((X[i - 1] == 0 && X[i] == 0 && X[0] == 1)) {
this.newX[i] = this.r001;
}else if ((X[i - 1] == 0 && X[i] == 0 && X[0] == 2)) {
this.newX[i] = this.r002;
} else if ((X[i - 1] == 0 && X[i] == 1 && X[0] == 0)) {
this.newX[i] = this.r010;
} else if ((X[i - 1] == 0 && X[i] == 1 && X[0] == 1)) {
this.newX[i] = this.r011;
}else if ((X[i - 1] == 0 && X[i] == 1 && X[0] == 2)) {
this.newX[i] = this.r012;
} else if ((X[i - 1] == 1 && X[i] == 0 && X[0] == 0)) {
this.newX[i] = this.r100;
} else if ((X[i - 1] == 1 && X[i] == 0 && X[0] == 1)) {
this.newX[i] = this.r101;;
} else if ((X[i - 1] == 1 && X[i] == 0 && X[0] == 2)) {
this.newX[i] = this.r102;;
} else if ((X[i - 1] == 1 && X[i] == 1 && X[0] == 0)) {
this.newX[i] = this.r110;
} else if ((X[i - 1] == 1 && X[i] == 1 && X[0] == 1)) {
this.newX[i] = this.r111;
} else if ((X[i - 1] == 1 && X[i] == 1 && X[0] == 2)) {
this.newX[i] = this.r112;
} else if ((X[i - 1] == 1 && X[i] == 2 && X[0] == 0)) {
this.newX[i] = this.r120;
} else if ((X[i - 1] == 1 && X[i] == 2 && X[0] == 1)) {
this.newX[i] = this.r121;
} else if ((X[i - 1] == 1 && X[i] == 2 && X[0] == 2)) {
this.newX[i] = this.r122;
} else if ((X[i - 1] == 2 && X[i] == 0 && X[0] == 0)) {
this.newX[i] = this.r200;
} else if ((X[i - 1] == 2 && X[i] == 0 && X[0] == 1)) {
this.newX[i] = this.r201;
} else if ((X[i - 1] == 2 && X[i] == 0 && X[0] == 2)) {
this.newX[i] = this.r202;
} else if ((X[i - 1] == 2 && X[i] == 1 && X[0] == 0)) {
this.newX[i] = this.r210;
} else if ((X[i - 1] == 2 && X[i] == 1 && X[0] == 1)) {
this.newX[i] = this.r211;
} else if ((X[i - 1] == 2 && X[i] == 1 && X[0] == 2)) {
this.newX[i] = this.r212;
} else if ((X[i - 1] == 2 && X[i] == 2 && X[0] == 0)) {
this.newX[i] = this.r220;
} else if ((X[i - 1] == 2 && X[i] == 2 && X[0] == 1)) {
this.newX[i] = this.r221;
}else if ((X[i - 1] == 2 && X[i] == 2 && X[0] == 2)) {
this.newX[i] = this.r222;
}
}
}
for(int k = 0; k < X.length-1; k++){
this.X[k] = this.newX[k];
}
System.
out
.println("");
}
public int[] arrayOut(){
return this.X;
}
}
class RandomizeArray{
int[] rando = new int[1002];
public RandomizeArray(){
for(int i = 0; i < 1002; i++){
if(i==250){
rando[i] = 1;
}else{
rando[i] = 0;
}
if(i==750){
rando[i] = 2;
}
}
}
public int[] out(){
return this.rando;
}
}
Report abuse
Page details
Page updated
Report abuse