Shogi.js icon indicating copy to clipboard operation
Shogi.js copied to clipboard

Enforce checks for legal moves

Open na2hiro opened this issue 9 years ago • 1 comments

Background

This library was originally created for Kifu for JS which is a viewer of Kifus. This is why there are not exhaustive checks which would be needed for usages like UIs which allows inputs of moves.

Current status

Currently it checks legality in the following points:

  • [x] Turn is correct
  • [x] The move according to the type of piece is correct

(2018-02-24) Following checked were added

  • [x] Nifu (2 FU in the same column)
  • [x] Piece which can never move (行きどころのない駒)

The needs

It's not difficult to imagine some usages like to provide UI for playing Shogi. For such case we don't want allow users to input illegal moves.

Let's consider adding some more checks which would make sense:

  • [ ] checkmate by FU drop (打ち歩詰め)
  • [ ] Sennichite (千日手): same position appeared 4 times
  • [ ] Check Sennichite (王手千日手): same position appeared 4 times while one continuously check to the other
  • [ ] not avoiding check (王手無視)

There should be needs to handle illegal moves. Consider an option to accept such moves other than only throwing exceptions.

na2hiro avatar Feb 15 '15 18:02 na2hiro

0ef265de04acb8f8a44343a7803d3bb18bb5b7d2 で二歩と行き所のない駒の判定を追加.打ち歩詰め,千日手,王手千日手もあると良い.

na2hiro avatar Feb 24 '18 13:02 na2hiro