• Advertisement
Sign in to follow this  

1st game - newbie looking for feedback.

This topic is 4722 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all I've just completed my 1st game. It's a simple text based version of Tic-Tac-Toe. I'm pretty new to this C++ and OOP development, I come from a C development background and so would really appreciate some feedback on the design and other areas of C++ & OOP that I've used or missed or missused. Any constructive comments would be good, be they good, bad or ugly. The source can be downloaded from here Thanks to ace_lovegrove for helping me with webspace...top man..:) The project has been built using dev-c++ v4.9.9.2. Please get back to me if you wouldn't mind. Thanks in advance..:)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ZadrraS
Can you upload a compiled exe file? It doesn't compile with Visual C++.


Seconded - I had some severe issues with both VS and DevC++ - also, why have it in two nested zip files???

Share this post


Link to post
Share on other sites
Firstly, no std namespace needed in Boardtile.cpp and you need a return value at bool GenericPlayer::setGo(const bool turn).

*looks at game*

The GUI and such is very well layed out and frankly kick ass :P

As for the code, you have lots of accessor methods such as
char GenericPlayer::getPlayPiece()

that only return a value. You should place them in the header file so that they will be inlined. Although Im sure a decent compiler would anyway. other than that everything seems fine from a quick skim of the code.

Oh one last thing, isntead of writting vector<BoardTile*>::const_iterator and such all the time you might want to typedef it to something shorter and more easily remembered.

Share this post


Link to post
Share on other sites
I'm not much of a OOP programmer so without looking at the code closely I think this game is pretty damn good. One question though. Is it possible to win? That always seems to be the problem with tic tac toe games. What about cpu vs cpu? does one ever win? Sorry I didn't test it for too long :)

Share this post


Link to post
Share on other sites
Thanks for all the responses and feedback.

Good point about using typedefs for short hand.

I'm suprised taht the compiler didn't complain about the missing return in GenericPlayer::SetGo() function. Changed that now so return type is void. Also will remeber to inline functions. C++ does offer some great functionality when compared to C, am suprised just how much I'm enjoying programming again. Am looking forward to starting to play with templates and some more advanced features liek automatic memory management and class factories...but is better to learn to walk before running.

Will look into a clear screen function.

One thing I was trying to do was overload the << operator to display the board. I did write this as a friend function to the Board{} class but was then getting probelms. The memory address of m_Tiles was being displayed and not the board itself, and then the bit that takes input from the manu would loop infinitely..did wonder if I needed to have a cin.clear(), but as I understand it that function only clears any errors that have occured during the last use of cin? If anyone couls help out with this would be more than appreciated.

For people having problems compiling the project then the executable can be found here.

Am not too sure why the files are in 2 zips, that'll be down to the lovely peeps that helped me get it onto the web.

Thanks for the feedback, please keep it coming.

Share this post


Link to post
Share on other sites
Quote:
Original post by sand_man
One question though. Is it possible to win?


Quite easily. In fact, if you know what you're doing, it's impossible for it to beat you.

Looks quite well made, and I didn't find any flaws in the program. I havn't looked into the code, as my download of the source seems to be corrupted (the files had gibberish).

Perhaps the computer could go first sometimes (Human vs. Comp) to add a little more challenge? I'd also be interested to know if the computer can indeed defeat itself - it appears to play an identical game (resulting in a tie) every time?

Share this post


Link to post
Share on other sites
I like it, very cool...

Have you thought about clearing the screen when you enter a game, after you have a go etc. ?

Cheers,
Add

:EDIT: Doh! someones already said it, :EDIT:

Share this post


Link to post
Share on other sites
One thing i must say, is it has really smart AI, most games at this level just have AI that tries to put 3 in a row with no blocking what so ever.

Share this post


Link to post
Share on other sites
Thanks.

I personally thought about randomising the AI a little, well for the demo at least. At the moment the computers always follow the same path so radomising it may produce different results.

Am thinking about starting to do a text based tetris next. Was thinking about doing a graphical version of TTT straight away but might be an idea to consolidate a bit of knowledge and try something new.

Have broken the game down into some constituent parts 1 being the game area, teh area that shows the score, next piece, in play instructions. and another being the play area, the area in which the blocks are moved.

I'm thinking the play area shold be a 1-D array of strings or a 2-D array of char(s). What does anyone else think?

Don't worry I have also thought that I'll need playing pieces.

a square
a Block (made up of 4 squares)
and a blocktype (derived from a block class I think???)

I think I'll try to add a high score table as well which will mean using file I/O (which will be new for me in C++)

What do poeople think about the basic HLD for this tetris game. Does anyone have suggestions, either about the design and/or features that should be incorporated?

Share this post


Link to post
Share on other sites
That is very nice indeed! one suggestion I have is make a clrScrn macro. all you have to do is cout " \n" 200 times. It will look pretty good.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by sand_man
One question though. Is it possible to win? That always seems to be the problem with tic tac toe games.



I won the game.... entered 3, 7, 9 and then 8

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I am not sure if VC++ has it or not but there is a function/macro that does clear the screen ... it is called clrscr() with no parameters.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Tic-tac-toe is a classic example of a "perfect game" one in which ends in a draw assuming both players play the absolute best moves every time. A win on either side means one of the players made a mistake.

Share this post


Link to post
Share on other sites
Any game without hidden information is "perfect." Even chess. Tic-tac-toe just has a solution that even a child can comprehend.

Share this post


Link to post
Share on other sites
It took a long time until I realized that I couldn't use the num pad to enter the numbers. I liked it a lot but I would prefer to have the 1 for the lower left corner and the 9 for the upper right... maybe that's just me but it seems counterintuitive...
otherwise great. beats my ttt by.... ummm... many times...
I'll go to bed.. good night

Share this post


Link to post
Share on other sites
Pretty good version of tic-tac-toe. I just finish my tic-tac-toe game about a month ago. Just one problem with your program i noticed. if you enter a command at the menu screen that isnt valid like typing asfdads you computer will just keep on looping. If your using C++ strings this is a easy fix all you have to do is just make a else statement that will go after all your other conditions for the different menu items if it enters the else statement you can easily display a message and have a continue statement right after. That is if the menu selection part is inside some kind of loop. Hope this helps kind of tired so not sure if this is all that clear.

Share this post


Link to post
Share on other sites
Thanks...didn't know about that bug..not enough testing on my part.

Was thinking about using kbhit() next time and then processing the input...what do others think?

Share this post


Link to post
Share on other sites
hey good job on the game.... would be great if you could also add a nice GUI with mouse control and all. Good job though..Keep it up

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement