Skip to content

anthocote19/TKINTER-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Queen and Rook Game

1. Rules of the Game

Two players face each other on a square board with n rows and n columns, where n is an even integer. By default, n=8.

Pieces and Movements

  • Queen: Moves orthogonally or diagonally to an empty square, provided all squares between the starting and ending positions are empty (like a chess queen, but without capturing opposing pieces).
  • Rook: Moves orthogonally to an empty square, provided all squares between the starting and ending positions are empty (like a chess rook, but without capturing opposing pieces).

Initial Configuration

  • Each player starts with:
    • 1 queen.
    • n² // 4 - 1 rooks.

Capture Rules

  • After a rook moves, it can capture opposing rooks if it forms a rectangle with its queen.
  • Captures only occur when:
    • The moved rook and the queen of the same player form two vertices of a rectangle.
    • Opposing rooks are located on one or both of the other vertices of this rectangle.
  • Queens cannot capture, and they cannot be captured.

Victory Condition

  • A player loses when they have two or fewer pieces left (queen and rooks combined).

2. Implementation in Python

The game is implemented in Python with the Tkinter graphics library. Object-oriented programming principles and encapsulation must be strictly followed.

Classes

  • Player Class:

    • Attributes: Coordinates of the player's queen, number of remaining pieces.
  • Game Class:

    • Attributes: A 2D list modeling the game board and other necessary attributes.

Features

  1. Board Customization:
    • Choice of board size via a menu (n must be even and between 6 and 12).
  2. Game Display:
    • Visualization of the grid and pieces.
    • Indication of the current player's turn.
  3. Piece Selection:
    • Players select a piece to move using the mouse.
    • Selected pieces are visually highlighted (e.g., with a circle).
  4. Movement and Captures:
    • Enforce movement and capture rules.
  5. Turn Management:
    • Alternation of turns between players.
  6. Victory Condition:
    • Detect and display the winner.
  7. End of Game:
    • Show results and offer the option to start a new game.

Design Notes

  • The application must decouple algorithmic logic (game rules and board management) from graphical logic (display and event handling).

3. Bonuses

The following optional features provide additional functionality:

  • Move Preview:
    • Highlight playable moves for the selected piece.
  • Save and Load Game:
    • Save the current game state to a text file and resume it later.
  • Visual and Sound Effects:
    • Add animations and sounds for movements and captures.
  • AI Mode:
    • Play against the computer, either with random moves or an intelligent algorithm.

4. How to Run the Game

  1. Clone the repository:
    git clone <repository_url>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages