Skip to content

feat: Add Mathdoku game to Sir Lancebot#1732

Open
daDevBoat wants to merge 74 commits intopython-discord:mainfrom
daDevBoat:feature
Open

feat: Add Mathdoku game to Sir Lancebot#1732
daDevBoat wants to merge 74 commits intopython-discord:mainfrom
daDevBoat:feature

Conversation

@daDevBoat
Copy link

Co-authors

Co-authored-by: JannisHaeffner jannis.haeffner@yahoo.de
Co-authored-by: djonte djonatanbolenius@gmail.com
Co-authored by: arpega75 arnau.pelechano@gmail.com
Co-authored by: knasssss alexander.mannertorn@gmail.com

Relevant Issues

Closes #989

Description

Implement a mathdoku game, in the style proposed by the issue.

The Mathdoku feature is implemented as a subsystem across three modules with clear separation of responsibilities.

1. Game Logic (mathdoku.py)

This module contains the core game model:

  • Cell: stores coordinates (row, column), block, player guess, and correct value.
  • Block: stores block metadata (id, operation, number, assigned cells, color).
  • Grid: stores board state and game rules (latin-square rules, full-board checks, check block constraints, evaluates win condition, hint cooldown handling...).

This module is independent from Discord commands, so game correctness can be verified independently from the bot's event handling.

2. Board Parsing (mathdoku_parser.py)

This module reads mathdoku_boards.txt, extract board definitions, builds Grid objects, assign blocks and operations, and loads the correct solution values.

This module acts as the entry point for board data, transforming raw text into structured game objects ready to be used by the game logic.

3. Discord Integration (mathdoku_integration.py)

This module connects the game to Discord and manages the full interaction flow with the player:

  • Starts a game session.
  • Wait for player input messages with a 10 minutes inactivity timeout.
  • Handles guesses from user inputs.
  • Handles emoji reactions for hints and block validation.

This module contains no game rules. It receives player input messages,
delegates to the game logic, and sends the result back to Discord.

How to run and play

Start a mathdoku game by typing .md start SIZE DIFFICULTY where size can be any integer from 3-9, and difficulty must be either easy, medium or hard.

You fill in a number by typing its position, followed by your guess. For example: A1 3 to put number 3 in field A1 (top left corner)

To display further rules click the book emoji

Did you:

djonte and others added 30 commits March 2, 2026 12:27
The ./kenken command can now be used

closes #12
add a generate image method to the Grid and a correpsonding test

closes #10
Add hint feature with Cooldown and its unit tests

closes #14
Ensure only the user starting can play the game
closes #48
the user guess is validated, if correct it is applied and the image is updated

closes #50
changed so the turn message is only printed at the beginning, prevents the chat from jumping

closes #66
once the grid is filled a magnifying glass appears and the user can verify their game status by clicking it. The grid then updates and shows which blocks are good and which are bad

closes #51
knasssss and others added 30 commits March 2, 2026 12:28
fixed format inside test_hint_find_first_empty_cell and test_hint_find_empty_cell_after_some_filled tests.

closes #93
Added UML class diagram image and Component Diagram image to the report

closes #27
) #78

This was tested by running the docker build and seeing that the
error was removed. Which it was.

close #78
closes #147

Co-authored-by: Jonte <djonatanbolenius@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kenken command

5 participants