How linxin8/chinese-chess works
Project type and purpose
• This is a desktop “full‑stack” application (Windows Presentation Foundation on .NET) that integrates with a native C++ AI engine implementing minimax/α‑β/Negamax search and heuristic evaluation for Chinese Chess.
• The README confirms its focus: “基于极大极小算法的中国象棋程序” (a Chinese Chess program based on minimax).
File structure
• Top‐level solution (WpfApp.sln) contains two projects:
• WpfApp (C# / XAML): the UI and game controller
• DecisionTree (C++ .vcxproj): native chess‑AI engine
• WpfApp folder:
• App.xaml + MainWindow.xaml + code‑behind → UI layer
• Chess.cs, ChessBoard.xaml.cs, ChessGame.csproj → game model & controller
• GlobalRule.cs, LogicMap.cs → rule engine, board representation
• UserControl1.xaml → custom WPF control
• DecisionTree folder:
• bitboard.cpp/h, bittree.cpp/h → core data structures for board & game tree
• dllfunction.cpp/h → exported functions for P/Invoke
Key insights from README
• The engine implements: search tree abstraction, minimax, α‑β pruning, NegaMax, quiescent search, null‑window search, null‑move, move‐ordering heuristics, Zobrist hashing.
• No external services; all computation is in‐process.
Main components & interactions
a. Components:
– UI Layer (WPF Frontend)
– Game Controller / Model (C# classes: ChessGame, GlobalRule, LogicMap)
– Native AI Engine (C++ DLL: DecisionTree)
– Data Structures (Bitboard, BitTree)
– Cache/History Tables & Zobrist Hash Table
b. Interactions:
1. User clicks on board (MainWindow) → triggers ChessGame move request
2. ChessGame calls into DecisionTree via P/Invoke (dllfunction)
3. DecisionTree builds search tree (using BitBoard/BitTree), runs minimax/α‑β, returns best move
4. ChessGame applies move → UI updates ChessBoard
5. During engine run, history tables & Zobrist hash serve as internal caches
c. Architectural patterns & design principles:
– Separation of concerns: UI vs game logic vs AI engine
– Native‑managed boundary: C# ↔ C++ interop via DLL exports
– Algorithmic layering: core data structures at the bottom, search routines above, public API at top
d. Technologies/frameworks:
– .NET WPF (C#, XAML)
– Visual C++ (native DLL)
– P/Invoke for interop
– Bitboard representation, minimax variants, various search optimizations