Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A game, also known as "Noughts and Crosses", in which players take turns placing marks on a 3 × 3 grid in an attempt to form a line of three consecutive marks. You can also use this tag for variants of the game.
5
votes
Accepted
Tic-Tac-Toe in Java with GUI
Event Dispatching Thread
Since Swing is not thread safe, all Swing UI component creation and modification should be done on the Event Dispatching Thread (EDT). It isn’t a problem with this program, …
1
vote
Accepted
Tic Tac Toe check for win/tie in Python
def check_row_containing_move_for_win(self):
total = 0
for column in range(3):
total = total + int(self.letter_dict[self.state_of_game.board[self.row_index_of_move][column]])
i …
3
votes
Determining winning line in TicTacToe game
Bugs
Board Size
I assume that the board can be of any size (but only square) ...
private final int size = 3;
You mean, the board can be any size as long as it is 3-by-3?
Perhaps you meant ...
pr …
1
vote
Tic Tac Toe Python
is_valid_move(state, tup): Is the given move really valid? If the tuple (123,4.71) is given, is it a valid move, invalid move, or a crash-the-program input? It can only be valid if the tuple exists …
2
votes
First Python program: Tic-Tac-Toe
The function check_winner() does not need global move_count. Using global is code smell, avoid if at all possible, which tends to be always. But in this case it is completely unnecessary, as move_co …
1
vote
Accepted
10 minute Tic Tac Toe
When it is X’s turn, and they make a move, only player X can win. Similarly, only Y can win on Y’s turn. So why all these tests?
win = tt[0].value == 1 ? "X" : "O";
If there is a winner, just tes …
2
votes
TicTacToe in Python 3
PyLint is a useful tool for checking your code, ensuring good coding habits. For example, PyLint doesn’t like a lack of spaces around operators or after commas. Neither do my old weak eyes. Instead …
2
votes
MVC Java console tic-tac-toe
I agree with @Timothy Truckle in that you have some issues with the MVC-pattern. I disagree with where they've drawn the line between the model, view and controller.
As they've stated, the model sho …
3
votes
A Simple Tic-Tac-Toe Game
You definitely need more functions.
You state that you could put print(display_table) in a function, but not sure how you could update the table since it would be a local variable within the function. …
3
votes
Accepted
Tic-Tac-Toe Code
Where to start…
tuple assignment
p1, p2, p3, p4, p5, p6, p7, p8, p9 = " ", " ", " ", " ", " ", " ", " ", " ", " "
Is that the correct number of " "? Did you count? Of course you did, and yes it is …
5
votes
Accepted
Design of a Tic Tac Toe program in Python
While your goal may be to "make it so the reader can understand the current method they are reading", I actually found it very confusing to read the code.
Consider:
from games_engine import GamesEng …
4
votes
Beginner Tic Tac Toe Game for Python
create_board()
You explicitly return a hard-coded board, using 5 lines of code. This could be written as one line, using list multiplication and list comprehension:
return [ [EMPTY]*3 for _ in rang …
2
votes
Accepted
Simple Python 3 TicTacToe Game
In addition to Reinderien's comments:
checkWin() first checks board[0][0]==board[0][1]==board[0][2] and returns the "winning" symbol (a string), if the match was found.
This means that, with the f …
3
votes
Accepted
Back to Basics: Tic Tac Toe - follow-up
I see you've removed the bugs. Good job. Let's clean it up some more.
Zero -vs- Naught
It is a little disconcerting to read the code and see '0' not in board or if board[idx] == '0'. It looks lik …
3
votes
Accepted
First Python program: Tic-Tac-Toe (Followup)
You now have two methods of setting up the board. The first is direct initialization:
board = [0, 1, 2,
3, 4, 5,
6, 7, 8]
and the second is a resetting an already existing board: …