Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3736d3c

Browse files
committed
Used | Bitwise OR and ^= (Bitwise XOR) operators in calculating next Elementary Generation over Addition + and Subtraction -=
1 parentcdd28e9 commit3736d3c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎Cellular-Automata/Elementary.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ export function getNextElementaryGeneration (generation, rule) {
8484
constRIGHT_DEAD=1// 001 in binary
8585

8686
for(leti=0;i<generation.length;i++){
87-
letneighborhoodValue=LEFT_DEAD+MIDDLE_DEAD+RIGHT_DEAD
87+
letneighborhoodValue=LEFT_DEAD|MIDDLE_DEAD|RIGHT_DEAD
8888

8989
if(i-1>0&&generation[i-1]===1){
90-
neighborhoodValue-=LEFT_DEAD
90+
neighborhoodValue^=LEFT_DEAD
9191
}
9292

9393
if(generation[i]===1){
94-
neighborhoodValue-=MIDDLE_DEAD
94+
neighborhoodValue^=MIDDLE_DEAD
9595
}
9696

9797
if(i+1<generation.length&&generation[i+1]===1){
98-
neighborhoodValue-=RIGHT_DEAD
98+
neighborhoodValue^=RIGHT_DEAD
9999
}
100100

101101
output[i]=ruleData[neighborhoodValue]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp