TicTacToe Feedback (console game)

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
User avatar
Vortex
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 70
Joined: Sat Nov 15, 2008 1:00 pm

TicTacToe Feedback (console game)

Post by Vortex »

Hey, im gonna start by saying that i am new to c++ and programming overall so dont be to harsh.

i have started my first real "projekt" and i decided to make tictactoe in console. the game itself is complete and i have made an simple "AI" (if you now can call it that) or bot that you can play against or you could play against another player.

the thing is that i need feedback on my code on bad habbits things i could do diffrent to improve so please give me so much feed back you can :)
i also need you guys to check the Bot if you can beat him, i wont him to be 100% unbeatable.
if you beat him dont start a new game but first post the log that will be generated in the folder where the .exe is,
post it here so i can see what you did to beat him so i can fix it.

Dowload link, i included an complete exe file for you lazy persons :roll:
http://www.uploading.com/files/AJP4SKMD ... e.zip.html

and once again, remember that im very new to c++ and this is my first "game" and project.


Pardon my imperfect english.
TorteXXX
User avatar
Vortex
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 70
Joined: Sat Nov 15, 2008 1:00 pm

Re: TicTacToe Feedback (console game)

Post by Vortex »

Oops i now saw that you have to wait 90 secounds to download...

i uploaded it here if you dont wanna wait.
http://www.2shared.com/file/4365245/f62 ... acToe.html

also come with suggestions that i can add to my game :)
TorteXXX
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: TicTacToe Feedback (console game)

Post by avansc »

did you make it with VS? (visual studio?)
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Vortex
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 70
Joined: Sat Nov 15, 2008 1:00 pm

Re: TicTacToe Feedback (console game)

Post by Vortex »

Yea, Microsoft visual c++ 2008 express.
TorteXXX
User avatar
ismetteren
Chaos Rift Junior
Chaos Rift Junior
Posts: 276
Joined: Mon Jul 21, 2008 4:13 pm

Re: TicTacToe Feedback (console game)

Post by ismetteren »

I just made an console TicTacToe game too :D but i dont have any AI

Cant wait to see how you done it ;)

.:Edit:.
Can't open the .exe file.

it gives me an error message(in danish, i've tried to translate it):

The program could not start, because the side by side-configuration is wrong. You will find more information in the eventlogfile.

I've looked at the source. Mine seems to be more object oriented the yours(not saying that mine is better, i guess it is about perferrence). Ive found out to check for win this way(instead of checking every win posibility):

Code: Select all

int Game::checkForWin()
{
    list<int> xCord;
    list<int> yCord;
    
    for(int i = 0; i < 2; i++)
    {
        for(int y = 0; y < 3; y++)
        {
            for(int x = 0; x < 3; x++)
            {
                if(board.getPiece(x, y) == players.at(i).getPiece())
                {
                    xCord.push_back(x);
                    yCord.push_back(y);
                }
            }
        }
        if(xCord.size() == 3 && yCord.size() == 3)
        {
            int xSize = xCord.size();
            xCord.sort();
            xCord.unique();
            int ySize = yCord.size();
            yCord.sort();
            yCord.unique();
            //checks if all xCord or yCord values are euqual, and there therfore is an horizonal or vertical win
            if(xCord.size() == 1 || yCord.size() == 1)
            {
                cout << players.at(i).getName() << " " << " WON!!!" << endl;;
                done = true;
            }
            //checks if all xCord or yCord values are non-euqual, and there therfore is an diagonal win
            if(xCord.size() == xSize && yCord.size() == ySize)
            {
                cout << players.at(i).getName() << " " << " WON!!!" <<  endl;;
                done = true;
            }
        }
        xCord.clear();
        yCord.clear();
    }
}
the first part loads the coordinates of the players pieces into 2 list's. The idea is that if all x or y values are equal there is a win, and if all x AND y values are different there is a win.
Last edited by ismetteren on Sat Nov 29, 2008 10:50 am, edited 1 time in total.
Image ImageImage Image
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: TicTacToe Feedback (console game)

Post by avansc »

ismetteren wrote:I just made an console TicTacToe game too :D but i dont have any AI

Cant wait to see how you done it ;)

.:Edit:.
Can't open the .exe file.

it gives me an error message(in danish, i've tried to translate it):

The program could not start, because the side by side-configuration is wrong. You will find more information in the eventlogfile.
the reason you cant open it is because you cant take exe compiled with VS to another machine. (its MS's way of making sure you dont make money off their products.)
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Vortex
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 70
Joined: Sat Nov 15, 2008 1:00 pm

Re: TicTacToe Feedback (console game)

Post by Vortex »

ismetteren wrote:I just made an console TicTacToe game too :D but i dont have any AI

Cant wait to see how you done it ;)

.:Edit:.
Can't open the .exe file.

it gives me an error message(in danish, i've tried to translate it):

The program could not start, because the side by side-configuration is wrong. You will find more information in the eventlogfile.

I've looked at the source. Mine seems to be more object oriented the yours(not saying that mine is better, i guess it is about perferrence). Ive found out to check for win this way(instead of checking every win posibility):

Code: Select all

Code.
the first part loads the coordinates of the players pieces into 2 list's. The idea is that if all x or y values are equal there is a win, and if all x AND y values are different there is a win.
i havent got so far into c++ so i dont know how to make a good "objekt oriented" program yet, still dont really know what it is,
about my solution for checking win.
i didint really know how to do it in any other way but i will try to change it when i get time
also i hope you could read the rest of my code, its kinda messy.
TorteXXX
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: TicTacToe Feedback (console game)

Post by MarauderIIC »

avansc wrote:the reason you cant open it is because you cant take exe compiled with VS to another machine. (its MS's way of making sure you dont make money off their products.)
You can too. It's just not as easy as possible. Anyway:

http://stackoverflow.com/questions/2540 ... ins-errors

I've had this problem. The solution has two steps:
1. Compile your program in "Release" mode instead of "Debug" mode (there's usually a combo-box in the toolbar)
2. Download from Microsoft their Redistributable Package of runtime components. Make sure to download the x86 edition for 32-bit computers and the x64 edition for 64-bit computers/OSes. Install this package on the target computer, and your application should run fine

P.S. This is a SxS thing
P.P.S. Alternatively, use a different compiler (like GCC, for example with Dev-Cpp) to compile your program's source, and your headaches will disappear.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply