Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | 38x 10x 10x 28x 7x 3x 3x 4x | import { tCommon as translate } from "@multi-game-engines/i18n-common";
import { Brand,
EngineError,
EngineErrorCode,
Move,
createMove,
createPositionString,
PositionString,
IBaseSearchOptions,
IBaseSearchInfo,
IBaseSearchResult,
IScoreInfo,
createI18nKey } from "@multi-game-engines/core";
/**
* Janggi Move.
*/
export type JanggiMove = Brand<Move, "JanggiMove">;
/**
* Janggi Position string.
*/
export type JanggiPosition = PositionString<"JanggiPosition">;
/**
* Janggi search options.
*/
export interface IJanggiSearchOptions extends IBaseSearchOptions {
position?: JanggiPosition | undefined;
}
/**
* Janggi search info.
*/
export interface IJanggiSearchInfo extends IBaseSearchInfo {
score?: IScoreInfo | undefined;
}
/**
* Janggi search result.
*/
export interface IJanggiSearchResult extends IBaseSearchResult {
bestMove: JanggiMove | null;
}
/**
* Create a JanggiMove with validation.
*/
export function createJanggiMove(move: string): JanggiMove {
// Basic validation for Janggi move
if (!/^[a-i][0-9][a-i][0-9]$|^resign$|^pass$/.test(move)) {
const i18nKey = createI18nKey("engine.errors.invalidMoveFormat");
throw new EngineError({
code: EngineErrorCode.VALIDATION_ERROR,
message: translate(i18nKey, { move }),
i18nKey,
});
}
return createMove<"JanggiMove">(move);
}
/**
* Create a JanggiPosition string.
*/
export function createJanggiPosition(pos: string): JanggiPosition {
if (typeof pos !== "string" || pos.trim() === "") {
const i18nKey = createI18nKey("engine.errors.invalidPositionString");
throw new EngineError({
code: EngineErrorCode.VALIDATION_ERROR,
message: translate(i18nKey),
i18nKey,
});
}
return createPositionString<"JanggiPosition">(pos);
}
|