This commit is contained in:
BeGj
2025-03-07 16:53:10 +00:00
parent 0ddfc942a4
commit 619891741f
15 changed files with 28 additions and 22 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ export function manhattanDistWrapped(
dx = Math.min(dx, width - dx);
// Calculate y distance (no wrapping for y-axis)
let dy = Math.abs(c1.y - c2.y);
const dy = Math.abs(c1.y - c2.y);
// Return the sum of x and y distances
return dx + dy;
@@ -64,7 +64,7 @@ export function sourceDstOceanShore(
tile: TileRef,
): [TileRef | null, TileRef | null] {
const dst = gm.owner(tile);
let srcTile = closestShoreFromPlayer(gm, src, tile);
const srcTile = closestShoreFromPlayer(gm, src, tile);
let dstTile: TileRef | null = null;
if (dst.isPlayer()) {
dstTile = closestShoreFromPlayer(gm, dst as Player, tile);
+2 -2
View File
@@ -434,7 +434,7 @@ export class DefaultConfig implements Config {
}
maxPopulation(player: Player | PlayerView): number {
let maxPop =
const maxPop =
player.type() == PlayerType.Human && this.infiniteTroops()
? 1_000_000_000
: 2 * (Math.pow(player.numTilesOwned(), 0.6) * 1000 + 50000) +
@@ -461,7 +461,7 @@ export class DefaultConfig implements Config {
}
populationIncreaseRate(player: Player): number {
let max = this.maxPopulation(player);
const max = this.maxPopulation(player);
let toAdd = 10 + Math.pow(player.population(), 0.73) / 4;
+1 -1
View File
@@ -274,7 +274,7 @@ export const pastelTheme = new (class implements Theme {
}
terrainColor(gm: GameMap, tile: TileRef): Colord {
let mag = gm.magnitude(tile);
const mag = gm.magnitude(tile);
if (gm.isShore(tile)) {
return this.shore;
}
+1 -1
View File
@@ -274,7 +274,7 @@ export const pastelThemeDark = new (class implements Theme {
}
terrainColor(gm: GameMap, tile: TileRef): Colord {
let mag = gm.magnitude(tile);
const mag = gm.magnitude(tile);
if (gm.isShore(tile)) {
return this.shore;
}
+1 -1
View File
@@ -256,7 +256,7 @@ export class AttackExecution implements Execution {
let numOwnedByMe = this.mg
.neighbors(neighbor)
.filter((t) => this.mg.owner(t) == this._owner).length;
let dist = 0;
const dist = 0;
if (numOwnedByMe > 2) {
numOwnedByMe = 10;
}
+1 -1
View File
@@ -153,7 +153,7 @@ export class PlayerExecution implements Execution {
}
private isSurrounded(cluster: Set<TileRef>): boolean {
let enemyTiles = new Set<TileRef>();
const enemyTiles = new Set<TileRef>();
for (const tr of cluster) {
if (this.mg.isOceanShore(tr) || this.mg.isOnEdgeOfMap(tr)) {
return false;
+9 -4
View File
@@ -320,7 +320,12 @@ export class GameImpl implements Game {
}
addPlayer(playerInfo: PlayerInfo, manpower: number): Player {
let player = new PlayerImpl(this, this.nextPlayerID, playerInfo, manpower);
const player = new PlayerImpl(
this,
this.nextPlayerID,
playerInfo,
manpower,
);
this._playersBySmallID.push(player);
this.nextPlayerID++;
this._players.set(playerInfo.id, player);
@@ -378,7 +383,7 @@ export class GameImpl implements Game {
if (!this.isLand(tile)) {
throw Error(`cannot conquer water`);
}
let previousOwner = this.owner(tile) as TerraNullius | PlayerImpl;
const previousOwner = this.owner(tile) as TerraNullius | PlayerImpl;
if (previousOwner.isPlayer()) {
previousOwner._lastTileChange = this._ticks;
previousOwner._tiles.delete(tile);
@@ -403,7 +408,7 @@ export class GameImpl implements Game {
throw new Error("Cannot relinquish water");
}
let previousOwner = this.owner(tile) as PlayerImpl;
const previousOwner = this.owner(tile) as PlayerImpl;
previousOwner._lastTileChange = this._ticks;
previousOwner._tiles.delete(tile);
previousOwner._borderTiles.delete(tile);
@@ -438,7 +443,7 @@ export class GameImpl implements Game {
return false;
}
for (const neighbor of this.neighbors(tile)) {
let bordersEnemy = this.owner(tile) != this.owner(neighbor);
const bordersEnemy = this.owner(tile) != this.owner(neighbor);
if (bordersEnemy) {
return true;
}
+1 -1
View File
@@ -68,7 +68,7 @@ export async function loadTerrainFromFile(fileData: string): Promise<GameMap> {
function logBinaryAsAscii(data: string, length: number = 8) {
consolex.log("Binary data (1 = set bit, 0 = unset bit):");
for (let i = 0; i < Math.min(length, data.length); i++) {
let byte = data.charCodeAt(i);
const byte = data.charCodeAt(i);
let byteString = "";
for (let j = 7; j >= 0; j--) {
byteString += byte & (1 << j) ? "1" : "0";
+2 -1
View File
@@ -99,7 +99,8 @@ export class SerialAStar implements AStar {
const openSet = isForward ? this.fwdOpenSet : this.bwdOpenSet;
const cameFrom = isForward ? this.fwdCameFrom : this.bwdCameFrom;
let tentativeGScore = gScore.get(current)! + this.gameMap.cost(neighbor);
const tentativeGScore =
gScore.get(current)! + this.gameMap.cost(neighbor);
if (!gScore.has(neighbor) || tentativeGScore < gScore.get(neighbor)!) {
cameFrom.set(neighbor, current);