跳转至

Chess 🚀#

约 413 个字 预计阅读时间 3 分钟

A Chinese chess program based on tkintertools and written in Python 3.12 and C++ 20.

This program is implemented using a mix of tkinter and tkintertools modules, tkintertools is a third-party Python module that I developed on my own to beautify tkinter and provide some advanced features! 🎉

Note

Since the original program was written by me one year ago, the tkintertools module uses the test version, and the AI of the program was added later, and the previous code quality is relatively poor, please understand. 😅

Star History#

Star History Chart

How to use#

Before use#

Info

Make sure your Python version is 3.12 or greater and C++ version is 20 or greater.

Choose the mode#

run the main.py and choose a game mode you want.

I’ve provided 4 modes, Three of them can be selected in “新游戏”,and “残局挑战” needs to be selected in the “棋局库”.

One last step#

have fun! 😁

Brief introduction#

Base Features#

  1. Two-player match
  2. Man-machine battles
  3. Endgame Challenge
  4. LAN connection

About the AI#

I’ve provided 2 AI algorithms, one of which also provides an implementation of C++20:

  1. Minimum-Max search algorithm
    • Python: min_max_search.py
  2. Alpha-beta pruning algorithm
    • Python: alpha_beta_search.py
    • C++ (default):
      • src: ./cpp/HelloWorld.cpp
      • dll: ./PyDLL.dll

You can change them in the settings. By the way, default value of the search depth is 4.

Tip

Due to the smaller number of pieces in endgame mode, the search space is smaller, and you can increase the AI’s search depth a little more, and the results could be even better!

Danger

You can also modify the pieces of the individual AI algorithms to evaluate the scores if you want, but be careful not to set the score to a limit value (like math.inf), which will cause the algorithm to not come up with the correct result!

Some really great features#

When you’re playing chess, the terminal actually has an output! For example:

SCORE: 2
STEP: 5
〇〇象士将士象马车
〇〇〇〇〇〇〇〇
炮马〇〇〇〇

〇〇〇〇〇〇〇〇〇
〇〇〇〇〇〇〇〇〇

〇〇〇〇
〇〇〇〇〇〇〇〇〇
車相仕帥仕相馬車

It provides a very clear picture of the game state and the current AI score.

Warning

Some of the pictures and other resources involved in the project come from the Internet and are not used for commercial purposes.
Please contact me for infringement: 2951256653@qq.com


If you want to know more about this program, see: https://xiaokang2022.blog.csdn.net/article/details/128852029