stockfish for godot
add uci ep support(?)
bendn 2022-09-14
parent f4a4d3f · commit d23acc7
-rw-r--r--addons/stockfish.gd/chess.gd7
-rw-r--r--addons/stockfish.gd/package.json2
2 files changed, 7 insertions, 2 deletions
diff --git a/addons/stockfish.gd/chess.gd b/addons/stockfish.gd/chess.gd
index 6dd9fb1..77f7c52 100644
--- a/addons/stockfish.gd/chess.gd
+++ b/addons/stockfish.gd/chess.gd
@@ -978,7 +978,7 @@ func __move_from_san(move, sloppy := false) -> Dictionary:
func __move_from_uci(uci: String) -> Dictionary:
- if len(uci) <= 5:
+ if len(uci) <= 5 and len(uci) >= 4:
var to: int = SQUARE_MAP[uci.substr(2, 4)]
var from: int = SQUARE_MAP[uci.substr(0, 2)]
var flags = BITS.NORMAL
@@ -989,6 +989,11 @@ func __move_from_uci(uci: String) -> Dictionary:
flags = BITS.KSIDE_CASTLE
if from - 2 == to:
flags = BITS.QSIDE_CASTLE
+ if board[from].get("type","") == PAWN:
+ var offsets = PAWN_OFFSETS[board[from].color].slice(2, 4)
+ for offset in offsets:
+ if from + offset == to and to == ep_square:
+ flags = BITS.EP_CAPTURE
return __build_move(from, to, flags, uci[5] if len(uci) == 5 else "")
return {}
diff --git a/addons/stockfish.gd/package.json b/addons/stockfish.gd/package.json
index 46a204b..a87f635 100644
--- a/addons/stockfish.gd/package.json
+++ b/addons/stockfish.gd/package.json
@@ -1,6 +1,6 @@
{
"name": "@bendn/stockfish.gd",
- "version": "1.2.2",
+ "version": "1.2.4",
"description": "godot stockfish",
"main": "stockfish_loader.gd",
"scripts": {