57 votes

Tic Tac Toe C++

Avoid platform specific code If there is an alternative you should try to avoid platform specific code. This entails avoiding #include <windows.h> and using ...
Nobody moving away from SE's user avatar
32 votes

Tic Tac Toe console program

This is not bad for a programmer as new to C++ as you have said you are. Keep up the good work! With that said, here are some ideas on how you might be able to improve your program. Don't abuse <...
Edward's user avatar
  • 65.3k
27 votes
Accepted

Tic Tac Toe vs PC

Here are some things that may help you improve your code. Fix your formatting The indentation, in particular, seems rather random. It may be that it's an artifact of posting the code, but it doesn'...
Edward's user avatar
  • 65.3k
26 votes
Accepted

Tic Tac Toe in C++14

Here are some observations and suggestions that may help you improve your program. Check your spelling If you run a spell check on your comments, you'll find a number of things such as "peice" ...
Edward's user avatar
  • 65.3k
25 votes
Accepted

First Program Tic-Tac-Toe

Here are some things that may help you improve your code. Use the required #includes The code uses std::string which means ...
Edward's user avatar
  • 65.3k
24 votes
Accepted

4x4 tic tac toe

Your code is quite good for someone who started 10 days ago. Here are a couple of improvements you should consider: Your code is hard to read due to inadequate indentation and spacing. Take a look at ...
hb20007's user avatar
  • 372
19 votes
Accepted

Tic Tic Tic Tac Tac Tac Toe Toe Toe

You have many problems within your code, including: Meaningless variable names (why, for example, is the user input named aaa?!); Repetition; Inconsistent ...
jonrsharpe's user avatar
  • 13.9k
18 votes

Tic-Tac-Toe for the terminal

First of all: nice work! It's easy to read and understand. Program organization It's very good that you split the task to small functions. Reading the body of main...
janos's user avatar
  • 111k
17 votes
Accepted

Tic Tac Toe game in C#

//Variable to store player, 0 is X, 1 is O. int counter = 0; Good thing that comment is there! This sets you up for some rather unimpressive player-turn logic ...
Mathieu Guindon's user avatar
15 votes

Simple C# console Tic Tac Toe program

Bug The same player can place its sign on a allready taken (by him) place. You have defended against this for the opponent although you use inappropriate language here. You should just check if the ...
Heslacher's user avatar
  • 50.3k
15 votes
Accepted

Simple Tic Tac Toe game inside terminal

On the whole this is nicely done for an application made during your first week of C programming. The functions are generally reasonably-sized, the code is comprehensible and the design decisions are ...
ggorlen's user avatar
  • 3,317
14 votes
Accepted

Tic-Tac-Toe code using c#

Choosing good identifiers When I see a name like options I think of something a player can choose from like "single player" (i.e., play against the ...
Olivier Jacot-Descombes's user avatar
13 votes

Check for a win on the board

What you've done here is listed all possible checks, but you've compiled it into a single method. Ideally, you should split this up into separate tasks, as there are three categories of similar checks:...
Flater's user avatar
  • 5,542
13 votes
Accepted

Ncurses Tic Tac Toe with simplistic AI

Avoid numbered variables ...
mdfst13's user avatar
  • 21.4k
12 votes
Accepted

Python, JavaScript, PHP, HTML: Unbeatable Tic Tac Toe

As JosephtheDreamer has left the Python to someone else, I'll take up the challenge. It's a small thing, but the styling for the definition of winning_combos doesn'...
zondo's user avatar
  • 3,787
12 votes
Accepted

Simple C# console Tic Tac Toe program

OK .. I took a look at your code. Let's do this one step at a time... I'm using VisualStudio with Resharper Installed. This causes a big chunk of your code to grey out. The if clause ...
Nigel Thorne's user avatar
12 votes

Ncurses Tic Tac Toe with simplistic AI

Here are a number of things that may help you improve your program. Eliminate global variables where practical Having routines dependent on global variables makes it that much more difficult to ...
Edward's user avatar
  • 65.3k
11 votes
Accepted

TicTacToe where the computer plays random moves against itself

Some of your functions can use list comprehensions. As you seem to know maths, you may have come across 'set-builder notation', and that's what list comprehension are based off: \$S = \{2 \times x | ...
Peilonrayz's user avatar
  • 42.7k
11 votes
Accepted

Tic Tac Toe - console application

First things first: your code is pretty easy to read, and very consistently formatted, good job on that. You're including the right headers, and didn't go wild with using directives, and that's good ...
Mat's user avatar
  • 2,995
11 votes

Tic Tac Toe vs PC

Inconsistent Indentation The code in Main is not indented. The code in PC_turn is not properly indented. The code in ...
pacmaninbw's user avatar
  • 23.5k
11 votes

Simple C# console Tic Tac Toe program

First of all, why pos has 10 elements and everywhere you counting from 1 to 9? Let this array to have 9 elements and count from 0. You must rewrite the ...
Maxim's user avatar
  • 2,532
11 votes

4x4 tic tac toe

For coding since 10 days, this program is really impressive. If I had to learn something new and complicated as C++, I'd probably make many more mistakes. One thing that is always tricky is input and ...
Roland Illig's user avatar
  • 21.2k
11 votes

Tic-Tac-Toe program

Don’t write using namespace std;. Read through and bookmark the C++ Standard Guidelines. Numbers I note later are citations from this. ...
JDługosz's user avatar
  • 11.3k
11 votes
Accepted

I made Tic Tac Toe in C

Please check it if you can, and give your opinion! Enable more warnings ...
chux - Reinstate Monica's user avatar
11 votes
Accepted

A Simple Tic-Tac-Toe Game

Put all code in functions. This is what experienced programmers do, so you would be wise to adopt the practice even if you don't fully appreciate all of the reasons yet. After that change, you'll end ...
FMc's user avatar
  • 12.5k
10 votes

Tic Tac Toe game in C#

Each of your buttonX_Click contains basically the same code. Don't copy-paste, instead create a method that contains this code and accepts the button as a parameter,...
BCdotWEB's user avatar
  • 11.2k
10 votes

Tic Tac Toe game in C#

Other answers have noted that there is a great deal of unnecessary repetition in the button handling logic. There is also a great deal of repetition in the winning-condition-checking logic. Any time ...
Eric Lippert's user avatar
  • 14.7k
10 votes
Accepted

Minimax implementation of tic tac toe

Sorry, but that someone is probably right. At the same time, thanks for being thus brave and asking on how to improve here. It's not so simple to give feedback in such a scenario, since there are so ...
Thomas Weller's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible