## Roman Numeral Generator

Hello all! So as you can read in some previous posts I have been working on a roman numeral ID method for my Simpossible game. The code is now finished! Previous posts were only inclusive up to the roman numeral for 20 but now it is complete, including numerals all the way up to 100! It took a while to perfect the method, but ALAS it is complete! I had lots of fun with this specific method as it posed some very interesting challenges utilizing the modulus operation. Ill paste the code and some output below! Enjoy!

``````    // Difficulty above 6
else if(difficulty > 6){

// Seeds and initializes random number
srand(time(0));
int randomNum = rand() % 100 + 10;

// Checks for base 50
if((randomNum % 50) == 0){

// Creates string for as many times as 50 goes into the number
for(int rep = 0; rep < (randomNum/50); rep++){

// Adds L to the string
number += "L";

// If the repetition is 1, the string will be cleared and "C" will be put instead
if(rep == 1){
number.clear();
number += "C";
}

}

// Outputs the number and takes in user's answer
cout << number << endl;

int temp;
cin >> temp;

if(temp == randomNum){

cout << endl;
}

else{

lives --;
cout << incorrectAnswer() << " You have " << lives << " lives left! " << endl << endl;

//returns false
return false;

}

}

// Checks to see if random number is less than 40
else if(randomNum < 40){

// Creates loop to iterate as many times as 10 goes into the random number
for(int rep = 0; rep < randomNum/10; rep++){

// adds an X to the string for each iteration
number += "X";
}

// If the number is 1 unit away from a base (aka 19, 29, 39)
if(((randomNum + 1) % 10) == 0){
number += "IX";
}

// If the number ends in a 5
else if((randomNum % 5) == 0){
number += "V";
}

// If the number ends in 6, 7, or 8
else if(((randomNum % 5) < 4) && ((randomNum % 10) > 5)){
number += "V";

// A loop that iterates for each remaining value when random is divided by 5
for(int rep = 0; rep < (randomNum % 5); rep++){

// Appends an I for each iteration
number += "I";
}
}

// If the number ends in a 4
else if(((randomNum + 1) % 5) == 0){
number += "IV";

}

// Oterwise, just adds Is for each unit random is above a base 10
else {

// Loop that iterates for each value that random number is above 10
for(int rep = 0; rep < (randomNum % 10); rep++){

// Appends an I to the string
number += "I";
}

}

// Outputs numeral and takes user's input
cout << number << endl;
int temp;

cin >> temp;

if(temp == randomNum){
cout << endl;
}

else{

lives --;
cout << incorrectAnswer() << " You have " << lives << " lives left! " << endl << endl;

//returns false
return false;
}

}

// If random is greater than 40 & less than 50
else if(randomNum >= 40 && randomNum < 50){

// Creates 49 in numerals if number is 49.. How whack is it that that's 49..!
if(randomNum == 49){

number += "XLIX";
}

// Creates 40 in numerals
else{

number += "XL";

// Appends a V if the number requires
if((randomNum - 40) >= 5){
number += "V";
}

// Adds Is for amount or remainder when divided by 5
for(int rep = 0; rep < (randomNum % 5); rep++){

number += "I";
}
}

// Outputs numeral and recieves users input
cout << number << endl;
int temp;

cin >> temp;

if(temp == randomNum){
cout << endl;
}

else {

lives --;
cout << incorrectAnswer() << " You have " << lives << " lives left! " << endl << endl;

//returns false
return false;

}

}

// Checks to see if random number is greater than 50
else if(randomNum > 50 && randomNum < 90){

number += "L";

// Creates loop to iterate as many times as 10 goes into the random number
for(int rep = 0; rep < randomNum/10; rep++){

// adds an X to the string for each iteration
number += "X";
}

// If the number is 1 unti away from a base (aka 19, 29, 39)
if(((randomNum + 1) % 10) == 0){
number += "IX";
}

// If the number ends in a 5
else if((randomNum % 5) == 0){
number += "V";
}

// If the number ends in 6, 7, or 8
else if((randomNum % 5) < 4){
number += "V";

// A loop that iterates for each remaining value when random is divided by 5
for(int rep = 0; rep < (randomNum % 5); rep++){

// Appends an I for each iteration
number += "I";
}
}

// If the number ends in a 4
else if(((randomNum + 1) % 5) == 0){
number += "IV";

}

// Otherwise, just adds Is for each unit random is above a base 10
else {

// Loop that iterates for each value that random number is above 10
for(int rep = 0; rep < (randomNum % 10); rep++){

// Appends an I to the string
number += "I";
}

}

// Outputs numeral and takes user's input
cout << number << endl;
int temp;

cin >> temp;

if(temp == randomNum){
cout << endl;
}

else{

lives --;
cout << incorrectAnswer() << " You have " << lives << " lives left! " << endl << endl;

//returns false
return false;
}

}

// If number is between 90 and 100
else{

// Creates 99 in numerals if number is 99.. How whack is it that that's 99..!
if(randomNum == 99){

number += "XCIX";
}

// Creates 90 in numerals
else{

number += "XC";

// Appends a V if the number requires
if((randomNum - 90) >= 5){
number += "V";
}

// Adds Is for amount or remainder when divided by 5
for(int rep = 0; rep < (randomNum % 5); rep++){

number += "I";
}
}

// Outputs numeral and recieves users input
cout << number << endl;
int temp;

cin >> temp;

if(temp == randomNum){
cout << endl;
}

else {

lives --;
cout << incorrectAnswer() << " You have " << lives << " lives left! " << endl << endl;

//returns false
return false;

}

}

}

return true;
}

``````

## Roman Numerals ID Method

Hello all! So I’ve been working more on my Simpossible game, and specifically on the roman numerals ID minigame I talked about in earlier posts. So, in short, I’ve been working with the modulus operator nonstop for a couple hours… But it’s been really fun! So far, it’s coming together well. The majority of my time I spent on devising just how I would turn regular numbers into roman numerals. I’ve done it mostly by using whats called the “modulus” operator (%). You can read more on that here, but I’ll explain the basis for anyone unfamiliar with programming basics. It’s an operator (Like plus, minus or multiply) which will return the remainder of the first number divided by the second. So, 17 % 5 = 2. This operator is used most frequently in creating bounds for the rand() function, or to find whether or not a number is even.

My use of this operator has been to find whether or not a roman numeral requires an “X” or a “V”. So, for example, I can use the equation 17%10 = 7, and from there determine the appropriate numeral is XVII.

Below is some output and the unfinished method. I hope you enjoy!

```/*

Roman Numeral ID

*/

bool romanNumerals(int difficulty){

// Start of game

// Initialize roman numeral string to be appended

string number;

cout &lt;&lt; "Hey, ID this Roman Numeral for me.?" &lt;&lt; endl;

sleep(3);

// Difficulties below or equal to 1
if(difficulty &lt;= 1){

// Seed &amp; initialize rand
srand(time(0));
int randomNum = rand()% 5;

// Ensures rand cant = 0
if (randomNum == 0) randomNum += 3;

// If rand is &lt; 4, the numeral will only consist of "I"
if(randomNum &lt; 4){

// Create the roman numeral up to 3
for(int rep = 0; rep &lt; randomNum; rep++){

number += "I";
}

// Output numeral
cout &lt;&lt; number &lt;&lt; endl;

int temp;
cin &gt;&gt; temp;

if (temp == randomNum){

cout &lt;&lt; endl;
}

else {

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}

}

// If rand = 4
else {

// Outputs 4 in Roman Numerals
cout &lt;&lt; "IV" &lt;&lt; endl;

int temp;
cin &gt;&gt; temp;

if(temp == 4){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}
}

// Difficulty &gt; 1 &amp;&amp; &lt; or equal to 5
else if(difficulty &gt; 1 &amp;&amp; difficulty &lt;= 5){

// seeds and initializes rand range 5 - 20
srand(time(0));
int randomNum = rand() % 20 + 6;

// Rand = 5
if(randomNum == 9){

// Output
cout &lt;&lt; "IX" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 9){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 14
else if(randomNum == 14){

// Output
cout &lt;&lt; "XIV" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 14){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 15
// IDK WHY but this wont work rn
else if(randomNum == 15){

// Output
cout &lt;&lt; "XV" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 15){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 19
else if(randomNum == 19){

// Output
cout &lt;&lt; "IXX" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 19){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 6 - 20
else{

// If rand is directly divisible by 10
if ((randomNum % 10) == 0){

//Create a string which properly represents rand with Xs
for (int rep = 0; rep &lt; (randomNum/10); rep++){

number += "X";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if(temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// If rand can be divided by 10 with a remainder less than 4
else if((randomNum % 10) &lt; 4){

//Starts numeral with a X
number += "X";

// Creates the random numeral
for(int rep = 0; rep &lt; (randomNum - 10); rep++){

number += "I";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// Input
int temp;
cin &gt;&gt; temp;

if (temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// If rand can be divided by 10 with a remaineder greater than 5
else if((randomNum % 10) &gt; 5){

// Starts numeral with a XV

number += "XV";

// Creates random numeral

for(int rep = 0; rep &lt; (randomNum - 15); rep++){

number += "I";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// Input
int temp;
cin &gt;&gt; temp;

if(temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// If rand is not divisible by 10 at all, aka less than 10
else if(randomNum &gt; 5 &amp;&amp; randomNum &lt; 9){

// Starts numeral with a V
number += "V";

// Creates the random numeral
for(int rep = 0; rep &lt; (randomNum - 5); rep++){

number += "I";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// Input
int temp;
cin &gt;&gt; temp;

if(temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

}
}

return true;
}
```

## Simpossible Personality

Hey all!

It’s my birthday! Therefore, I gave myself some time to work on my passion projects, such as this game, and even explore some old design documents which i’ll probably post about a little later today as well!

So a couple weeks ago I shared with you guys my game Simpossible in this post. Since the, I’ve been working pretty hard in school and all that, but I have had some time to work a little more on my game, and wanted to post to further include my audience on what makes this project really special to me!

The personality I’m trying to give this game is what I feel will make it more than just another text based game. I’m doing this in 2 main ways: Words of Wisdom and Words of Disappointment.

My Words of Wisdom are quirky little snippits that are included at the start of every new game, every upping in difficulty, and every correct answer, and  I hope to make them numerous enough that a player never sees the same one twice. They range from dumb little sayings and goofy interactions to actual advice and fun facts.

My Words of Disappointment are essentially the opposite. They’re dumb little snips of the “character” poking fun at, and antagonizing the player, in a very very softhearted fashion.

A great (and incredibly relevant) example of this approach being used is the new game Smash Brothers: Ultimate. In loading screens, tips, backgrounds, and simply entertaining text tidbits appear. They used the text to input personality into the game. My favorite example, pulling from my favorite game, is their background on Sheik. It goes something like: “Sheik is originally from The Legend of Zelda Ocarina of Time, released in 1996. Though her true identity is a mystery at the beginning, we soon found out that she was actually Ze- I won’t spoil it for you“. It’s small little insertions like that which give the game a personification, and that’s just one example of the many embedded within this game. It’s cool to see techniques that I believe very strongly in being used in such a successful franchise, such as Smash Bros.

You can see output of these lines in action on my earlier post about the game. It’s very simple, but effective and easy. I’ll probably end up adding an array of previously selected lines to ensure the diversity in the lines, and that the user doesn’t get the same one twice in a single game session, but for now I’ll share with you the code as it is:

```//Words of Disappointment

// Gives rand() a new seed
srand ( time(NULL) );

// Creates random int using rand()
int random = rand() % 16;

if(random == 0){
return "OUCH! I'm sorry, that's wrong... ";
}

if(random == 1){
return "SO CLOSE.... just kidding I really don't know.. ";
}

if(random == 2){
return "I believe in you! But maybe I shouldn't have that time... ";
}

if(random == 3){
return "You wouldve done awesome on that one, if task was to do terribly... ";
}

if(random == 4){
return "Well... You tried! ";
}

if(random == 5){
return "Nice one!! Just kidding, that's really wrong..";
}

if(random == 6){
return "Have you not been paying attention..?";
}

if(random == 7){
return "You're wronger than the word \"wronger\" sounds..";
}

if(random == 8){
return "Don't you know how long it took me to make this game?? The least you can do is get the answers correct!";
}

if(random == 9){
return "Close, but no cigar..";
}

if(random == 10){
return "OOF... That one hurt me too :(";
}

if(random == 11){
return "Remember Tom & Jerry..? You're really acting like Tom rightn now..";
}

if(random == 12){
return "Sometimes... effort just isn't enough..";
}

if(random == 13){
return "I wish I could help you... cause you really need it..";
}

if(random == 14){
return "Randomly generated generic response to your ignorance #120321: \"You embarass me\"";
}

if(random == 15){
return "Eat a can of spinnach.. or do something, just stop being wrong..";
}

else return "Well... That shouldn't have happened... but you're also incorrect.. ";
}

//Words of Wisdom
string wordsOfWisdom(){

// Gives rand() a new seed
srand ( time(NULL) );

// Creates random int using rand() from
int random = rand()%31;

//Random responses
if(random == 0){
return "Never look back.. You dont have time for that!";
}

if(random == 1){
return "Time is the one thing you can never get back... and you're wasting it!";
}

if(random == 2){
}

if(random == 3){
return "Don't overthink this..";
}

if(random == 4){
return "Lightning strikes the earth about 100 times every second... That's like 300 times since you started reading this..!";
}

if(random == 5){
return "Are you enjoying yourself?? Let me know! +1(805)231-1561";
}

if(random == 6){
return "Try listening to faster paced music maybe.?";
}

if(random == 7){
return "Open a window! Fresh air is good for you!";
}

if(random == 8){
return "Carrot cake is perhaps one of the best collabs we've ever seen.. it evolved from carrot pudding! Sounds much less appetizing..";
}

if(random == 9){
return "Cool game, huh?";
}

if(random == 10){
return "Theres billions of people in this world... your small mistakes really don't matter much!";
}

if(random == 11){
return "Can you do a cartwheel?? Show me!";
}

if(random == 12){
return "Don't trip chocolate chip.";
}

if(random == 13){
return "Simpossible because it's so simple... but still impossible... get it now?";
}

if(random == 14){
return "I hope some of these little words of wisdom have made you smile!";
}

if(random == 15){
return "You're wonderful!";
}

if(random == 16){
return "That was so quick I didn't even see your fingers move!";
}

if(random == 18){
return "Check out my mixtape: 11101101000110100";
}

if(random == 19){
return "Lo Hicimos!";
}

if(random == 20){
return "Don't copy and paste code kids! That's how bugs are spread!";
}

if(random == 21){
return "Every correct answer is another byte of RAM I consume!";
}

if(random == 22){
return "High levels of arousal are best for simple tasks, such as these! Check out Yerkes-Dodson Law!";
}

if(random == 23){
return "They did surgery.. on a grape!!! (This meme is probably long dead..)";
}

if(random == 24){
return "RIP all the hours you've spent on this game...";
}

if(random == 25){
return "Kanpai!";
}

if(random == 26){
return "Salud!";
}

if(random == 27){
return "Cheers!";
}

if(random == 28){
return "Skål!";
}

if(random == 29){
return "Spread love and acceptance, and the world may become a better place yet!!";
}

if(random == 30){
return "Read more Tolkien! (Not paid for by the Tolkien Trust).";
}

else return "Well... That shouldn't have happened!";
}

```

## Simpossible Initial Overview and Code

Hello there!

I haven’t been very active here these last few months, my apologies! I’ve been swamped with my classes. But all is well, classes are going really well for me, but the only downside is my free time to program and work on passion projects has been effectively consumed by the amount of work my classes have been requiring. However, as finals week approaches I have had a little more time to be working on a game which I started a few months back.

The game I’ve been working on I have titled Simpossible. It’s essentially a game of mini games, all done through text. It’s in C++, and is built entirely upon speed. The score increases with each quick minigame, and the faster a task is completed, the higher the score for that specific game. by quick, I mean very quick. The game will cut you off at 10 seconds, which is achievable at the start, but as difficulty of tasks increases, this time limit becomes a serious constraint.

