Fix Javascript BigInt to Number bug
This commit is contained in:
14
chess.js
14
chess.js
@@ -22,18 +22,6 @@ const WasmHost = (() => {
|
|||||||
return { load, getFn };
|
return { load, getFn };
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/*
|
|
||||||
static inline struct move wasm_MoveTo_move(uint64_t m)
|
|
||||||
{
|
|
||||||
return (struct move) {
|
|
||||||
.appeal = (m >> 24) & 0xFF,
|
|
||||||
.attr = (m >> 16) & 0xFF,
|
|
||||||
.from = (m >> 8) & 0xFF,
|
|
||||||
.to = (m >> 0) & 0xFF,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const MoveResult = Object.freeze({
|
const MoveResult = Object.freeze({
|
||||||
Normal: 0,
|
Normal: 0,
|
||||||
Check: 1,
|
Check: 1,
|
||||||
@@ -217,7 +205,7 @@ const run = async () => {
|
|||||||
console.log("from:", move.from.fileChar(), move.from.rankChar(),
|
console.log("from:", move.from.fileChar(), move.from.rankChar(),
|
||||||
"to:", move.to.fileChar(), move.to.rankChar());
|
"to:", move.to.fileChar(), move.to.rankChar());
|
||||||
|
|
||||||
const mr = wb_move(m);
|
const mr = wb_move(Number(m));
|
||||||
if (mr == MoveResult.Stalemate || mr == MoveResult.Checkmate) {
|
if (mr == MoveResult.Stalemate || mr == MoveResult.Checkmate) {
|
||||||
console.log(_moveResultName[mr]);
|
console.log(_moveResultName[mr]);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ uint64_t wb_search(int8_t max_depth)
|
|||||||
return move_serialize(sr.move);
|
return move_serialize(sr.move);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum move_result wb_move(uint32_t move)
|
int32_t wb_move(uint32_t move)
|
||||||
{
|
{
|
||||||
struct move m = move_deserialize(move);
|
struct move m = move_deserialize(move);
|
||||||
enum move_result const r = board_move_2(&g_board, m);
|
enum move_result const r = board_move_2(&g_board, m);
|
||||||
return r;
|
return (int32_t)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wb_init()
|
void wb_init()
|
||||||
|
|||||||
Reference in New Issue
Block a user