“I am participating in the nuggets Community Game Creativity Submission Contest. For details, please see: Game Creativity Submission Contest.”

Writing in the front

Code repository, go by and click a Star ✨

In contact with some board games as a child, gobang, Chinese chess, chess, and so on, which play renju, best to contact the chess under a coincidence, recently watched it again rules (I’ve forgotten about, of course, may also do not have carefully studied in childhood, such as castling, points short translocation and translocation of two). I downloaded some apps, such as National Elephant Alliance and Lichess, and finished watching the Neflix drama “Rear Wing Abandon Soldier” over the weekend. In fact, I started to write the code last week. I write this article because several versions of the code have been written, and I want to share the process and experience of writing the code.

Chess rules

Know pieces

  • ♙ Pawn starts from the starting position, the first step can be one or two squares, then can only arch, oblique eating;
  • ♘ a horse (Knight) will not have the same footwork as a Chinese chess;
  • ♗ an elephant (Bishop) can walk diagonally all the way, in an X shape;
  • ♖ rook (Rock) can walk horizontally and vertically, like Chinese chess, in the shape of a cross;
  • Queen of the Queen of the Queen of the Queen of the Queen of the Queen of the Queen of the Queen of the Queen of the Queen of the Queen of the Queen of the Queen.
  • ♔ Wang (King) is also walk meters word, but can only walk a lattice;

Of course the above translation is a reference to the pieces in Chinese chess, which may actually be called knight, castle, bishop.

Some simple rules

Promotion litres of soldiers

[Fixed] When you reach the last square, you can become all the other pieces except yourself and the king.

Castling Castling changed position

Three conditions need to be met:

  1. The king or the car did not move at this station
  2. There was no obstacle between the chariots, the horses and elephants were outside
  3. This rule cannot be used when a king is attacked while being checkmate or while moving

Translocations are divided into long translocations and short translocations:

  • Long transposition, the king moves two squares back, then the rook is placed to the other side of the king’s movement
  • Short translocation, the king moves two squares back in the opposite direction, and the rook is placed to the other side of the king’s movement

En passant eats a passer

According to the rules of chess, a pawn in the fifth row may be eaten by the enemy if the adjacent pawn advances one space from the starting position. According to the rule of passing pawns, even if the enemy’s adjacent pawns advance two squares from the starting position, the former can still eat the latter and occupy the same position as the enemy pawns after advancing only one square. There are several conditions for a wayfarer.

  • The pawn who wants to eat the son must be in the fifth row.
  • The pawn to be gobbled must be in an adjacent column and move two squares at a time.
  • Passing is optional. If you want to play, you must play immediately after the opponent’s next move, or you lose the chance.