Jump to content

Elementary cellular automaton/Random number generator: Difference between revisions

New post.
(New post.)
Line 318:
byte__m"0 i.10
220 197 147 174 117 97 149 171 100 151
</pre>
 
=={{header|Java}}==
<syntaxhighlight lang="java">
public class ElementaryCellularAutomatonRandomNumberGenerator {
 
public static void main(String[] aArgs) {
final int seed = 989898989;
evolve(seed, 30);
}
private static void evolve(int aState, int aRule) {
long state = aState;
for ( int i = 0; i <= 9; i++ ) {
int b = 0;
for ( int q = 7; q >= 0; q-- ) {
long stateCopy = state;
b |= ( stateCopy & 1 ) << q;
state = 0;
for ( int j = 0; j < BIT_COUNT; j++ ) {
long t = ( stateCopy >>> ( j - 1 ) ) | ( stateCopy << ( BIT_COUNT + 1 - j ) ) & 7;
if ( ( aRule & ( 1L << t ) ) != 0 ) {
state |= 1 << j;
}
}
}
System.out.print(" " + b);
}
System.out.println();
}
private static final int BIT_COUNT = 64;
 
}
</syntaxhighlight>
{{ out }}
<pre>
231 223 191 126 253 251 247 239 223 191
</pre>
 
871

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.