6 #define bit(x) (1 << (x))
8 #define RULE 30 // 22 //
10 #define STEPS 64 // default steps
12 typedef unsigned char uint8_t;
13 typedef unsigned long long uint64_t;
15 // * * * **** ** * ** * * ***** *** * ** *** **
16 // 001000010000101111000110010110010010011111011101000110001110011
17 // uint8_t uni[ LEN ] = { 0b00100001, 0b00001011, 0b11000110, 0b01011001, 0b00100111, 0b11011101, 0b00011000, 0b11100110 };
19 uint8_t uni[ LEN ] = { 0b00011100, 0b00010011, 0b01010001, 0b11011110, 0b11100001, 0b01111000, 0b01110011, 0b10010110 };
21 void shift_left( uint8_t shift) {
29 uint8_t next = (uni[i] & 0x80) ? 1 : 0;
30 uni[i] = carry | (uni[i] << 1);
35 uni[ LEN - 1 ] |= carry ;
40 int main( int argc, char *argv[] ){
43 uint8_t i, tmp, triade;
44 uint8_t cnt=0, cntMax=0;
45 uint8_t stat[ 8*LEN ];
48 printf("CyberHeart evolution statistical analyzer. (◎)2021 by Dmitry Shalnoff, MIT\n");
49 printf("Usage: %s [number of steps] [p]\n", argv[0]);
50 printf("p:\tprint output state instead of statistics\n");
56 // ------------ cell automata -------------
59 printf("Steps: %llu, about %llu min (>%llu realtime days with 8 sec epoch delay) \n", j, (j*8)/(60), (j*8)/(60*60*24) );
66 if ( argc > 2 && argv[2][0] == 'p' ){
67 for (i = 0; i < LEN*8; i++) putchar( uni[ i/8 ] & bit( 7-(i%8) ) ? '*' : ' ');
68 // for (i = 0; i < LEN*8; i++) printf("%s", uni[ i/8 ] & bit( 7-(i%8) ) ? "▒▒" : " ");
72 for (i=0; i < LEN*8; i++){
74 // if ( argv[2] == 'p' ){
75 // put_char( uni[ i/8 ] & bit( 7-(i%8) ) );
76 // putchar( uni[ i/8 ] & bit( 7-(i%8) ) ? '*' : ' ');
79 if ( i > LEN * 8 - 4 ) triade = (tmp >> (LEN*8 - i) ); else triade = uni[ 0 ];
80 if ( RULE & bit(7 & triade) ) uni[ 0 ] |= bit(2); else uni[ 0 ] &= ~bit(2);
82 if ( (( uni[ 0 ] >> 2) & 0b11) == 0b00 ) {
98 shift_left( LEN*8-1 );
102 printf("cnt max: %d\n", cntMax );
104 for (i=0; i<=cntMax; i++) printf("%d: \t%d\n", i, stat[i]);