Skip to content

Commit

Permalink
rename to UAS
Browse files Browse the repository at this point in the history
  • Loading branch information
EllAchE committed Nov 4, 2023
1 parent 4fefad4 commit 3eb7a5e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions cjsmin/src/chess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export type PrettyMove = {
capture?: Capture | undefined;
promotion?: PieceType | undefined;
flags: string;
uas: UAPSymbol;
uas: UASymbol;
};

export type UAPSymbol =
export type UASymbol =
| 'RA'
| 'NB'
| 'BC'
Expand Down Expand Up @@ -146,7 +146,7 @@ export const ALL_SQUARES: Square[] = [
]

// prettier-ignore
export const ALL_UNAMBIGUOUS_PIECE_SYMBOLS: UAPSymbol[] = [
export const ALL_UNAMBIGUOUS_PIECE_SYMBOLS: UASymbol[] = [
"RA", "NB", "BC", "Q", "K", "BF", "NG", "RH",
"PA", "PB", "PC", "PD", "PE", "PF", "PG", "PH",
"ra", "nb", "bc", "q", "k", "bf", "ng", "rh",
Expand All @@ -159,20 +159,20 @@ export const DEFAULT_POSITION =
export type Piece = {
color: Color;
type: PieceType;
uas: UAPSymbol;
uas: UASymbol;
};

type Capture = {
type: PieceType;
uas: UAPSymbol;
uas: UASymbol;
};

export type InternalMove = {
color: Color;
from: number;
to: number;
piece: PieceType;
uas: UAPSymbol;
uas: UASymbol;
capture?: Capture;
promotion?: PieceType;
flags: number;
Expand All @@ -197,7 +197,7 @@ export type Move = {
capture?: Capture;
promotion?: PieceType;
flags: string;
umabiguousSymbol: UAPSymbol;
umabiguousSymbol: UASymbol;
// san: string;
// lan: string;
// before: string;
Expand Down Expand Up @@ -612,7 +612,7 @@ function addMove(
from: number,
to: number,
piece: PieceType,
uas: UAPSymbol,
uas: UASymbol,
capture: Capture | undefined = undefined,
flags: number = BITS.NORMAL
) {
Expand Down Expand Up @@ -867,7 +867,7 @@ export class Chess {
square: Square
) {
//@ts-ignore this breaks for non init
const uas = SQUARE_TO_STARTING_POSITION_MAP[square] as UAPSymbol;
const uas = SQUARE_TO_STARTING_POSITION_MAP[square] as UASymbol;

// check for piece
if (SYMBOLS.indexOf(type.toLowerCase()) === -1) {
Expand Down Expand Up @@ -1304,7 +1304,7 @@ export class Chess {
this._board[from].uas,
{
type: PAWN,
uas: uas as UAPSymbol,
uas: uas as UASymbol,
},
BITS.EP_CAPTURE
);
Expand Down
4 changes: 2 additions & 2 deletions src/metrics/captures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Piece, PrettyMove, UAPSymbol } from '../../cjsmin/src/chess';
import { Piece, PrettyMove, UASymbol } from '../../cjsmin/src/chess';
import { UAPMap } from '../types';
import { createUAPMap } from '../utils';
import { Metric } from './metric';
Expand All @@ -24,7 +24,7 @@ export class KillStreakMetric implements Metric {
) {
let i = startingIndex;
let streakLength = 0;
let streakPiece: UAPSymbol;
let streakPiece: UASymbol;

while (i < game.length) {
const move = game[i].move;
Expand Down
12 changes: 6 additions & 6 deletions src/metrics/distances.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chess, Piece, PrettyMove, UAPSymbol } from '../../cjsmin/src/chess';
import { Chess, Piece, PrettyMove, UASymbol } from '../../cjsmin/src/chess';
import { FileReaderGame, UAPMap } from '../types';
import { createUAPMap } from '../utils';
import { Metric } from './metric';
Expand All @@ -13,7 +13,7 @@ export async function getMoveDistanceSingleGame(game: FileReaderGame) {

// Initialize variables to keep track of the maximum distance and the piece
let maxDistance = -1;
let maxDistancePiece: UAPSymbol;
let maxDistancePiece: UASymbol;
let singleGameDistanceTotal = 0;

// evaluate each move, update the correct unambiguous piece's distance
Expand Down Expand Up @@ -165,8 +165,8 @@ export async function getMoveDistanceSetOfGames(games: FileReaderGame[]) {

export class AverageDistanceMetric implements Metric {
distanceMap: UAPMap<{ totalDistance: number }>;
pieceWithHighestAvg: UAPSymbol;
pieceWithLowestAvg: UAPSymbol;
pieceWithHighestAvg: UASymbol;
pieceWithLowestAvg: UASymbol;
maxAvgDistance: number;
minAvgDistance: number;
totalDistance: number;
Expand All @@ -182,11 +182,11 @@ export class AverageDistanceMetric implements Metric {
const avgDistance = this.distanceMap[piece].totalDistance / gameCount;
if (avgDistance > this.maxAvgDistance) {
this.maxAvgDistance = avgDistance;
this.pieceWithHighestAvg = piece as UAPSymbol;
this.pieceWithHighestAvg = piece as UASymbol;
}
if (avgDistance < this.minAvgDistance) {
this.minAvgDistance = avgDistance;
this.pieceWithLowestAvg = piece as UAPSymbol;
this.pieceWithLowestAvg = piece as UASymbol;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Square, UAPSymbol } from '../cjsmin/src/chess';
import { Square, UASymbol } from '../cjsmin/src/chess';

export interface FileReaderGame {
moves: string;
metadata: string[];
}

export type UAPMap<T> = {
[key in UAPSymbol]: T;
[key in UASymbol]: T;
};

export type BoardMap = {
[key in Square]: {
[key in UAPSymbol]: {
[key in UASymbol]: {
captured: number;
captures: number;
revengeKills: number;
Expand Down

0 comments on commit 3eb7a5e

Please sign in to comment.