Build and Test a Terminal Game with Freebuff Desktop
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
Build and Test a Terminal Game with Freebuff Desktop
Describe a small game, and Freebuff Desktop writes the code and the tests, then runs them. This example builds a two-player Tic-Tac-Toe game with the game logic kept separate from the input loop.
Quick answers
Can Freebuff Desktop run commands and test the code it just wrote? Yes. In this example it wrote game.py and test_game.py, ran the tests, and ran the game itself.
Can it build a game from a plain description? Yes. One paragraph produced a playable game with 19 passing tests.
Does it fix its own mistakes? Yes. Its first test run had three failures, all bad test setups and not game bugs. It corrected the tests and ran them again, and it explained what changed.
Do I need a terminal? No. You work in the chat. The commands below are only for checking the result yourself.
The prompt
Open an empty folder as a project in Freebuff Desktop, start a new chat and send:
Write a terminal Tic-Tac-Toe game for two players in game.py. Keep the game logic in functions (new_board, make_move, winner, is_full) separate from the input loop, and write unit tests in test_game.py. Run the tests.
The result
Freebuff created game.py and test_game.py. The logic lives in small pure functions, which is what makes the game easy to test:
WINNING_LINES = (
(0, 1, 2), (3, 4, 5), (6, 7, 8), # rows
(0, 3, 6), (1, 4, 7), (2, 5, 8), # columns
(0, 4, 8), (2, 4, 6), # diagonals
)
def new_board():
"""Return an empty 3x3 board as a list of 9 cells."""
return [" "] * 9
def winner(board):
"""Return "X" or "O" if that player has three in a row, else None."""
for a, b, c in WINNING_LINES:
if board[a] != " " and board[a] == board[b] == board[c]:
return board[a]
return None
make_move rejects an off-board position, a taken square or an invalid player. play() handles the input loop, re-prompting on bad input without losing the turn, and exits cleanly on Ctrl+C or Ctrl+D.
In its summary Freebuff noted that it fixed the three failing tests rather than loosening them, and that it changed an error message that had shown a 0-based position after you typed 1.
Verify the result
python3 -m unittest
Ran 19 tests in 0.000s OK
Play a scripted game. The game takes one position from 1 to 9, numbered left to right and top to bottom:
printf '1\n4\n2\n5\n3\n' | python3 game.py
X | X | X ---+---+--- O | O | ---+---+--- | | Player X wins!
Troubleshooting
The game rejects your input. Enter a number from 1 to 9. Anything else prints Please enter a number from 1 to 9., and a taken square prints '1' is not a free square from 1 to 9. Try again.
Your code will look different. Every run writes its own version of the game and its tests. Run the tests and play a game to see yours work.
Tested in Freebuff Desktop 0.0.184 on 2026-10-30.