Shahrayar123 / Shahrayar123/Python-Projects
Bug: Program crashes when board is full in Tic Tac Toe game
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 582
- Forks
- 441
- PR merge metrics
- No merged PRs in 30d
Description
After the board is filled in the Tic Tac Toe game, the program crashes with an error:
TypeError: list indices must be integers or slices, not NoneType
Cause:
The compMove() function returns None when no moves are left, but the program tries to insert at board[None].
Suggested Solution:
Before calling insertLetter("O", move), check if move is None and handle it as a tie.
Example:
if move == 0 or move is None:
print("Tie game")
else:
insertLetter("O", move)
print(f"Computer placed O on position {move}")
printBoard(board)
Additional Suggestion:
In compMove(), add a check:
if len(possibleMoves) == 0:
return None
Happy to work on fixing this if you would like! 🚀
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Tic Tac Toe game’s compMove() and insertLetter() functions, then trace the computer-turn path when the board has no open positions. Handle the full-board case as a tie before indexing the board, and verify that a completed board prints a tie instead of raising the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100