optimize to use 1 less bit for color
This commit is contained in:
parent
05debd41f1
commit
b9b7937a96
1 changed files with 4 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ import { Game } from "./utils";
|
||||||
export type GameListener = (board: Game) => void;
|
export type GameListener = (board: Game) => void;
|
||||||
|
|
||||||
export enum Piece {
|
export enum Piece {
|
||||||
|
// bit 0-2: piece type (0-6)
|
||||||
EMPTY = 0,
|
EMPTY = 0,
|
||||||
KING = 1,
|
KING = 1,
|
||||||
QUEEN = 2,
|
QUEEN = 2,
|
||||||
|
|
@ -10,8 +11,9 @@ export enum Piece {
|
||||||
KNIGHT = 5,
|
KNIGHT = 5,
|
||||||
PAWN = 6,
|
PAWN = 6,
|
||||||
|
|
||||||
WHITE = 8,
|
// bit 3: color (0-1)
|
||||||
BLACK = 16,
|
WHITE = 0,
|
||||||
|
BLACK = 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CHAR_TO_PIECE: Record<string, number> = {
|
export const CHAR_TO_PIECE: Record<string, number> = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue