Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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
  • 66.4k
26 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
  • 66.4k
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
  • 66.4k
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
  • 66.4k
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

A tic-tac-toe game in C

Unfortunately, it seems like you have stumbled across an older version of The C Programming Language which described a dialect of C now dubbed K&R C. K&R C was superseded by ANSI C (C89), and ...
Rish's user avatar
  • 2,341
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
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.4k
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,540
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,532
13 votes
Accepted

Ncurses Tic Tac Toe with simplistic AI

Avoid numbered variables ...
mdfst13's user avatar
  • 21.6k
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,797
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
  • 66.4k
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.8k
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,542
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.3k
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.4k
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.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
10 votes

Tic Tac Toe console program

There's a typo in this line: }else if(arr[1]+arr[4]+arr[7]==3*10||arr[1]+arr[7]+arr[7]==3*11){ //win condition outputs the winner player's name for all I think ...
Toby Speight's user avatar
  • 75.8k
10 votes

Python: Tic Tac Toe Game

I'll point out some useful starting points for improving your code. I would additionally recommend looking at some other implementations, for some further inspiration regarding logic and code ...
riskypenguin's user avatar
  • 3,453
10 votes

Object-oriented programming for tic-tac-toe (only 66 lines) in Python

Your Board class is handling too much at present. It's managing the following items: The board itself Whose move it is Making moves for either player Printing the ...
C.Nivs's user avatar
  • 2,947
10 votes

Tic-Tac-Toe game in C++

Avoid using namespace std; If you are coding professionally you probably should get out of the habit of using the ...
pacmaninbw's user avatar
  • 23.8k
9 votes
Accepted

Simple Tic-Tac-Toe with Minimax Algorithm

Here are some things that may help you improve your code. First, yes, you implemented the minimax algorithm correctly, but there's an easy improvement you can make that I'll show later. Avoid magic ...
Edward's user avatar
  • 66.4k

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