Rotational Analysis
For some reason Pico-8 is the only environment that really beckons me to be creative. For the most part I really like the challenge of making something interestingly complex, with minimal code.
Controls:
Up and Down : Move through parameters
Left and Right : Change currently selected parameter by 10
X and C : Change currently selected parameter by 1
Left + Right : Reset current parameter to 0
X + C : Change between discrete steps [-] and continuous analogue steps [~]
There is a mouse position option [MSE] that is intended for use on touchscreens, turn it off at desired location to hold it in that position.
On top of the obvious messing about, I found that when AMP and RADB are in the high thousands, and are relatively close to each other in value, other different patterning emerge.
Hexagon in C
This program draws a hexagon for the user using various characters as the filler.
TODO:Add the feature for repeating horizontallyAdd Hollow fillerAdd the Ability to change the width of outlineAdd ability to make the outline and filler different chars.
"The force that makes the winter grow Its feathered hexagons of snow , and drives the bee to match at home Their calculated honeycomb, Is abacus and rose combined. An icy sweetness fills my mind , A sense that under thing and wing Lies, taut yet living , coiled, the spring." ---Jacob Bronowski (1908 -- 1974)
*/
#include <stdio.h>
int main(){ int i,j,k,l; // Counting Variables int shrink = 0; // Used to shrink the filling on the bottom half of hexagon int repeatNum = 0; // How many times a user wants to repeat the sequence int isRepeat = 0; // After running for the first time tells tells the loop to account for multiple instances int hexHeight = 16; // The amount in lines that user wants the height of the hexagon float characterPad = 2.5; //Because charcters dont take up extaly the same amount of pixels in height and width, this is used to get a close approximation for the sides of the heaxgon to be equal. float characterPadTemp = 0; // Temporarily holds the users prefered character padding. char userChar = '#'; // Users prefered character to be used for filler
printf("How tall in lines do you want your hexagon? \n"); scanf("%d",&hexHeight);
printf("What character would you like to use as filler? \n"); scanf(" %c",&userChar); printf("How many times do you want your hexagon repeated? \n"); scanf(" %d",&repeatNum);
printf("Enter the character height to width ratio (around 2 to 3), if you are not certain, type N and hit enter and the default value (2.5) will be used: \n"); scanf(" %f",&characterPadTemp);
//Use user input if they didnt choose the default value if (characterPadTemp != 'N' ){ characterPad = characterPadTemp; }
int midRow = hexHeight/2 + hexHeight%2; // Calculates how many rows it takes to get the middle, it also accounts for odd numbers int sideLen = ((midRow*2*(3^(-(1/2))))/(characterPad)); // Finds the side length using half the height of the hexagon approximately int hexWidth = 2 * sideLen; // Finds the max width of the hexagon. int growthRate = ((hexWidth-sideLen)/midRow); // Determines how fast the hexagon width should grow for each line
// Repeat as many times as the user dictates for (l = 0; l < repeatNum + 1; l++){ // Itterate through the height of the hexagon for (i = 0 - isRepeat; i <= hexHeight; i++) { // Is it on the growing or shrinking side? if (i > midRow){ shrink = shrink + 2; } //Pad in the characters for proper alignment for(k=0; k <= ((sideLen/2) - (growthRate*(i-shrink)/2)); ++k){ printf(" "); } //Draw the filling of the hexagon for (j = 0; j <= ((growthRate*(i-shrink) + sideLen)); j++) { printf("%c",userChar); } printf("\n"); } // Reset or set the values for the next run through shrink = 0; isRepeat = 1; } /* printf("Side length: %d\n",sideLen); printf("Mid Row: %d\n",midRow); printf("Hex Width: %d\n",hexWidth); printf("Growth Rate: %d\n",growthRate); */ return 0;}
Cocktail Sort in C
/*
Written as a part of Homework 2 on 10/4/2020 for Advanced Technical Progragraming taught by Larry Speakman at MSU Denver.
This program can either prompt a user for inputs of number, or randomly generate a seris of numbers. The sorts them.
"Out of clutter, find simplicity. From discord, find harmony. In the middle of difficulty lies opportunity."
-- Albert Einstein (1879 -- 1955)
*/
#include <stdio.h>
void tablePrint(int intArray[], int arrLength, int startPoint, int maxNum);
int randGen(int upper, int lower, int count, int seed);
int main(void) {
char userRepeat;
do {
int sortVis = 1; // Change this to 0 if you want to for go the graphics
int randFill = 1; // Changes this to 1 if you want the array to auto fill itself with random numbers
int randMax = 43; //Upper limit of the random number generator
int randMin = 1; //Lower limit of the random number generator.
int randSeed = 1337; //If you need consistent results this see can be used.
int updateTime = 24700; //How ofthe the graphics update
int cyclesComplete = 0; //How many times the sorter has gone back and forth
int holdNum = 0; //Temporary variable for holding the users input
int maxInputs = 30; //Total number of numbers to be inputed and sorted
int startNum = 1; // How far into the array would you like to sort it.
int zeroCount = 0; // How many times has the user typed 0
int madeSwap = 0; // Tracks if the sort algorithms have swapped a number in this cycle
int sortMax = 1; //Tracks if the program is doing sorting the max values
int sortMin = 1; //Tracks if the program is doing sorting the min values
int notDoneSort = 1; // A boolean like variable that tells the program when it is done sorting.
int maxNum = 0; // Holds the biggest number found
int minNum = 0; // holds the smallest number found
int userInput[maxInputs]; // Array to hold the numbers to be processed
userInput[0] = 0; //Setting the first entry as zero, to prevent any uassigned variable issues
int userInputUnsorted[maxInputs]; // Array for the coppy of the input
int arrSize = (sizeof userInput / sizeof *userInput); // Used to pass to the print function so that it can properly print it.
//If you dont want to enter nubmers this setting can be turned on to generate random numbers.
if (randFill == 1){
for(int s = startNum; s <= maxInputs; s++){
userInput[s] = randGen(randMax, randMin, maxInputs, randSeed);
}
}
//Prompt user for input, if they enter a zero, tell them to enter again, count the zero inputs
else if (randFill == 0){
printf("Please enter %d inputs:\n",maxInputs);
for (int m = startNum; m <= maxInputs;){
do{
printf("Enter #%d number:", m);
scanf(" %d",&holdNum);
if (holdNum == 0){
printf("Enter a number other than 0\n");
zeroCount++;
}
else if (holdNum != 0 ){
userInput[m] = holdNum;
m++;
holdNum = 0;
}
} while (holdNum != 0);
}
}
//Copy unsorted data
for (int n = 0; n <= maxInputs; n++){
userInputUnsorted[n] = userInput[n];
}
//Coditioning before sort procedure.
int padLen = maxNum/2 + maxNum%2;
minNum = userInput[1];
//Sorting the data
do {
for (int p = startNum; p <= maxInputs;){
if (sortVis == 1){
printf("%*.20s\n",padLen+6,"Going Forward");
printf("%d\n",p);
printf("Min: %d & Max: %d & Cycles: %d\n",minNum,maxNum, cyclesComplete);
tablePrint(userInput, arrSize , 0, maxNum);
usleep(updateTime);
system("clear");
}
//Checking the larger numbers
if (userInput[p] > userInput[p+1] && p < maxInputs){
if (userInput[p] > maxNum){
maxNum = userInput[p];
}
userInput[0] = userInput[p+1];
userInput[p+1] = userInput[p];
userInput[p] = userInput[0];
madeSwap = 1;
}
else if(madeSwap == 0) {sortMax = 0;}
p++;
}
for (int p = maxInputs; p >= startNum;){
if (sortVis == 1){
printf("%*.20s\n",padLen+6,"Going Back");
printf("%d\n",p);
printf("Min: %d & Max: %d & Cycles: %d\n",minNum,maxNum,cyclesComplete);
tablePrint(userInput, arrSize , 0, maxNum);
usleep(updateTime);
system("clear");
}
//checking the smaller numbers
if (userInput[p] < userInput[p-1] && p >= startNum){
if (userInput[p] < minNum){
minNum = userInput[p];
}
userInput[0] = userInput[p-1];
userInput[p-1] = userInput[p];
userInput[p] = userInput[0];
madeSwap = 1;
}
else if (madeSwap == 0){sortMin = 0;}
p--;
}
//Is sorting done yet?
if (sortMax == 0 && sortMin == 0){
if (maxNum == 0){
maxNum = minNum;
}
notDoneSort = 0;
}
else{madeSwap = 0;}
//counting the cycles
cyclesComplete++;
} while (notDoneSort == 1);
//Print the entire information for the user.
padLen = maxNum/2 + maxNum%2;
printf("%*.20s\n",padLen+4,"Sorted");
tablePrint(userInput, arrSize , startNum, maxNum);
printf("%*.20s\n",padLen+4,"Unsorted");
tablePrint(userInputUnsorted, arrSize , startNum, maxNum);
printf("Zeros entered: %d\n",zeroCount);
printf("Min Number: %d\n",minNum);
printf("Max Number: %d\n",maxNum);
printf("Cycles completed: %d\n",cyclesComplete);
printf("Type N to quit, otherwise any other entry will repeat the program\n:");
scanf("%c", &userRepeat);
}while(userRepeat!='N');
}
//Cycles htrough an array with ints, and make a string of stars as long as the integer values
void tablePrint(int userArray[], int arrLength, int startPoint, int maxNum){
// Takes an array and prints stars for the value in each position
// Used for visualizing sorting algorythims
for (int k = 0; k <= maxNum+5; k++){
printf("-");
}
printf("\n");
for (int i = startPoint; i <= arrLength; i++ ){
int userNum = userArray[i];
printf("Pos#:%2d|%3d|",i,userNum);
for (int j = 1; j <= userNum; j++){
printf("*");
}
printf("\n");
}
for (int k = 0; k <= maxNum+5; k++){
printf("-");
}
printf("\n");
}
//Generates a random number
int randGen(int upper, int lower, int count, int seed){
int r;
int num;
//srand(seed);
for (r = 0; r < count; r++) {
num = (rand() %
(upper - lower + 1)) + lower;
}
return num;
}