Skip to content

tictactoe: Avoid replaying the computer’s opening move. - #953

Open
sripavantejb wants to merge 1 commit into
zulip:mainfrom
sripavantejb:tictactoe-opening-turn
Open

sripavantejb wants to merge 1 commit into
zulip:mainfrom
sripavantejb:tictactoe-opening-turn

Conversation

@sripavantejb

Copy link
Copy Markdown
Collaborator

When the computer opens in a corner and the human takes the center, there is exactly one X on the board. That used to trigger the opening reply again. If the bot picked its own corner, its turn ended without adding an O. Checking for eight empty squares limits the opening reply to the human’s first move on an otherwise empty board.

Related to #417.

How did you test this PR?

All 14 tic-tac-toe tests also passed locally on macOS.

The regression test forces the corner choice that previously lost a turn. It failed before the fix (one O instead of two) and passed afterward.

python -m unittest zulip_bots.bots.tictactoe.test_tictactoe
Ran 14 tests
OK
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

A single X can also occur after the computer has already placed O. Only use the opening reply on a board with eight empty squares, so a later turn cannot select an occupied corner.
Copilot AI balanced review requested due to automatic review settings December 5, 2026 10:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants