![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Newbie
|
Hehe, wow. He must've been bored that day.
|
|
|
|
|
|
#22 |
|
Programmer
Join Date: Oct 2004
Posts: 32
Rep Power: 0
![]() |
I tried TTT as my first program. I never finished it though, i should get checked for ADD
#include <iostream>
#include <string>
using namespace std;
int winnerz(char current_board[3][3]);
int main()
{
int x, y;
char winner, the_move, theres_errors, current_board[3][3];
for(x=0; x<3; x++)
{
for(y=0; y<3; y++)
{
current_board[x][y]='-';
}
}
system("@echo off");
cout<<"This is standard Tic-Tac-Toe, user vs. computer.";
system("echo.");
cout<<"Use the following board as a key when choosing a position to play:";
system("echo.");
system("echo.");
cout<<"A | B | C";
system("echo.");
cout<<"---------";
system("echo.");
cout<<"D | E | F";
system("echo.");
cout<<"---------";
system("echo.");
cout<<"G | H | I";
system("echo.");
cout<<"Don't forget to use CAPITAL LETTERS";
system("echo.");
system("echo.");
system("echo.");
current_board[1][1] = 'X';
cout<<"Current Board:";
system("echo.");
system("echo.");
cout<<current_board[0][0]<<" | "<<current_board[0][1]<<" | "<<current_board[0][2];
system("echo.");
cout<<"---------";
system("echo.");
cout<<current_board[1][0]<<" | "<<current_board[1][1]<<" | "<<current_board[1][2];
system("echo.");
cout<<"---------";
system("echo.");
cout<<current_board[2][0]<<" | "<<current_board[2][1]<<" | "<<current_board[2][2];
system("echo.");
system("echo.");
cout<<"Please make a move: ";
cin>>the_move;
system("echo.");
while(winner!=1)
{
switch(the_move)
{
case 'A': if(current_board[0][0]!='-')
{
cout<<"Please move into an unoccupied square. ";
break;
}
else
{
current_board[0][0] = 'O';
break;
}
case 'B': if(current_board[0][1]!='-')
{
cout<<"Please move into an unoccupied square. ";
break;
}
else
{
current_board[0][1] = 'O';
break;
}
case 'C': if(current_board[0][2]!='-')
{
cout<<"Please move into an unoccupied square. ";
break;
}
else
{
current_board[0][2] = 'O';
break;
}
case 'D': if(current_board[1][0]!='-')
{
cout<<"Please move into an unoccupied square. ";
break;
}
else
{
current_board[1][0] = 'O';
break;
}
case 'E': if(current_board[1][1]!='-')
{
cout<<"Please move into an unoccupied square. ";
break;
}
else
{
current_board[1][1] = 'O';
break;
}
case 'F': if(current_board[1][2]!='-')
{
cout<<"Please move into an unoccupied square. ";
break;
}
else
{
current_board[1][2] = 'O';
break;
}
case 'G': if(current_board[2][0]!='-')
{
cout<<"Please move into an unoccupied square";
break;
}
else
{
current_board[2][0] = 'O';
break;
}
case 'H': if(current_board[2][1]!='-')
{
cout<<"Please move into an unoccupied square";
break;
}
else
{
current_board[2][1] = 'O';
break;
}
case 'I': if(current_board[2][2]!='-')
{
cout<<"Please move into an unoccupied square";
break;
}
else
{
current_board[2][2] = 'O';
break;
}
default: cout<<"Errors have occured. Please restart the program.";
winner=1;
theres_errors=1;
}
if(theres_errors!=1)
{
cout<<"Current Board:";
system("echo.");
system("echo.");
cout<<current_board[0][0]<<" | "<<current_board[0][1]<<" | "<<current_board[0][2];
system("echo.");
cout<<"---------";
system("echo.");
cout<<current_board[1][0]<<" | "<<current_board[1][1]<<" | "<<current_board[1][2];
system("echo.");
cout<<"---------";
system("echo.");
cout<<current_board[2][0]<<" | "<<current_board[2][1]<<" | "<<current_board[2][2];
system("echo.");
system("echo.");
cout<<"Please make a move: ";
cin>>the_move;
system("echo.");
}
winner = winnerz(current_board[3][3]);
};
system("echo.");
system("pause");
return 0;
}
int winnerz(char current_board[3][3])
{
if(current_board[0][0] == current_board[0][1] && current_board[0][1] == current_board[0][2])
{
cout<<"You Win Sucker!";
return 1;
}
else
{
return 0;
}
}
__________________
<CENTER><span style='font-size:17pt;line-height:100%'>My Homepage</span></CENTER> |
|
|
|
|
|
#23 |
|
Programmer
Join Date: Oct 2004
Posts: 32
Rep Power: 0
![]() |
aw man, I just tested out that 8000+ line program, its no fun
I had the AI cornered, so it just quit the game I was X's: X2O 4O6 X8X i was gonna win!
__________________
<CENTER><span style='font-size:17pt;line-height:100%'>My Homepage</span></CENTER> |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|