https@://codepen.io/HLKC779/pen/ZYbKPmG

#

🎯 Objective

• The goal is to checkmate the enemy General (King).

• Use your army to attack, defend, and control key lanes while protecting your own General.

🎲 Pieces & Movement

Symbol

Piece

Moves / Description

R

Chariot

Like the rook (♖) in Chess. Moves horizontally/vertically any distance.

H

Horse

Like the knight (♘), but blocked by adjacent pieces. L-shape movement.

E

Elephant

Moves 2 diagonal points. Cannot cross the river. Used for defense.

A

Advisor

Moves 1 point diagonally. Must stay in the 3×3 palace. Protects the General.

K

General

Stays in palace. Moves 1 step orthogonally. Can’t face opposing General directly.

C

Cannon

Moves like Rook. Attacks by jumping over a piece. Strategic and powerful!

S

Soldier

Moves 1 step forward. After crossing river, can also move sideways.

Unique Xiangqi Rules

• No face-off Generals: Generals cannot face each other without a piece between.

• River boundary: Elephants and Soldiers change behavior after crossing the river.

• Cannons jump to attack: Unique to Xiangqi, Cannons must leap over a piece to capture.

• Palace zones: Generals and Advisors must stay within a 3×3 square “palace”.

🤖 Benefits of AI Algorithm

Our game includes a Minimax-based AI engine, which:

• 🔁 Simulates future moves for both players to plan ahead

• 💡 Chooses optimal plays based on risk and reward

• ⚙️ Supports multiple difficulty levels:

• 🟢 Easy: Short-term strategy, basic tactics

• 🟡 Medium: Balanced play with better piece values

• 🔴 Hard: Deeper lookahead (2–3 turns), stronger defense and offense

Playing against AI helps sharpen your strategy by offering:

• Practice without needing a human opponent

• Insight into attack/defense patterns

• Opportunities to explore and learn from mistakes

🎮 How to Play

1. Click or tap a piece to select it.

2. Click on a valid destination to move.

3. You can restart or switch difficulty anytime.

4. Win by capturing the enemy General!

https@://codepen.io/HLKC779/pen/ZYbKPmG

2025/8/5 Edited to

... Read moreHey Xiangqi lovers! I've been diving deeper into some of the game's more intricate rules, and I wanted to share some of my findings, especially concerning those tricky pieces and unique strategies. First up, let's talk about the Cannon's powerful attacks. The article briefly mentions it, but understanding how it truly works is a game-changer. Unlike the Rook, which just moves and captures directly, the Cannon needs a "screen" or "pivot" piece to capture. This means there must be exactly one piece (any piece, yours or your opponent's) between the Cannon and its target. What I've learned is that this makes the Cannon incredibly versatile for long-range attacks and setting up traps. For example, if you have a Cannon on the 3rd rank and an enemy piece is on the 6th rank, with any piece on the 4th or 5th rank in between, your Cannon can jump over that intervening piece to capture the enemy. This often catches opponents off guard because they might not realize a piece they thought was safe is actually vulnerable to a Cannon's jump. I often use my Cannon to target pieces deep in the enemy's territory, especially when other pieces are creating screens. It's a fantastic way to control key files and prevent your opponent from developing. Next, let's tackle the Elephant's unique movement across the river. As noted, Elephants and Soldiers have different behaviors once they cross that central river boundary. For Elephants, this is a strict defensive piece. They move two points diagonally, but *cannot cross the river*. This means your Elephants are always confined to your half of the board, making them excellent pieces for protecting your General and forming a robust defensive wall. I remember one game where I tried to push my Elephant forward, only to realize it couldn't make the move because of the river. It was a lightbulb moment! This restriction forces you to think about your defensive setup differently. You'll often see players position their Elephants to guard the General's palace, creating a strong diagonal shield. It’s crucial to understand this limitation because it shapes your entire defensive strategy and prevents you from making illegal moves when you're under pressure. Finally, let's talk about a defensive strategy that beginners often overlook but is incredibly effective: the Screen Horse Defense. While my initial guide didn't cover specific openings or defenses, this one is worth learning. A "screen horse" refers to a Horse that is positioned to defend another key piece, often the General or an Advisor, by blocking potential attacks. Typically, this involves placing a Horse on a central file, often acting as a shield for your General. For instance, if your General is in the center of the palace, placing a Horse in front (on the appropriate diagonal) can block a Cannon or Chariot attack. The beauty of the screen horse is that it protects while also being a potential attacking piece itself. It's about creating a strong, interconnected defense where pieces support each other. I've found that implementing this early in the game makes my position much more resilient against aggressive openings. It's a great way to ensure your General stays safe while you develop your other pieces for offense. Understanding these nuances—the Cannon's jump, the Elephant's river boundary, and defensive formations like the Screen Horse—has definitely elevated my Xiangqi game. Don't be afraid to experiment with these ideas in your own matches, even against the AI! Happy playing!