export class Position extends Data.Class<{
x: number;
y: number;
}> {
toString(): string {
return `(${this.x}, ${this.y})`;
}
getManhattanDistanceTo(other: Position): number {
return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);
}
isAdjacentTo(other: Position): boolean {
return Math.abs(this.x - other.x) + Math.abs(this.y - other.y) === 1;
}
}
export class Position extends Data.Class<{
x: number;
y: number;
}> {
toString(): string {
return `(${this.x}, ${this.y})`;
}
getManhattanDistanceTo(other: Position): number {
return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);
}
isAdjacentTo(other: Position): boolean {
return Math.abs(this.x - other.x) + Math.abs(this.y - other.y) === 1;
}
}