A big thing I’ve been trying to do with this project is give the game a personality of it’s own. I’ll post more on that in the future, but as you look at output, take notice of the little, what I’ve called, words of wisdom and words of disappointment. So far, I’ve put in about 25 unique lines for both, but I would like to have it around 100 or so by the time I’ve finished the project, but as it’s extremely simple to add to, I just haven’t taken the time yet… IM BUSY!

So far, I’ve created only 4 minigames, but hope to come to about 10 by the time I am finished. Each round is comprised of 5 “events”, each one of them being a try at one of the minigames, randomly selected. The player has 3 lives, which are lost by incorrect answers. The punishment for not meeting the time constraint is no points for the event. The games so far include the following:

Math Game:

The simplest of the games to explain, the user is given a problem to solve and must answer the problem correctly. Starting with simple addition and eventually elevating to include all operations and order of operations. The challenge is I must keep it simple enough that most would be able to reasonably solve even the most difficult of these problems within 14 seconds at most. This is important because the game must remain competitive and fun even at the higher difficulties. I’ll post code at bottom, but heres some output:

Repeat After Me:

This game just creates a random string of letters that the user must replicate within the time limit. The letters are truly random, so as of now they are absolute gibberish… I have considered pairing this program with a file of the english lexicon and possibly just pulling random words from there, but I think that would be too easy for the player, and there’s something I really find fun and interesting about the output of completely random strings. As difficulty increases, the string is lengthened to add more nonsense. Heres some output, I’ll include some code at the bottom:

(looking at the output, it looks a little lame super fun! )

But I do promise it’s actually a lot of fun to play around with!

Let’s Dance:

Let’s dance is my favorite game I’ve implemented so far. It feeds you a series of directions and you have to respond to those directions one at a time, to replicate the idea of DDR. It’s actually a lot of fun. I had to resort to using the WASD keys as opposed to arrow keys, because I couldn’t find a way to make the arrows work for both MAC OS and Windows, but it doesn’t take away from the idea of things, or at least I don’t think. Here’s some output:

Roman Numeral Game:

The last game that I’ve just started working on implementing is a roman numeral identification game. It’s going to feed the user randomly generated roman numerals, and the player must translate them into the numbers we know and love. While simple at first, the game is going to go on to involve numbers which not everybody may be able to decipher. I’m still working on this game, and trying to emphasize playability, because I know this one could be a little tougher for some.

Here’s some code:

```/*

Math Game

*/

//Math Game
bool mathGame(int difficulty){

//Seeds Rand
srand ( time(NULL) );

/*

Difficulty 0 - 2

*/

if(difficulty <= 2){

//Generates vars & decides operation
int var1 = (rand() % 11) * difficulty;
int var2 = (rand() % 11) * difficulty;
int operation = rand() % 2;

if(operation == 0){

cout << var1 << " + " << var2 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

else return true;
}

//subtraction operation
else if(operation == 1){

cout << var1 << " - " << var2 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;                 sleep(3);                 return false;             }                          //Correct Answer             else return true;         }     }               /*               Difficulty 3 - 6            */               //Increase in difficulty     else if(difficulty > 2 && difficulty <= 6){

//Creates random vars & decides operation. The random vars increase in size as the difficulty goes up.
int var1 = (rand() % (20 + difficulty));
int var2 = (rand() % (20 + difficulty));
int var3 = (rand() % (20 + difficulty));
int operation = rand() % 2;

if(operation == 0){

cout << var1 << " + " << var2 << " + " << var3 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

else return true;
}

//subtraction operation
else if(operation == 1){

cout << var1 << " - " << var2 <<  " + " << var3 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;                 sleep(3);                 return false;             }                          //Correct Answer             else return true;                      }                                         }               /*            Difficulty 7 - 10            */               //Increase in difficulty     else if(difficulty > 6 && difficulty <= 10){

//Creates random vars & decides operation. The random vars increase in size as the difficulty goes up.
int var1 = (rand() % (20 + difficulty));
int var2 = (rand() % (20 + difficulty));
int var3 = (rand() % (20 + difficulty));
int operation = rand() % 3;

if(operation == 0){

cout << var1 << " + " << var2 << " + " << var3 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

else return true;
}

//subtraction operation
else if(operation == 1){

cout << var1 << " - " << var2 <<  " + " << var3 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

else return true;

}

//Multiplication Operation
else if(operation == 2){

//Lowers random vars for sake of doability
var1 -= 15;
var2 -= 15;

cout << var1 << " * " << var2 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;                 sleep(3);                 return false;             }                          //Correct             else return true;         }     }               /*            Difficulty 11 - 15            */               //Increase in difficulty     else if(difficulty > 10 && difficulty <= 15){

//Creates random vars & decides operation. The random vars increase in size as the difficulty goes up.
int var1 = (rand() % (20 + difficulty));
int var2 = (rand() % (20 + difficulty));
int var3 = (rand() % (20 + difficulty));
int operation = rand() % 4;

if(operation == 0){

cout << var1 << " + " << var2 << " + " << var3 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

else return true;
}

//subtraction operation
else if(operation == 1){

cout << var1 << " - " << var2 <<  " + " << var3 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

else return true;

}

//Multiplication Operation
else if(operation == 2){

//Lowers random vars for sake of doability
var1 -= 15;
var2 -= 15;
var3 -= 15;

cout << var1 << " * " << var2 << " * " << var3 << " = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

//Correct
else return true;
}

//PemDas Operation
else if(operation == 3){

var1 -= 15;

cout << var1 << "(" << var2 << " + " << var3 << ") = ";             cin >> answer;

lives--;
cout << incorrectAnswer() << " You have " << lives << " lives left." << endl << endl;
sleep(3);
return false;
}

//Correct
else return true;

}
}

return false;
}

```
```/*

Repeat After Me

*/

//Repeat After Me Game
bool repeatAfterMe(int difficulty){

//Basic instructions
cout << "Repeat after me!! " << endl;
sleep(2);

char letter;
string sentence;
int temp;

//initialize random num generator
srand (time(0));

//Loop to increase size of repeat after me by difficulty
for(int rep = 0; rep <= difficulty+3; rep++){

//generates random number
temp = rand() % 26;

//converts number to letter
letter = 'a' + temp;
sentence += letter;
}

//prints out the "sentence"
cout << sentence << endl;          //takes user's input     cin >> answer;

//compares the user's input to the specified string

else{

lives --;
cout << incorrectAnswer() << " You have " << lives << " lives left! " << endl << endl;

//returns false
return false;
}
}

```

## Unity Crash Destroys My Happiness

Well, shit… After spending a few days working on an order taking software based off of my job at In N Out, a Unity crash proved to be all it took for me to lose all progress. Since the software was only 1 scene, that scene has been completely wiped. Despite my good saving habits, and having exited out of Unity3D multiple times, and still having my project, this one crash seems to have completely wiped all my progress (except for my code). Everything carries a lesson and the lesson i’ve learned from this is after a Unity crash, to not re open Unity, but instead find out  of the automatic backups stored in the “temp” folder under assets. Save yourself time, & sanity, and learn from my mistakes.

All that aside, I still have some interesting code and was working with some interesting ways in which I could store & display an order in progress, as well as a completed order. Using a generic type “BurgerObject”, that take the specific type of burger as a string, and have the ingredients stored in a List, I am able to accurately recreate how order taking works across all In N Out store locations. In addition to this, using the buttons that I had placed across the scene to represent each item would add a new text to the screen, representing the burger/item added, adding it to the entirety of the order. I found it difficult to decide how I was going to best display the entire order, since the order is stored in a List and displaying a List seems to be pretty much undoable in C#, but found this way to be likely the most promising. Here’s some code (please know that this is not nearly completed, just posting what I had completed pre crash):

## Game Update: Tic Tac Toe

After finishing up my Tic Tac Toe AI, I was left wondering: “Is this bot really the best Tic Tac Toe competitor I can create?”, so I went to work towards another concept of AI to compete in my game versus the original bot. Below are details of the 2 bots, as well as a link to the .pdf showing the outcome of their 10,000 matchups.

CPU 1 is the original bot I created a few days back. The code can be accessed in the link above. This bot takes a unique approach every turn, excluding the final two turns. The first turn it will default to the middle box (spot 5), or, if that is occupied, the bottom right box (spot 9). From there it will place its next 2 pieces according to how it’s opponent is trying to play. If the opponent is aggressive in trying to get 3 in a row, it will play defensively. If the opponent is more lax in their approach, the bot will go for the win. The bot has every possible situation, and the appropriate response, hard coded into it’s programming for turns 2 & 3. Turns 4 & 5 the bot looks for any possible opportunity, by either player, to win the match, and places it’s piece in the spot that would complete the 3 in a row. If none can be found, it simply places in a random open space.

CPU 2 is the bot I created in an attempt to out play my previous bot. The bot’s moves are decided very basically on whether or not the bot has a chance to win. In a kind of “bogo sort” fashion, the bot will make it’s first move at complete random, since the first move is rather insignificant. From there it gauges the opponent’s move, decides whether or not the opponent has a chance to win (not by using specific spot numbers but instead the overall state of the board), and if so defends the move, and if not places it’s piece in the way it deems easiest to get a 3 in a row. This move is the repeated for the rest of the game.

In conclusion, as of now the original AI is by far the superior, but it would be preferable to decrease the overall number of draws, and perhaps make the bot more aggressive, resulting in more wins.

## Game Sample: Tic Tac Toe AI

Over the last few weeks I have been implementing a bot into my Tic Tac Toe program, allowing a single player to test their skills at tic tac toe, while also sharpening my skills in regards to writing AI. The bot has proven to be a somewhat tedious, but very successful attempt at Artificial Intelligence. After many hours of testing, and improvising (and nearly 2000 lines of code), I believe it to be unbeatable… while I’m sure there is a flaw in there somewhere, I am unable to find it. I will continue to improvise and improve the bot, but for the time being, it is completed! Here is some gameplay (Just a note: the bot always plays as player 2 (O)):

```//
//  main.cpp
//  Tic Tac Toe
//
//  Created by Aidan Takami on 3/8/18.
//

#include
#include

using namespace std;

//Array to represent the spots on the board
char spot[10] = {'o','1','2','3','4','5','6','7','8','9'};
char cpuChoices[5]{0,0,0,0,0};

int ifWon();
void singlePlayer();
void cpuTurn(int);
void board();
void clearBoard();
void clearCpu();
bool cpuChoicesContains(char);
int findSpot();

//Main method
int main()
{

cout << "\n\n\tTic Tac Toe\n\n";

//Allows player to play vs CPU or human

string temp;
cout << "Would you like to play with 2 players, or 1? (enter 1 or 2)" << endl;     cin >> temp;

if(temp == "1"){
singlePlayer();
}

start:

int player = 1,i = -1,choice;

char side, playOn;

//Game loop, which will continue while no player has won
while(i==-1){

//Draws the board
board();

//Deciphers which players turn it is, using the modulus operator
player=(player%2)?1:2;

//Intro text & takes players move
cout << "Player " << player << ", enter a number:  ";         cin >> choice;

//Decides the team that the current player is on (X's or O's)
side=(player == 1) ? 'X' : 'O';

//Will take the player's move and mark the correct box (if unoccupied) with the correct side
if (choice == 1 && spot[1] == '1')

spot[1] = side;
else if (choice == 2 && spot[2] == '2')

spot[2] = side;
else if (choice == 3 && spot[3] == '3')

spot[3] = side;
else if (choice == 4 && spot[4] == '4')

spot[4] = side;
else if (choice == 5 && spot[5] == '5')

spot[5] = side;
else if (choice == 6 && spot[6] == '6')

spot[6] = side;
else if (choice == 7 && spot[7] == '7')

spot[7] = side;
else if (choice == 8 && spot[8] == '8')

spot[8] = side;
else if (choice == 9 && spot[9] == '9')

spot[9] = side;

//If selected box is occupied
else
{
cout<<"Invalid move ";

//gives the same player another turn
player--;
cin.ignore();
cin.get();
}

//determines if the board contains a win or draw.
i=ifWon();

//Continues the play process
player++;
}

//If a player won, draws the board and announces who won
board();
if(i==1)

cout<<"Player "<<--player<<" wins! ";

//If draw, announces a draw
else
cout<<"==>\aGame draw";

//Gives players an option to play again
cout << " Would you like to play again? (y/n)" << endl;     cin >> playOn;

if(playOn == 'y' || playOn == 'Y' ){
clearBoard();
goto start;
}

else
exit(0);
}

//function that returns the result of the game

int ifWon()
{

//Game was won
if (spot[1] == spot[2] && spot[2] == spot[3])
return 1;
else if (spot[4] == spot[5] && spot[5] == spot[6])

return 1;
else if (spot[7] == spot[8] && spot[8] == spot[9])

return 1;
else if (spot[1] == spot[4] && spot[4] == spot[7])

return 1;
else if (spot[2] == spot[5] && spot[5] == spot[8])

return 1;
else if (spot[3] == spot[6] && spot[6] == spot[9])

return 1;
else if (spot[1] == spot[5] && spot[5] == spot[9])

return 1;
else if (spot[3] == spot[5] && spot[5] == spot[7])

return 1;

//Game was a draw
else if (spot[1] != '1' && spot[2] != '2' && spot[3] != '3'
&& spot[4] != '4' && spot[5] != '5' && spot[6] != '6'
&& spot[7] != '7' && spot[8] != '8' && spot[9] != '9')

return 0;

//Game still in progress
else
return -1;
}

//Function that draws the board
void board()
{

cout << endl << endl << endl;

//Prints each box of the board with the contents of the array properly alligned
cout << "Player 1 (X)  -  Player 2 (O)" << endl << endl << endl;
cout << "     |     |     " << endl;
cout << "  " << spot[1] << "  |  " << spot[2] << "  |  " << spot[3] << endl;
cout << "_____|_____|_____" << endl;
cout << "     |     |     " << endl;
cout << "  " << spot[4] << "  |  " << spot[5] << "  |  " << spot[6] << endl;
cout << "_____|_____|_____" << endl;
cout << "     |     |     " << endl;
cout << "  " << spot[7] << "  |  " << spot[8] << "  |  " << spot[9] << endl;
cout << "     |     |     " << endl << endl;
}

//Method to allow player to play versus a CPU
void singlePlayer(){

start:

int player = 1,i = -1,choice, round = 0;

char side, playOn;

//Game loop, which will continue while no player has won
while(i==-1){

//Deciphers which players turn it is, using the modulus operator
player=(player%2)?1:2;

//Draws the board for user
if(player == 1)
board();

//Intro text & takes players move
cout << "Player " << player << ", enter a number:  ";

if(player == 2){
cpuTurn(round);
cout << "CPU turn!" << endl;         }         else{                      cin >> choice;

//Decides the team that the current player is on (X's or O's)
side=(player == 1) ? 'X' : 'O';

//Will take the player's move and mark the correct box (if unoccupied) with the correct side
if (choice == 1 && spot[1] == '1')
spot[1] = side;

else if (choice == 2 && spot[2] == '2')

spot[2] = side;
else if (choice == 3 && spot[3] == '3')

spot[3] = side;
else if (choice == 4 && spot[4] == '4')

spot[4] = side;
else if (choice == 5 && spot[5] == '5')

spot[5] = side;
else if (choice == 6 && spot[6] == '6')

spot[6] = side;
else if (choice == 7 && spot[7] == '7')

spot[7] = side;
else if (choice == 8 && spot[8] == '8')

spot[8] = side;
else if (choice == 9 && spot[9] == '9')

spot[9] = side;

//If selected box is occupied
else
{
cout<<"Invalid move ";

//gives the same player another turn
player--;
cin.ignore();
cin.get();
}
}

//determines if the board contains a win or draw.
i=ifWon();

//Continues the play process
player++;
round++;
}

//If a player won, draws the board and announces who won
board();
if(i==1)

cout<<"Player "<<--player<<" wins! ";

//If draw, announces a draw
else
cout<<"==>\aGame draw";

//Gives players an option to play again
cout << " Would you like to play again? (y/n)" << endl;     cin >> playOn;

if(playOn == 'y' || playOn == 'Y' ){
clearBoard();
clearCpu();
goto start;
}

else
exit(0);

}

//AI to play against the player in single player mode
//Organized by turn.
void cpuTurn(int round){

//in the first round
if(round == 1){

//AI will try to get the middle of the board
if(spot[1] == 'X' || spot[2] == 'X' || spot[3] == 'X' || spot[4] == 'X'){
spot[5] = 'O';
cpuChoices[0] = '5';
}

else if(spot [6] == 'X' || spot [7] == 'X' || spot[8] == 'X' || spot[9] =='X'){
spot[5] = 'O';
cpuChoices[0] = '5';
}

//Otherwise, AI will go for spot 9
else{
spot[9] ='O';
cpuChoices[0] = '9';
}
}

//Second turn
if(round == 3){

//AI will decide based upon previous moves by both AI and user
if(spot[1] == 'X' && spot[2] == 'X'){
if(cpuChoices[0] == '5'){
spot[3] = 'O';
cpuChoices[1] = '3';
}
}

else if(spot[1] == 'X' && spot[3] == 'X'){
if(cpuChoices[0] == '5'){
spot[2] = 'O';
cpuChoices[1] = '2';
}
}

else if(spot[1] == 'X' && spot[4] == 'X'){
if(cpuChoices[0] == '5'){
spot[7] = 'O';
cpuChoices[1] = '7';
}
}

else if (spot[1] == 'X' && spot[5] == 'X'){
spot[3] = 'O';
cpuChoices[1] = '3';
}

else if(spot[1] == 'X' && spot[6] == 'X'){
if(cpuChoices[0] == '5'){
spot[2] = 'O';
cpuChoices[1] = '2';
}
}

else if(spot[1] == 'X' && spot[7] == 'X'){
if(cpuChoices[0] == '5'){
spot[4] = 'O';
cpuChoices[1] = '4';
}
}

else if(spot[1] == 'X' && spot[8] == 'X'){
if(cpuChoices[0] == '5'){
spot[3] = 'O';
cpuChoices[1] = '3';
}
}

else if(spot[1] == 'X' && spot[9] == 'X'){
if(cpuChoices[0] == '5'){
spot[2] = 'O';
cpuChoices[1] = '2';
}
}

else if(spot[2] == 'X' && spot[3] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[2] == 'X' && spot[4] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[2] == 'X' && spot[5] == 'X'){
spot[8] = 'O';
cpuChoices[1] = '8';
}

else if(spot[2] == 'X' && spot[6] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[2] == 'X' && spot[7] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[2] == 'X' && spot[8] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[2] == 'X' && spot[9] == 'X'){
if(cpuChoices[0] == '5'){
spot[3] = 'O';
cpuChoices[1] = '3';
}
}

else if(spot[3] == 'X' && spot[4] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[3] == 'X' && spot[5] == 'X'){
spot[7] = 'O';
cpuChoices[1] = '7';
}

else if(spot[3] == 'X' && spot[6] == 'X'){
if(cpuChoices[0] == '5'){
spot[9] = 'O';
cpuChoices[1] = '9';
}
}

else if(spot[3] == 'X' && spot[7] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[3] == 'X' && spot[8] == 'X'){
if(cpuChoices[0] == '5'){
spot[9] = 'O';
cpuChoices[1] = '9';
}
}

else if(spot[3] == 'X' && spot[9] == 'X'){
if(cpuChoices[0] == '5'){
spot[6] = 'O';
cpuChoices[1] = '6';
}
}

else if(spot[4] == 'X' && spot[5] == 'X'){
spot[6] = 'O';
cpuChoices[1] = '6';
}

else if(spot[4] == 'X' && spot[6] == 'X'){
if(cpuChoices[0] == '5'){
spot[9] = 'O';
cpuChoices[1] = '9';
}
}

else if(spot[4] == 'X' && spot[7] == 'X'){
if(cpuChoices[0] == '5'){
spot[1] = 'O';
cpuChoices[1] = '1';
}
}

else if(spot[4] == 'X' && spot[8] == 'X'){
if(cpuChoices[0] == '5'){
spot[9] = 'O';
cpuChoices[1] = '9';
}
}

else if(spot[4] == 'X' && spot[9] == 'X'){
if(cpuChoices[0] == '5'){
spot[3] = 'O';
cpuChoices[1] = '3';
}
}

else if(spot[5] == 'X' && spot[6] == 'X'){
spot[4] = 'O';
cpuChoices[1] = '4';
}

else if(spot[5] == 'X' && spot[7] == 'X'){
spot[3] = 'O';
cpuChoices[1] = '3';
}

else if(spot[5] == 'X' && spot[8] == 'X'){
spot[2] = 'O';
cpuChoices[1] = '2';
}

else if(spot[6] == 'X' && spot[7] == 'X'){
if(cpuChoices[0] == '5'){
spot[9] = 'O';
cpuChoices[1] = '9';
}
}

else if(spot[6] == 'X' && spot[8] == 'X'){
if(cpuChoices[0] == '5'){
spot[9] = 'O';
cpuChoices[1] = '9';
}
}

else if(spot[6] == 'X' && spot[9] == 'X'){
if(cpuChoices[0] == '5'){
spot[3] = 'O';
cpuChoices[1] = '3';
}
}

else if(spot[7] == 'X' && spot[8] == 'X'){
if(cpuChoices[0] == '5'){
spot[9] = 'O';
cpuChoices[1] = '9';
}
}

else if(spot[7] == 'X' && spot[9] == 'X'){
if(cpuChoices[0] == '5'){
spot[8] = 'O';
cpuChoices[1] = '8';
}
}

else if(spot[8] == 'X' && spot[9] == 'X'){
if(cpuChoices[0] == '5'){
spot[7] = 'O';
cpuChoices[1] = '7';
}
}

}

//third turn
//Most complex turn, most games are won or lost in this round
if(round == 5){

//Spots 1 & 2 taken first

if(spot[1] == 'X' && spot[2] =='X'){

if(spot[4] =='X'){
if(cpuChoicesContains('3') && cpuChoicesContains('5')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

}

else if(spot[5] == 'X'){
if(cpuChoicesContains('9') && cpuChoicesContains('6')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('3')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

}

else if(spot[6] == 'X'){
if(cpuChoicesContains('3')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

}

else if(spot[7] == 'X'){
if(cpuChoicesContains('4')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else{
spot[4] = 'O';
cpuChoices[2] = '4';
}

}

else if(spot[8] == 'X'){
if(cpuChoicesContains('3')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

}

else if(spot[9] == 'X'){
if(cpuChoicesContains('3')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

}

}

//Spots 1 & 3 taken first

else if(spot[1] == 'X' && spot[3] =='X'){

if(spot[4] =='X'){
if(cpuChoicesContains('2') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(!cpuChoicesContains('7')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7') && cpuChoicesContains('5')){
spot[2] = 'O';
cpuChoices[2] = '2';
}

}

else if(spot[5] == 'X'){
if(!cpuChoicesContains('9')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(!cpuChoicesContains('7')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else{
spot[2] = 'O';
cpuChoices[2] = '2';
}

}

else if(spot[6] == 'X'){
if(cpuChoicesContains('2') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('8') && cpuChoicesContains('5')){
spot[2] = 'O';
cpuChoices[2] = '2';
}

else if (!cpuChoicesContains('9')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if (cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[2] = 'O';
cpuChoices[2] = '2';
}

}

else if(spot[7] == 'X'){
if(cpuChoicesContains('2') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('8') && cpuChoicesContains('5')){
spot[2] = 'O';
cpuChoices[2] = '2';
}

else{
spot[4] = 'O';
cpuChoices[2] = '4';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('2') && cpuChoicesContains('5')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('3')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

}

else if(spot[9] == 'X'){
if(cpuChoicesContains('2') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('8') && cpuChoicesContains('5')){
spot[2] = 'O';
cpuChoices[2] = '2';
}
}

}

//Spots 1 & 4 taken first
else if(spot[1] == 'X' && spot[4] == 'X'){

if(spot[5] == 'X'){
if(!cpuChoicesContains('6')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('6')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}

else if(spot[6] == 'X'){
if(cpuChoicesContains('7') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('2') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('5')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[7] = 'O';
cpuChoices[2] = '7';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('7') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('2') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if (cpuChoicesContains('3') && cpuChoicesContains('5')){
spot[7] = 'O';
cpuChoices[2] = '7';
}
}

}

//Spots 1 & 5 taken first

else if(spot[1] == 'X' && spot[5] == 'X'){

if(spot[6] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('9')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('4')){
spot[8] = 'O';
cpuChoices[2] = '8';
}
}

else if(spot[7] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('9')){
spot[6] = 'O';
cpuChoices[2] = '6';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('9')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('2') && cpuChoicesContains('9')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}

}

//Spots 1 & 6 taken first

else if(spot[1] == 'X' && spot[6] == 'X'){

if(spot[7] == 'X'){
if(cpuChoicesContains('5') && cpuChoicesContains('2')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('3')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('4') && cpuChoicesContains('5')){
spot[6] = 'O';
cpuChoices[2] = 6;
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('5') && cpuChoicesContains('2')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}

else if(spot[9] == 'X'){
if(!cpuChoicesContains('3')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}

}

//Spots 1 & 7 taken first

else if(spot[1] == 'X' && spot[7] == 'X'){

if(spot[8] == 'X'){
if(cpuChoicesContains('5') && cpuChoicesContains('4')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[6] = 'O';
cpuChoices[2] = '6';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('5') && cpuChoicesContains('4')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('8') && cpuChoicesContains('5')){
spot[2] = 'O';
cpuChoices[2] = '2';
}
}
}

//Spots 1 & 8 taken first

else if(spot[1] == 'X' && spot[8] == 'X'){

if(spot[9] == 'X'){
if(!cpuChoicesContains('7')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}
}

//Spots 2 & 3 taken first
else if(spot[2] == 'X' && spot[3] == 'X'){

if(spot[4] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}
}

else if(spot[5] == 'X'){
if(cpuChoicesContains('7') && cpuChoicesContains('9')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('8')){
spot[7] = 'O';
cpuChoices[2] = '7';
}
}

else if(spot[6] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[7] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('6')){
spot[4] = 'O';
cpuChoices[2] = '4';
}
}
}

//Spots 2 & 4 taken first

else if(spot[2] == 'X' && spot[4] == 'X'){

if(spot[5] == 'X'){
if(cpuChoicesContains('8') && cpuChoicesContains('9')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('6')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}

else if(spot[6] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}
}

else if(spot[7] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = 1;
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = '7';
cpuChoices[2] = '7';
}
}
}

//Spots 2 & 5 taken first

else if(spot[2] == 'X' && spot[5] == 'X'){

if(spot[6] == 'X'){
if(cpuChoicesContains('8') && cpuChoicesContains('9')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('4') && cpuChoicesContains('9')){
spot[8] = 'O';
cpuChoices[2] = '8';
}
}

else if(spot[7] == 'X'){
if(cpuChoicesContains('9') && cpuChoicesContains('8')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('3')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

}
}

//Spots 2 & 6 taken first

else if(spot[2] == 'X' && spot[6] == 'X'){

if(spot[7] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = '1';
}

}

else if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}
}

//Spots 2 & 7 taken first

else if(spot[2] == 'X' && spot[7] == 'X'){

if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('8') && cpuChoicesContains('5')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

}
}

//Spots 2 & 8 taken first

if(spot[2] == 'X' && spot[8] == 'X'){

if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('3')){
spot[7] = 'O';
cpuChoices[2] = '7';
}
}
}

//Spots 3 & 4 taken first

else if(spot[3] == 'X' && spot[4] == 'X'){

if(spot[5] == 'X'){
if(cpuChoicesContains('9') && cpuChoicesContains('6')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('7') && cpuChoicesContains('9')){
spot[8] = 'O';
cpuChoices[2] = '8';
}
}

else if(spot[6] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = '1';
}

}

else if(spot[7] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}
}

else if (spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if (cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if (spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('6')){
spot[2] = 'O';
cpuChoices[2] = '2';
}
}
}

//Spots 3 & 5 taken first

else if(spot[3] == 'X' && spot[5] == 'X'){

if(spot[6] == 'X'){
if(cpuChoicesContains('7') && cpuChoicesContains('9')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('4') && cpuChoicesContains('9')){
spot[7] = 'O';
cpuChoices[2] = '7';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('9') && cpuChoicesContains('7')){
spot[2] = 'O';
cpuChoices[2] = '2';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('2')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

}
}

//Spots 3 & 6 taken first

else if(spot[3] == 'X' && spot[6] == 'X'){

if(spot[7] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = '1';
}

}

else if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}
}

//Spots 3 & 7 taken first

else if(spot[3] == 'X' && spot[7] == 'X'){

if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}
}
}

//Spots 3 & 8 taken first

else if(spot[3] == 'X' && spot[8] == 'X'){

if(spot[9] == 'X'){
if(cpuChoicesContains('5') && cpuChoicesContains('6')){
spot[4] = 'O';
cpuChoices[2] = '4';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('7')){
spot[4] = 'O';
cpuChoices[2] = '4';
}
}
}

//Spots 4 & 5 taken first

else if(spot[4] == 'X' && spot[5] == 'X'){

if(spot[7] == 'X'){
if(cpuChoicesContains('9') && cpuChoicesContains('6')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('3') && cpuChoicesContains('9')){
spot[6] = 'O';
cpuChoices[2] = '6';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('2') && cpuChoicesContains('9')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('6')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

}
}

//Spots 4 & 6 taken first

else if(spot[4] == 'X' && spot[6] == 'X'){

if(spot[7] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = '1';
}

}

else if(spot[9] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('5')){
spot[7] = 'O';
cpuChoices[2] = '7';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('1')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}
}

//Spots 4 & 7 taken first

else if(spot[4] == 'X' && spot[7] == 'X'){

if(spot[8] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[9] = 'O';
cpuChoices[2] = '9';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('7')){
spot[2] = 'O';
cpuChoices[2] = '2';
}

}
}

//Spots 4 & 8 taken first

else if(spot[4] == 'X' && spot[8] == 'X'){

if(spot[9] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('5')){
spot[7] = 'O';
cpuChoices[2] = '7';
}
}
}

//Spots 5 & 6 taken first

if(spot[5] == 'X' && spot[6] == 'X'){

if(spot[7] == 'X'){
if(cpuChoicesContains('4') && cpuChoicesContains('9')){
spot[3] = 'O';
cpuChoices[2] = '3';
}

else if(cpuChoicesContains('3') && cpuChoicesContains('9')){
spot[4] = 'O';
cpuChoices[2] = '4';
}
}

else if(spot[8] == 'X'){
if(cpuChoicesContains('4') && cpuChoicesContains('9')){
spot[2] = 'O';
cpuChoices[2] = '2';
}

else if(cpuChoicesContains('9') && cpuChoicesContains('5')){
spot[1] = 'O';
cpuChoices[2] = '1';
}

else if(cpuChoicesContains('2') && cpuChoicesContains('9')){
spot[4] = 'O';
cpuChoices[2] = '4';
}

}

else if(spot[9] == 'X'){
if(cpuChoicesContains('1') && cpuChoicesContains('5')){
spot[3] = 'O';
cpuChoices[2] = '3';
}
}
}

//Spots 5 & 7 taken first

if(spot[5] == 'X' && spot[7] == 'X'){

if(spot[8] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('9')){
spot[6] = 'O';
cpuChoices[2] = '6';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('9')){
spot[6] = 'O';
cpuChoices[2] = '6';
}

}
}

//Spots 6 & 7 taken first

if(spot[6] == 'X' && spot[7] == 'X'){

if(spot[8] == 'X'){
if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}
}

else if(spot[9] == 'X'){
if(cpuChoicesContains('3') && cpuChoicesContains('5')){
spot[8] = 'O';
cpuChoices[2] = '8';
}

else if(cpuChoicesContains('5') && cpuChoicesContains('9')){
spot[1] = 'O';
cpuChoices[2] = '1';
}

}
}
}

//Fourth turn
//AI will search for any possible 3 in a row by both bot & human, and complete that row
if(round == 7){
if((spot[1] == spot[2]) && spot[3] == '3'){
spot[3] = 'O';
}

else if((spot[4] == spot[5]) && spot[6] == '6'){
spot[6] = 'O';
}

else if((spot[7] == spot[8]) && spot[9] == '9'){
spot[9] = 'O';
}

else if((spot[2] == spot[3]) && spot[1] == '1'){
spot[1] = 'O';
}

else if((spot[5] == spot[6]) && spot[4] == '4'){
spot[4] = 'O';
}

else if((spot[8] == spot[9]) && spot[7] == '7'){
spot[7] = 'O';
}

else if((spot[1] == spot[3]) && spot[2] == '2'){
spot[2] = 'O';
}

else if((spot[4] == spot[6]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[7] == spot[9]) && spot[8] == '8'){
spot[8] = 'O';
}

else if((spot[1] == spot[4]) && spot[7] == '7'){
spot[7] = 'O';
}

else if((spot[2] == spot[5]) && spot[8] == '8'){
spot[8] = 'O';
}

else if((spot[3] == spot[6]) && spot[9] == '9'){
spot[9] = 'O';
}

else if((spot[1] == spot[7]) && spot[4] == '4'){
spot[4] = 'O';
}

else if((spot[2] == spot[8]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[3] == spot[9]) && spot[6] == '6'){
spot[6] = 'O';
}

else if((spot[4] == spot[7]) && spot[1] == '1'){
spot[1] = 'O';
}

else if((spot[5] == spot[8]) && spot[2] == '2'){
spot[2] = 'O';
}

else if((spot[6] == spot[9]) && spot[3] == '3'){
spot[3] = 'O';
}

else if((spot[1] == spot[5]) && spot[9] == '9'){
spot[9] = 'O';
}

else if((spot[3] == spot[5]) && spot[7] == '7'){
spot[7] = 'O';
}

else if((spot[1] == spot[9]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[3] == spot[7]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[5] == spot[9]) && spot[1] == '1'){
spot[1] = 'O';
}

else if((spot[5] == spot[7]) && spot[3] == '3'){
spot[3] = 'O';
}

//If no win is possible, AI will place marker in arbitrary posistion
else{
spot[findSpot()] = 'O';
}
}

//Fifth turn
//Exact same as 4th turn
if(round == 9){
if((spot[1] == spot[2]) && spot[3] == '3'){
spot[3] = 'O';
}

else if((spot[4] == spot[5]) && spot[6] == '6'){
spot[6] = 'O';
}

else if((spot[7] == spot[8]) && spot[9] == '9'){
spot[9] = 'O';
}

else if((spot[2] == spot[3]) && spot[1] == '1'){
spot[1] = 'O';
}

else if((spot[5] == spot[6]) && spot[4] == '4'){
spot[4] = 'O';
}

else if((spot[8] == spot[9]) && spot[7] == '7'){
spot[7] = 'O';
}

else if((spot[1] == spot[3]) && spot[2] == '2'){
spot[2] = 'O';
}

else if((spot[4] == spot[6]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[7] == spot[9]) && spot[8] == '8'){
spot[8] = 'O';
}

else if((spot[1] == spot[4]) && spot[7] == '7'){
spot[7] = 'O';
}

else if((spot[2] == spot[5]) && spot[8] == '8'){
spot[8] = 'O';
}

else if((spot[3] == spot[6]) && spot[9] == '9'){
spot[9] = 'O';
}

else if((spot[1] == spot[7]) && spot[4] == '4'){
spot[4] = 'O';
}

else if((spot[2] == spot[8]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[3] == spot[9]) && spot[6] == '6'){
spot[6] = 'O';
}

else if((spot[4] == spot[7]) && spot[1] == '1'){
spot[1] = 'O';
}

else if((spot[5] == spot[8]) && spot[2] == '2'){
spot[2] = 'O';
}

else if((spot[6] == spot[9]) && spot[3] == '3'){
spot[3] = 'O';
}

else if((spot[1] == spot[5]) && spot[9] == '9'){
spot[9] = 'O';
}

else if((spot[3] == spot[5]) && spot[7] == '7'){
spot[7] = 'O';
}

else if((spot[1] == spot[9]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[3] == spot[7]) && spot[5] == '5'){
spot[5] = 'O';
}

else if((spot[5] == spot[9]) && spot[1] == '1'){
spot[1] = 'O';
}

else if((spot[5] == spot[7]) && spot[3] == '3'){
spot[3] = 'O';
}

//If no win possible, AI will place marker in arbitrary posistion
else{
spot[findSpot()] = 'O';
}
}

}

//Method to clear the board & reset all values
void clearBoard(){

spot[1] = '1';
spot[2] = '2';
spot[3] = '3';
spot[4] = '4';
spot[5] = '5';
spot[6] = '6';
spot[7] = '7';
spot[8] = '8';
spot[9] = '9';

}

//Clears Array of CPU choices
void clearCpu(){
cpuChoices[0] = '0';
cpuChoices[1] = '0';
cpuChoices[2] = '0';
cpuChoices[3] = '0';
cpuChoices[4] = '0';
}

//Searches array of previous bot choices and returns true if bot has used that space
bool cpuChoicesContains(char value){
for(int rep = 0; rep < 5; rep++){
if(cpuChoices[rep] == value)
return true;
}

return false;
}

//Will find a spot for bot to place piece, for likely game will result in draw
int findSpot(){

if(spot[1] == '1') return 1;
if(spot[2] == '2') return 2;
if(spot[3] == '3') return 3;
if(spot[4] == '4') return 4;
if(spot[5] == '5') return 5;
if(spot[6] == '6') return 6;
if(spot[7] == '7') return 7;
if(spot[8] == '8') return 8;
if(spot[9] == '9') return 9;

return 0;
}

```

## Game Update: Tic Tac Toe AI

So over the past few weeks I have been working with Tic Tac Toe AI in an attempt integrate a bot into my Tic Tac Toe program, making it playable by just 1 person. The bot is coming along well, but through this process I have been reminded of the arduousness of creating AI. While the process has been incredibly fun, programming a bot to respond educatedly to every possible move made by a human is no small task. In addition to that, the bot must also take into account it’s own previous moves in order to construct the best, most likely to be successful, strategy.

To conquer this task I have been mapping every possible state of the tic tac toe board at every point of the game, taking into account the preset moves of the AI as well as every move that may be made by the human player. The mapping looks like this:

Using these notes I’m able to quickly assess which moves the bot should have programmed into itself, as well as which moves would never be necessary. For example, the bot will always try to go for the middle box (box 5) for it’s first move, but if that box is taken, it will default to the bottom right corner (box 9). Therefore, the bot will never encounter a situation in which the human player has both box 5 & box 9, so it does not need to have a response to that situation. While that is a very simple example, as the game progresses and the board becomes more complex, the number of situations which the bot could never face multiplies rapidly. Keeping track of these situations is crucial to creating clean, well organized code, as well as keeping the bot as efficient as possible. Below is some output from the unfinished bot. The bot should be finished and posted by early next week!

