CatForce port to INT attempt
Posted: June 9th, 2023, 5:11 am
A failed attempt to modify CatForce to run any INT rule (it's currently hardcoded to Glimmering Garden). However it doesn't work for some reason...
Forums for Conway's Game of Life
https://conwaylife.com/forums/
Code: Select all
<!DOCTYPE html>
<html lang>
<head>
<title>MAPGen</title>
</head>
<style>
</style>
<body>
</body>
<script>
/*
MAPGen
SET(TRANSITION,VALUE) sets the transition TRANSITION (ex. B3y or S5e) to VALUE (1 for yes, the cell stays alive or 0 for no, it dies).
SETALL(TRANSITION,VALUE) acts similarly to SET but it sets ALL transitions in TRANSITION to VALUE (ex. SETALL("B3",1) would set all transitions in B3 to alive).
*/
let arr = new Array(512);
for(let i = 0; i < 512; i ++){
arr[i] = 0;
}
let Encode = function(string){
string = string.replaceAll(" ","").replaceAll("\n","");
let res = 0;
for(let i = 0; i < 9; i ++){
res += (+string[i]) * (2 ** (8 - i));
}
return res;
};
let Rot = function(string){
return string[6]+string[3]+string[0]+string[7]+string[4]+string[1]+string[8]+string[5]+string[2];
};
let Ref = function(string){
return string[2]+string[1]+string[0]+string[5]+string[4]+string[3]+string[8]+string[7]+string[6];
};
let Perms = function(string){
string = string.replaceAll(" ","").replaceAll("\n","");
return [
string,
Rot(string),
Rot(Rot(string)),
Rot(Rot(Rot(string))),
Ref(string),
Rot(Ref(string)),
Rot(Rot(Ref(string))),
Rot(Rot(Rot(Ref(string))))
];
}
let LOOKUP = {
"0":`
000
000
000
`,
"1e":`
010
000
000
`,
"1c":`
001
000
000
`,
"2c":`
101
000
000
`,
"2e":`
010
001
000
`,
"2k":`
010
000
001
`,
"2a":`
011
000
000
`,
"2i":`
010
000
010
`,
"2n":`
100
000
001
`,
"3c":`
101
000
001
`,
"3e":`
010
101
000
`,
"3k":`
010
100
001
`,
"3a":`
110
100
000
`,
"3i":`
111
000
000
`,
"3n":`
101
001
000
`,
"3y":`
101
000
010
`,
"3q":`
100
001
001
`,
"3j":`
001
001
010
`,
"3r":`
001
101
000
`,
"4c":`
101
000
101
`,
"4e":`
010
101
010
`,
"4k":`
011
100
001
`,
"4a":`
100
100
110
`,
"4i":`
110
000
110
`,
"4n":`
100
100
101
`,
"4y":`
101
000
011
`,
"4q":`
110
100
001
`,
"4j":`
010
101
100
`,
"4r":`
110
101
000
`,
"4t":`
100
101
100
`,
"4w":`
011
100
100
`,
"4z":`
110
000
011
`,
"5c":`
110
101
010
`,
"5e":`
111
000
101
`,
"5k":`
101
001
110
`,
"5a":`
111
100
100
`,
"5i":`
111
101
000
`,
"5n":`
111
001
010
`,
"5y":`
010
101
101
`,
"5q":`
110
100
011
`,
"5j":`
111
100
001
`,
"5r":`
111
000
011
`,
"6c":`
111
101
010
`,
"6e":`
111
100
101
`,
"6k":`
111
100
011
`,
"6a":`
111
100
110
`,
"6i":`
111
000
111
`,
"6n":`
110
101
011
`,
"7e":`
111
101
101
`,
"7c":`
111
101
110
`,
"8":`
111
101
111
`,
}
let SET = function(token,val){
if(token[0] != "B" && token[0] != "S"){
throw `Error: Token does not start with B or S.`;
}
let off = 0;
if(token[0] == "S"){
off = 16;
}
token = token.slice(1);
if(token in LOOKUP){
let perm = Perms(LOOKUP[token]);
for(let i = 0; i < 8; i ++){
arr[Encode(perm[i]) + off] = val;
}
return;
}
throw `Error: "${token}" does not exist.`;
}
let SETALL = function(token,val){
if(token[0] != "B" && token[0] != "S"){
throw `Error: Token does not start with B or S.`;
}
let off = 0;
if(token[0] == "S"){
off = 16;
}
if(+token[1] < 0 || +token[1] > 8){
throw `Error: Amt. of neighbors is invalid.`;
}
token = +token[1];
for(let i in LOOKUP){
if(+i[0] == token){
let perm = Perms(LOOKUP[i]);
for(let j = 0; j < 8; j ++){
arr[Encode(perm[j]) + off] = val;
}
}
}
}
SETALL("B3",1);
SET("B3e",0);
SETALL("S2",1);
SETALL("S3",1);
console.log(arr.join(", "));
</script>
</html>