ASCII Random Walk Algorithm I would like some advice on improving/optimizing a small program I wrote. What it does is run a random walk on a torus manifold with 8 colors that loop around.
//RTM Test Using Random Walk Fractals, WIP
//Created by delta23
//This Code works on Minix, Unix, MacOSX, Linux
//This Code does not work on DOS or Windows (yet...)
//LICENSE OF CODE: CC0 - Public Domain

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;
#define TAPE_SIZE_X 672
#define TAPE_SIZE_Y 135
//Q!&gt;&lt;^V became &gt;&lt;^V : move and add
char inst [ 4 ] = { '&gt;', '&lt;', '^', 'V' } ; //can be used for debugging, and for inputting code later on, when it starts in a conditional loop perhaps
unsigned char tape [ TAPE_SIZE_X ] [ TAPE_SIZE_Y ] ;
int x = 336 ;
int y = 67 ;

void main ( void ) {
    system ( &quot;clear&quot; ) ; //clear screen
    srand ( time ( NULL ) ) ; //initialize random generator; TODO: port to C++ and use TRNG instead
    printf ( &quot;\e[?25l&quot; ) ; //disable cursor
    //TODO: Implement program input and conditional commands
    while ( 1 ) {
        switch ( inst [ rand ( ) % 4 ] ) { //MOVE
        case '&gt;' :
            x = x + 1 ;
        break ;
        case '&lt;' :
            x = x - 1 ;
        break ;
        case '^' :
            y = y + 1 ;
        break ;
        case 'V' :
            y = y - 1 ;
        break ;
        }
        if ( x &gt;= TAPE_SIZE_X ) x = 0 ; //TOROID CODES FOR OOB CURSOR
        else if ( x &lt; 0 ) x = TAPE_SIZE_X - 1 ;
        if ( y &gt;= TAPE_SIZE_Y ) y = 0 ;
        else if ( y &lt; 0 ) y = TAPE_SIZE_Y - 1 ;
        tape [ x ] [ y ] = tape [ x ] [ y ] + 1 ; // ADD 1
        if ( tape [ x ] [ y ] == 8 ) tape [ x ] [ y ] = 0 ;
        usleep ( 16667 ) ; // CAP SPEED TO 60FPS : 1/60 seconds = 16666.666... microseconds
        printf ( &quot;\33[%d;%dH&quot;, y, x ) ; //print @ cursor position
        switch ( tape [ x ] [ y ] ) { //Color Code for Mem
        case 0 :
            printf ( &quot;\x1B[40m &quot; ) ;
        break ;
        case 1 :
            printf ( &quot;\x1B[41m &quot; ) ;
        break ;
        case 2 :
            printf ( &quot;\x1B[43m &quot; ) ;
        break ;
        case 3 :
            printf ( &quot;\x1B[42m &quot; ) ;
        break ;
        case 4 :
            printf ( &quot;\x1B[46m &quot; ) ;
        break ;
        case 5 :
            printf ( &quot;\x1B[44m &quot; ) ;
        break ;
        case 6 :
            printf ( &quot;\x1B[45m &quot; ) ;
        break ;
        case 7 :
            printf ( &quot;\x1B[47m &quot; ) ;
        break ;
        }
        fflush ( stdout ) ; //flush stdout to prevent abnormal lag in printing to screen
    }
}
```
General Observations
Welcome to code review, nice first question. I would leave the licensing information out since stack exchange uses the Creative Commons Attribution-ShareAlike license.
The comment block at the top is rather helpful otherwise. FYI, this compiles fine on Windows 10 in Visual Studio 2019 Professional, but doesn't link (usleep() is undefined).
Some of the code is a little difficult to read as there is vertical crowding, you might want to insert a few blank lines inside main() between logic blocks.
Avoid Global Variables
It is very difficult to read, write, debug and maintain programs that use global variables. Global variables can be modified by any function within the program and therefore require each function to be examined before making changes in the code. In C and C++ global variables impact the namespace and they can cause linking errors if they are defined in multiple files. The answers in this stackoverflow question provide a fuller explanation.
Declare and Initialize the Variables Where They are Needed
In the original version of C variables needed to be declared at the top of the logic block where they were used, this is no longer true, declare them as necessary.
void main(void) {
    char inst[] =
    {
        '&gt;',
        '&lt;',
        '^',
        'V'
    };

    system(&quot;clear&quot;); //clear screen
    srand(time(NULL)); //initialize random generator; TODO: port to C++ and use TRNG instead
    printf(&quot;\e[?25l&quot;); //disable cursor
    //TODO: Implement program input and conditional commands

    unsigned char tape[TAPE_SIZE_X][TAPE_SIZE_Y];
    int x = 336;
    int y = 67;

    while (1) {
        ...
    }
}

Let the Compiler Do More of the Work
In the code example above there is no size defined for the array inst[], the compiler will fill this in based on the number of initialization values in the array. This makes it easier to write and maintain the code since the size doesn't need to be modified each time an instruction is added.
Magic Numbers
There are Magic Numbers in the main() function (336 and 67), it might be better to create symbolic constants for them to make the code more readable and easier to maintain. You already define symbolic constants for TAPE_SIZE_X and TAPE_SIZE_Y the code would be more readable and understandable if the initialization values for x and y used symbolic constants, in this case you could possibly make the initialization half of the tape size for x and y.
Numeric constants in code are sometimes referred to as Magic Numbers, because there is no obvious meaning for them. There is a discussion of this on stackoverflow.
Complexity
The function main() is too complex (does too much). As programs grow in size the use of main() should be limited to calling functions that parse the command line, calling functions that set up for processing, calling functions that execute the desired function of the program, and calling functions to clean up after the main portion of the program.
There is also a programming principle called the Single Responsibility Principle that applies here. The Single Responsibility Principle states:

that every module, class, or function should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by that module, class or function.

There are at least multiple functions in main().

//TODO: Implement program input and conditional commands
Set up the screen
The contents of the while (1) loop also seem to be multiple functions

Default Cases for switch Statements
While it isn't necessary in the current code, to prevent undefined behavior it is best to have a default case for every switch statement:
        switch (inst[rand() % 4]) { //MOVE
        case '&gt;':
            x = x + 1;
            break;
        case '&lt;':
            x = x - 1;
            break;
        case '^':
            y = y + 1;
            break;
        case 'V':
            y = y - 1;
            break;
        default :
            printf(&quot;Unknown instruction in switch\n&quot;);
            return 1;
        }

Possible Optimization
The second switch statement could be replaced with a table of values and that would improve performance.
        char* control_sequence[] =
        {
            &quot;\x1B[40m &quot;,
            &quot;\x1B[41m &quot;,
            &quot;\x1B[43m &quot;,
            &quot;\x1B[42m &quot;,
            &quot;\x1B[46m &quot;,
            &quot;\x1B[44m &quot;,
            &quot;\x1B[45m &quot;,
            &quot;\x1B[47m &quot;,
        };

        printf(&quot;%s&quot;, control_sequence[tape[x][y]]);
        fflush(stdout); //flush stdout to prevent abnormal lag in printing to screen

Readability and Maintainability
As mentioned in the general observations, this section of code is very hard to read and even harder to maintain:
        if (x &gt;= TAPE_SIZE_X) x = 0; //TOROID CODES FOR OOB CURSOR
        else if (x &lt; 0) x = TAPE_SIZE_X - 1;
        if (y &gt;= TAPE_SIZE_Y) y = 0;
        else if (y &lt; 0) y = TAPE_SIZE_Y - 1;
        tape[x][y] = tape[x][y] + 1; // ADD 1
        if (tape[x][y] == 8) tape[x][y] = 0;
        usleep(16667); // CAP SPEED TO 60FPS : 1/60 seconds = 16666.666... microseconds
        printf(&quot;\33[%d;%dH&quot;, y, x); //print @ cursor position

In languages like C, C++ or Java put action code such as x = 0; on its own line, preferably in braces, that makes the action easier to find, and with the braces easier to maintain by adding more statements later:
        if (x &gt;= TAPE_SIZE_X)
        {
            x = 0;
        }
        else if (x &lt; 0)
        {
            x = TAPE_SIZE_X - 1;
        }
        if (y &gt;= TAPE_SIZE_Y)
        {
            y = 0;
        }
        else if (y &lt; 0)
        {
            y = TAPE_SIZE_Y - 1;
        }

        tape[x][y] = tape[x][y] + 1; // ADD 1
        if (tape[x][y] == 8)
        {
            tape[x][y] = 0;
        }

        usleep(16667); // CAP SPEED TO 60FPS : 1/60 seconds = 16666.666... microseconds
        printf(&quot;\33[%d;%dH&quot;, y, x); //print @ cursor position

An example of how hard the original code is to read is that I missed the magic number 8 in the discussion of magic numbers above.