Problems with a string changing value

I am trying to make tic tac toe for practice making functions and using random i have the following program (please excuse the length of it)

#include <iostream>
#include <string>
#include <ctime>
#include <cmath>

using namespace std;



void Grid(string B1, string B2, string B3, string B4, string B5, string B6, string B7, string B8, string B9)
{
cout << B1 << "|" << B2 << "|" << B3 << endl;
cout << "-----" << endl;
cout << B4 << "|" << B5 << "|" << B6 << endl;
cout << "-----" << endl;
cout << B7 << "|" << B8 << "|" << B9 << endl;
}
void PlayerMove(int Move, string Player, string B1, string B2, string B3, string B4, string B5, string B6, string B7, string B8, string B9)
{
while (Move == 1)
{
if (Player == "B1")
{
if (B1 == "O")
{
cout << "I have already moved there" << endl;
}
if (B1 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B1 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B2")
{
if (B2 == "O")
{
cout << "I have already moved there" << endl;
}
if (B2 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B2 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B3")
{
if (B3 == "O")
{
cout << "I have already moved there" << endl;
}
if (B3 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B3 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B4")
{
if (B4 == "O")
{
cout << "I have already moved there" << endl;
}
if (B4 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B4 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B5")
{
if (B5 == "O")
{
cout << "I have already moved there" << endl;
}
if (B5 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B5 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B6")
{
if (B6 == "O")
{
cout << "I have already moved there" << endl;
}
if (B6 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B6 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B7")
{
if (B7 == "O")
{
cout << "I have already moved there" << endl;
}
if (B7 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B7 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B8")
{
if (B8 == "O")
{
cout << "I have already moved there" << endl;
}
if (B8 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B8 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (Player == "B9")
{
if (B9 == "O")
{
cout << "I have already moved there" << endl;
}
if (B9 == "X")
{
cout << "You have already moved there" << endl;
}
else
{
B9 = "X";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
}
}
void CPUMove(int Move, int random, string B1, string B2, string B3, string B4, string B5, string B6, string B7, string B8, string B9)
{
while (Move == 1)
{
if (random == 0)
{
if (B1 == "O")
{

}
if (B1 == "X")
{

}
else
{
B1 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (random == 1)
{
if (B2 == "O")
{

}
if (B2 == "X")
{

}
else
{
B2 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (random == 2)
{
if (B3 == "O")
{

}
if (B3 == "X")
{

}
else
{
B3 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (random == 3)
{
if (B4 == "O")
{

}
if (B4 == "X")
{

}
else
{
B4 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (random == 4)
{
if (B5 == "O")
{

}
if (B5 == "X")
{

}
else
{
B5 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}

}
if (random == 5)
{
if (B6 == "O")
{

}
if (B6 == "X")
{

}
else
{
B6 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}

}
if (random == 6)
{
if (B7 == "O")
{

}
if (B7 == "X")
{

}
else
{
B7 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (random == 7)
{
if (B8 == "O")
{

}
if (B8 == "X")
{

}
else
{
B8 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
if (random == 8)
{
if (B9 == "O")
{

}
if (B9 == "X")
{

}
else
{
B9 = "O";
--Move;
Grid (B1, B2, B3, B4, B5, B6, B7, B8, B9);
}
}
}
}

int main()
{

string Player;
int Move = 1;
string B1 = " ", B2 = " ", B3 = " ", B4 = " ", B5 = " ", B6 = " ", B7 = " ", B8 = " ", B9 = " ";
srand(time(0));
int random = rand() % 8;

cout << "B1|B2|B3" << endl;
cout << "--------" << endl;
cout << "B4|B5|B6" << endl;
cout << "--------" << endl;
cout << "B7|B8|B9" << endl;
cout << "Above is how the Tic Tac Toe grid is identified" << endl;
cout << "Your' move first" << endl;
cin >> Player;
PlayerMove (Move, Player, B1, B2, B3, B4, B5, B6, B7, B8, B9);
cout << "My Turn" << endl;
CPUMove (Move, random, B1, B2, B3, B4, B5, B6, B7, B8, B9);
system ("PAUSE");
return 0;
}

now when i run the program it outputs dsomething like this

x| |
-----
| |
My Turn
O| |
-----
| |

and im unsure as to why the top left box did not remain with value X
Topic archived. No new replies allowed.