Skip to content

Conversation

yufanana
Copy link

@yufanana yufanana commented Apr 1, 2024

Reorganisation changes

  • gui/: new package to contain GUI-related sections
  • renamed custom_bots package to bots
  • game_logic/player.py: split into separate files for human and each bot

General code modifications

  • Formatted code with ruff
  • Avoided the use of * star imports
  • Added docstrings to classes and functions
  • Added comments to explain the code
  • Improved general readability
  • pre-commit file to help code formatting

New features

  • Path visualization: instead of highlighting the start and end piece only, the entire path taken by the piece is indicated with purple dots. this helps to track the performance of bots. The path is obtained using breadth-first-search, see getMovePath() in game_logic/game.py
  • Turn indicator: to help keep track of game progress in the gameplay window, see gui/gui_helpers.py.
  • Player names: to help keep track of players in the gameplay window, see gui/gui_helpers.py.
  • Number of pieces: possible to start with 10 or 15 pieces, see game_logic/layout.py, configured in main.py.
  • Layouts: possible to start with mirror or triangle layout, see game_logic/layout.py, configured in main.py.
  • Autoplay: autoplay button to autoplay replays, see replayLoop() in gui/loops.py.
  • 1-3 players: select 1-3 players instead of 2-3 players in loadPlayer window.
  • 1-6 players: possible to have up to 6 players if the players are loaded in another way besides from the loadPlayer window.

@henrychess
Copy link
Owner

henrychess commented Apr 1, 2024 via email

@yufanana
Copy link
Author

yufanana commented Apr 1, 2024

Hi, your repository was very helpful for a course that I am taking at the Technical University of Denmark. My group used it for a project, and made some improvements to it, so it was not a big issue to create a pull request and contribute back to the repository. Take your time to review the pull request, and hopefully you can take away a few of the good coding practices that you see. Thanks again :)

@henrychess
Copy link
Owner

henrychess commented Apr 7, 2024

Hey, I see a bug!

This occurs when I try to change the number of players to 1 or 2:

Traceback (most recent call last):
  File "/Users/andytseng/Downloads/pygame-chinese-checkers-yufanana/gui/loops.py", line 242, in <lambda>
    lambda: setItem(
  File "/Users/andytseng/Downloads/pygame-chinese-checkers-yufanana/game_logic/helpers.py", line 70, in setItem
    list_[index] = item
IndexError: list assignment index out of range
[<bots.GreedyBot2.GreedyBot2 object at 0x7fa599d4d130>]
Traceback (most recent call last):
  File "/Users/andytseng/Downloads/pygame-chinese-checkers-yufanana/gui/loops.py", line 227, in <lambda>
    rButton_2P.toggled.connect(lambda: setItem(self.playerList, 2, None))
  File "/Users/andytseng/Downloads/pygame-chinese-checkers-yufanana/game_logic/helpers.py", line 70, in setItem
    list_[index] = item
IndexError: list assignment index out of range
[<bots.GreedyBot2.GreedyBot2 object at 0x7fa599d4d130>]

The game does not crash on this error message; however, if I click play, there is only one player present.

Also, the option to switch between 10/15 pieces per player is missing, and the buttons are somehow not responding to mouse hover.

Btw the trainingLoop is intended for a possible expansion to make machine learning easier on this game. It's a GUIless gameplay loop which returns all the necessary numbers.

That's all the things I have for this pull request for now, but maybe I'll find some more issues or explain some more stuff later on.

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.

2 participants