## Game Sample: Tic Tac Toe

Below is my attempt at a 2 player Tic Tac Toe game. It’s fairly simple, but very neatly done. I’m currently working on an AI to incorporate into the program as an option for single players. I will be sure to post when finished! Heres some output:

```//
//  main.cpp
//  Tic Tac Toe
//
//  Created by Aidan Takami on 3/8/18.
//

#include
using namespace std;

//Array to represent the spots on the board
char spot[10] = {'o','1','2','3','4','5','6','7','8','9'};

int ifWon();
void board();
void clearBoard();

//Main method
int main()
{

cout << "\n\n\tTic Tac Toe\n\n";
start:

int player = 1,i = -1,choice;

char side, playOn;

//Game loop, which will continue while no player has won
while(i==-1){

//Draws the board
board();

//Deciphers which players turn it is, using the modulus operator
player=(player%2)?1:2;

//Intro text & takes players move
cout << "Player " << player << ", enter a number:  ";         cin >> choice;

//Decides the team that the current player is on (X's or O's)
side=(player == 1) ? 'X' : 'O';

//Will take the player's move and mark the correct box (if unoccupied) with the correct side
if (choice == 1 && spot[1] == '1')

spot[1] = side;
else if (choice == 2 && spot[2] == '2')

spot[2] = side;
else if (choice == 3 && spot[3] == '3')

spot[3] = side;
else if (choice == 4 && spot[4] == '4')

spot[4] = side;
else if (choice == 5 && spot[5] == '5')

spot[5] = side;
else if (choice == 6 && spot[6] == '6')

spot[6] = side;
else if (choice == 7 && spot[7] == '7')

spot[7] = side;
else if (choice == 8 && spot[8] == '8')

spot[8] = side;
else if (choice == 9 && spot[9] == '9')

spot[9] = side;

//If selected box is occupied
else
{
cout<<"Invalid move ";

//gives the same player another turn
player--;
cin.ignore();
cin.get();
}

//determines if the board contains a win or draw.
i=ifWon();

//Continues the play process
player++;
}

//If a player won, draws the board and announces who won
board();
if(i==1)

cout<<"Player "<<--player<<" wins! ";

//If draw, announces a draw
else
cout<<"==>\aGame draw";

//Gives players an option to play again
cout << "Would you like to play again? (y/n)" << endl;     cin >> playOn;

if(playOn == 'y' || playOn == 'Y' ){
clearBoard();
goto start;
}

else
return 0;
}

//function that returns the result of the game

int ifWon()
{

//Game was won
if (spot[1] == spot[2] && spot[2] == spot[3])
return 1;
else if (spot[4] == spot[5] && spot[5] == spot[6])

return 1;
else if (spot[7] == spot[8] && spot[8] == spot[9])

return 1;
else if (spot[1] == spot[4] && spot[4] == spot[7])

return 1;
else if (spot[2] == spot[5] && spot[5] == spot[8])

return 1;
else if (spot[3] == spot[6] && spot[6] == spot[9])

return 1;
else if (spot[1] == spot[5] && spot[5] == spot[9])

return 1;
else if (spot[3] == spot[5] && spot[5] == spot[7])

return 1;

//Game was a draw
else if (spot[1] != '1' && spot[2] != '2' && spot[3] != '3'
&& spot[4] != '4' && spot[5] != '5' && spot[6] != '6'
&& spot[7] != '7' && spot[8] != '8' && spot[9] != '9')

return 0;

//Game still in progress
else
return -1;
}

//Function that draws the board
void board()
{

cout << endl << endl << endl;

//Prints each box of the board with the contents of the array properly alligned
cout << "Player 1 (X)  -  Player 2 (O)" << endl << endl << endl;
cout << "     |     |     " << endl;
cout << "  " << spot[1] << "  |  " << spot[2] << "  |  " << spot[3] << endl;
cout << "_____|_____|_____" << endl;
cout << "     |     |     " << endl;
cout << "  " << spot[4] << "  |  " << spot[5] << "  |  " << spot[6] << endl;
cout << "_____|_____|_____" << endl;
cout << "     |     |     " << endl;
cout << "  " << spot[7] << "  |  " << spot[8] << "  |  " << spot[9] << endl;
cout << "     |     |     " << endl << endl;
}

//Method to clear the board & reset all values
void clearBoard(){

spot[1] = '1';
spot[2] = '2';
spot[3] = '3';
spot[4] = '4';
spot[5] = '5';
spot[6] = '6';
spot[7] = '7';
spot[8] = '8';
spot[9] = '9';

}
```

