#include <iostream>
#include <string>
#include <sstream>


using namespace std;

//++++++++++++++++++++++++++++++/ HIGH LOW GAME /+++++++++++++++++++++++++++++++//

void playersInput()
{


	int player1Input[7];
	cout << "enter 7 values between 1 and 10" << endl;
	cin >> player1Input[0] >> player1Input[1] >> player1Input[2] >> player1Input[3] >> player1Input[4] >> player1Input[5] >> player1Input[6];
	//tried using a for loop here but it didnt work, i think its because theres too many things in one funtion.
	system("CLS");
	cout << "first number is :" << player1Input[0] << "  " << endl;
	cout << "\n is player 1's next number higher or lower than the privious" << endl;
	int temp = -1;
	cout << " \n **MAKE YOUR GUESS** \n H = HIGHER \n  L = LOWER   \n" << endl;



	for (int i = 0; i < 7; i++)
	{

		int y = player1Input[temp];
		int x = player1Input[i];
		temp += 1;
		string guess;
		cout << "guess :";
		cin >> guess;



		if (x > y && guess == "H" || x < y && guess == "L")
		{
			cout << " ~~~ correct ~~~ \n" << endl;
			cout << "~~~ the number was  " << player1Input[i] << " ~~~ " << endl;

			if (player1Input[i] >= 7)
			{
				cout << "PLAYER		TWO		WINS" << endl;
			}

		}
		else
		{

			cout << "false " << endl;

			cout << "GAME OVER" << endl;

			cout << "player		one		WINS" << endl;
			//originally used an if statement, then used i+=8, then used break as its more appropriate.
			break;
		}
	}
}

int main(int argc, char**argv)
{
	playersInput();
	system("pause");
	return 0;
}


#include <iostream>
#include <string>
#include <sstream>
#include<conio.h>
#include <windows.h>


//++++++++++++++++++++++++++++++++++++++++++/ HIDDEN TRESSURE GAME \+++++++++++++++++++++++++++++++++++++++++++\\

using namespace std;


// this function is to register user names
string playerNames(string name, string playerNum)
{
	cout << "player " << playerNum << " please enter your name:  ";
	cin >> name;
	return name;
}


void player1Tressure(int tressureArray[3][2], string player1)
{
	string arrayXY[6] = { "x","y","x","y","x","y" };
	cout << player1 << " hide your THREE tressures using( x  ,y )co-ordinates " << endl;
	int temp = -1;
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			temp += 1;
			cout << arrayXY[temp] << ": ";
			cin >> tressureArray[i][j];
		}
	}
	cout << "THANK YOU" << player1 << "YOUR TRESSURES ARE NOW HIDDIN" << endl;
}


void players2Input(int player2Guess[1][1], string player2)
{
	cout << player2 << " time to make your guesses using ( x  ,y )co-ordinates  ";
	string arrayXY[2] = { "x","y" };
	int temp = -1;

	for (int i = 0; i < 2; i++)
	{
		temp += 1;
		cout << arrayXY[temp] << ": ";
		cin >> player2Guess[i][i];
	}

}

int main(int argc, char**argv)
{
	int tressureArray[3][2];
	string player1, player2;
	int player2Guess[1][1];

	player1 = playerNames(player1, "one");
	player2 = playerNames(player2, "two");

	player1Tressure(tressureArray, player1);


	for (int g = 0; g < 3; g++)
	{
		players2Input(player2Guess, player2);



		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 2; j++)
			{
				if (tressureArray[i][j] == player2Guess[i][j])
				{

					string grid[8][7] = {
						{" ","1", "2 "," 3"," 4"," 5"," 6\n"},
						{"1","_ ","_ ","_ ","_ ","_ ","_ \n"},
						{"2","_ ","_ ","_ ","_ ","_ ","_ \n"},
						{"3","_ ","_ ","_ ","_ ","_ ","_ \n"},
						{"4","_ ","_ ","_ ","_ ","_ ","_ \n"},
						{"5","_ ","_ ","_ ","_ ","_ ","_ \n"},
						{"6","_ ","_ ","_ ","_ ","_ ","_ \n"},
						{"7","_ ","_ ","_ ","_ ","_ ","_ \n"}
					};
					for (int row = 0; row < 8; row++)
					{
						for (int column = 0; column < 7; column++)
						{
							cout << grid[row][column] << "     ";
							grid[tressureArray[i][j]][tressureArray[i][j]] = { "X" };
						}
					}
				}
			}
		}


	}

	system("pause");
	return 0;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++/ TIC TAC TOE\+++++++++++++++++++++++++++++++\\

#include <iostream>
#include <string>
#include <sstream>


using namespace std;

int arrayForGrid[7][6];
int choice, player;
bool end = false;
int a = 0;

void check(int x)
{
	if (arrayForGrid[x - 1][a] != 0 && a < 6)
	{
		a++;
		check(x);
	}
	else if (player == 1 && a < 6)
	{
		arrayForGrid[x - 1][a] = 1;
		a = 0;           // this re assigns as 0 so that its not 1++ its 0++
	}
	else if (player == 2 && a < 6)
	{
		arrayForGrid[x - 1][a] = 2;
		a = 0;
	}
	else
	{
		cout << "WRONG!" << endl;
		a = 0;
		player++;
	}
}

void draw()
{


	for (int i = 0; i < 9; i++)
	{
		if (i < 2)
		{
			cout << "-";
		}
		else if (i > 7)
		{
			cout << i - 1 << "--" << endl;
		}
		else {
			cout << i - 1 << "----";
		}
	}
	for (int i = 0; i < 6; i++)
	{
		for (int j = 0; j < 7; j++)
		{
			if (arrayForGrid[j][i] != 0)
			{
				if (arrayForGrid[j][i] == 1)
				{
					cout << "|_X_|";
				}
				else cout << "|_O_|";
			}
			else cout << "|___|";
		} cout << endl;
	}
	for (int i = 0; i < 35; i++) // a banner for cseperation, not necissary 
	{
		cout << "=";
	} cout << endl;
}

void win_check()
{
	bool end = false;
	for (int i = 0; i < 6; i++)
	{
		for (int j = 0; j < 7; j++)
		{
			if (arrayForGrid[j][i] == 1 && arrayForGrid[j + 1][i + 1] == 1 && arrayForGrid[j + 2][i + 2] == 1 && arrayForGrid[j + 3][i + 3] == 1)  // all the possible winning combinations for player one and two,
				end = true;
				cout << "\nPLAYER 1 WIN!" << endl;
			}
			if (arrayForGrid[j][i] == 1 && arrayForGrid[j + 1][i - 1] == 1 && arrayForGrid[j + 2][i - 2] == 1 && arrayForGrid[j + 3][i - 3] == 1)
			{
				cout << "\nPLAYER 1 WIN!" << endl;
				end = true;
			}
			if (arrayForGrid[j][i] == 2 && arrayForGrid[j + 1][i - 1] == 2 && arrayForGrid[j + 2][i - 2] == 2 && arrayForGrid[j + 3][i - 3] == 2)
			{
				cout << "\nPLAYER 2 WIN!" << endl;
				end = true;
			}
			else if (arrayForGrid[j][i] == 2 && arrayForGrid[j - 1][i - 1] == 2 && arrayForGrid[j - 2][i - 2] == 2 && arrayForGrid[j - 3][i - 3] == 2)
			{
				end = true;
				cout << "\nPLAYER 2 WIN!" << endl;
			}
			else if (arrayForGrid[j][i] == 1 && arrayForGrid[j][i - 1] == 1 && arrayForGrid[j][i - 2] == 1 && arrayForGrid[j][i - 3] == 1)
			{
				cout << "\nPLAYER 1 WIN!" << endl;
				end = true;
			}
			else if (arrayForGrid[j][i] == 1 && arrayForGrid[j - 1][i] == 1 && arrayForGrid[j - 2][i] == 1 && arrayForGrid[j - 3][i] == 1)
			{
				cout << "\nPLAYER 1 WIN!" << endl;
				end = true;
			}
			else if (arrayForGrid[j][i] == 2 && arrayForGrid[j][i - 1] == 2 && arrayForGrid[j][i - 2] == 2 && arrayForGrid[j][i - 3] == 2)
			{
				cout << "\nPLAYER 2 WIN!" << endl;
				end = true;
			}
			else if (arrayForGrid[j][i] == 2 && arrayForGrid[j - 1][i] == 2 && arrayForGrid[j - 2][i] == 2 && arrayForGrid[j - 3][i] == 2)
			{

				cout << "\nPLAYER 2 WIN!" << endl;
				end = true;
			}
		}
	}

}

void p_choice()
{
	bool end = false;
	player = 1;
	while (end != true)
	{
		cout << "PLAYER " << player << ": ";
		cin >> choice;
		if (choice > 0 && choice < 8)
		{
			check(choice);
			draw();                            // this calls the draw function if the choices are between 1-7
			if (player == 1)
			{
				player++;
			}
			else
			{
				player--;
			}
		}
		else
		{
			cout << "WRONG CHOICE!" << endl;      // if the user enters numbers not within 1-7 it will read this
		}
		win_check();                                    //if all conditions are met the program will call into function win_check
	}
}


int main()
{

	std::cout << "WELCOME IN CONNECT 4" << std::endl;
	draw();
	p_choice();
	return 0;
}