## Writing Sample: The Forgotten Characters

Below are some of the character profiles I’ve written for one of my games “The Forgotten”. More can be read about the universe here.

User’s Character

Born after the election, the only life you have ever known is that of the Forgotten. Your life is a constant battle to remain unseen, to remain forgotten. You are only 23, but you are proof that your people still have hope for the future generations. You grew up underground. You’ve been outside one time, when you were 9 and your hideout was discovered by the Safety Force. Other than that, like most others, you have never dared to take such a chance. It was then, when you were 9, that you lost your parents. You have no brothers, no sisters. You were luckily taken in by your closest friend’s family, Teo. Since living with Teo’s family, however, you have learned to be very self sufficient. You often go off on your own in the tunnels to see what you can find. Even as you got older, you couldn’t help the curiosity. And that’s where we join our hero…

King Olii

King Olii is a very mysterious man. Some say he was born for the sole purpose to take the throne, a scam put on by the most powerful in all the 5 sisters, but most don’t buy into this nonsense. When he was young, King Olii attended a private school, and was one of the very few who were permitted to travel to Zaki for the sole purpose of studying the Gods. Those closest to Olii say that this was a major turning point in his life. He soon began to study Gaius, the first King of the 5 sisters. He fought his way into politics and soon found himself as one of the closest advisors to the King himself. However, the story gets murky here. The rapid decline of the King soon took place and Olii seemed to fall off the face of the earth for the 2 years which followed. When he returned into the eye of the public, it was to rejoice of the people. Not long after, the King passed away and it was time for the 4th election to take place. As fate had it, Olii was nominated to hold the position along with 2 others. While future Kings are often nominated by the King prior, this was not the case this time. Olii went on to win the election, along with the heart of the people. As the forgotten fled Olii, he let his wrath take hold of him, as is tradition. Buri was flooded, and all planets were plagued by the presence of Olii’s safety force and Bots. Olii has now ruled for 30 years. As King of the 5 sisters, he decides his own agenda. Olii has made some efforts to advance his society with the introduction of the Safety Patrol, and the enactment of many new laws, but his main purpose of his reign thus far has been to eliminate all of the forgotten, by any means he can.

King Gaius of Zaki

From what is recorded in the vast libraries of Arne, Gaius was a heroic man. He led the 5 sisters from turmoil after the assassination of the last of Old Kings, and fought off all competitors to the throne. As a revenge towards his competitors, he ordered all their supporters be run out of cities, murdered on the street, and exiled. His rule was one of triumph. He was able to keep all of the sisters content and within check, and rid the planets of most the forgotten. On only his home planet of Zaki were any of the Forgotten spared. He passed away young, but his reign is overall considered very successful.

Teo

Teo is an observant girl to say the very least. As part of the forgotten, she has never left her hideout, except once after a raid on the former hideout. She keeps to herself but notices all that goes on around her. Her family is very kind and very hopeful, but it is hard to tell if she retains the same thoughts. While she does put on a strong face, she doesn’t open up enough to anyone for you to truly be sure. You have known her all your life and she is around your age. You and her used to get into mischief together but now she has put that part of her life away. She is preparing to be a teacher at the school for the forgotten, and spends a lot of her time studying.

Dr. Bolin

Dr. Bolin is widely considered the leader within your hideout. Bolin is a very kind hearted man. He is best known to those around the hideout for his incredible generosity towards the youth of the community. Dr. Bolin is one of the older men in the hideout. He can often be found painting or drawing using some of the mud or chalk found in the tunnels. Not very much is known about his background, just that he was a pediatrician before the election. His wife was one of the many who fled to Buri after the election. Whether it’s luck or fate, Dr Bolin didn’t follow her that day and he has been hiding out ever since.

## Groups

The Forgotten

The Forgotten are the group that supported a losing party during the most recent election. As their name states, they wish to remain forgotten. The only hope for those who supported another party after an election is for their kids to survive long enough until the next election ensues and they are no longer the target of such fierce attacks. While most of the forgotten have given up, there is always a fair percent which keep hope. The forgotten are constantly pursued by most outside their community. It is a crime to help a forgotten, so even when people don’t pursue them, they are incredibly reluctant to even be friendly. There are communities of forgotten scattered all across the 5 sisters. They are often easily noticed by the dirty clothes they wear, and their overall state of cleanliness, but if this doesn’t give them away, all Bots and Safety Patrol members are able to access databases which store the identity of all the forgotten.

The Control

Very little is known about The Control. They have been present across the 5 sisters for thousands of years, but didn’t make their way into the spotlight until their assassination of King Gaius. Even after the event, no detective in all the 5 Sisters has been able to trace down any members involved. Their presence and involvement is often very debated amongst citizens. They strike in mysterious ways with very questionable motives at times. All that is known is there is very suspicious activity in Arne and many blame it on The Control.