simply start population calculation

This commit is contained in:
Evan
2025-02-03 12:37:04 -08:00
parent c109d23f9f
commit bbf72bd14f
7 changed files with 36 additions and 45 deletions
-1
View File
@@ -30,7 +30,6 @@ export class TopBar extends LitElement implements Layer {
if (!myPlayer?.isAlive() || this.game?.inSpawnPhase()) {
return html``;
}
console.log("rendering top bar");
const popRate = this.game.config().populationIncreaseRate(myPlayer) * 10;
const maxPop = this.game.config().maxPopulation(myPlayer);
const goldPerSecond = this.game.config().goldAdditionRate(myPlayer) * 10;
+4 -4
View File
@@ -307,10 +307,10 @@ export class DefaultConfig implements Config {
switch (this._gameConfig.difficulty) {
case Difficulty.Easy:
case Difficulty.Medium:
return 1000;
return 10000 * (playerInfo?.nation?.strength ?? 1);
case Difficulty.Hard:
case Difficulty.Impossible:
return 2000;
return 20000 * (playerInfo?.nation?.strength ?? 1);
}
}
return 25000;
@@ -346,10 +346,10 @@ export class DefaultConfig implements Config {
let difficultyMultiplier = 1;
switch (this._gameConfig.difficulty) {
case Difficulty.Easy:
difficultyMultiplier = 1;
difficultyMultiplier = 0.5;
break;
case Difficulty.Medium:
difficultyMultiplier = 1.2;
difficultyMultiplier = 0.8;
break;
case Difficulty.Hard:
difficultyMultiplier = 1.5;
+9 -9
View File
@@ -22,16 +22,16 @@ export class DevConfig extends DefaultConfig {
// return 100
}
unitInfo(type: UnitType): UnitInfo {
const info = super.unitInfo(type);
const oldCost = info.cost;
info.cost = (p: Player) => oldCost(p) / 1000000000;
return info;
}
// unitInfo(type: UnitType): UnitInfo {
// const info = super.unitInfo(type);
// const oldCost = info.cost;
// info.cost = (p: Player) => oldCost(p) / 1000000000;
// return info;
// }
tradeShipSpawnRate(): number {
return 10;
}
// tradeShipSpawnRate(): number {
// return 10;
// }
// percentageTilesOwnedToWin(): number {
// return 1
+4 -7
View File
@@ -155,6 +155,7 @@ export class Executor {
fakeHumanExecutions(): Execution[] {
const execs = [];
for (const nation of this.mg.nations()) {
console.log(`got nation: ${nation.name}`);
execs.push(
new FakeHumanExecution(
this.gameID,
@@ -162,13 +163,9 @@ export class Executor {
nation.name,
PlayerType.FakeHuman,
null,
this.random.nextID()
),
nation.cell,
nation.strength *
this.mg
.config()
.difficultyModifier(this.mg.config().gameConfig().difficulty)
this.random.nextID(),
nation
)
)
);
}
+4 -10
View File
@@ -43,12 +43,7 @@ export class FakeHumanExecution implements Execution {
private lastEnemyUpdateTick: number = 0;
private lastEmojiSent = new Map<Player, Tick>();
constructor(
gameID: GameID,
private playerInfo: PlayerInfo,
private cell: Cell,
private strength: number
) {
constructor(gameID: GameID, private playerInfo: PlayerInfo) {
this.random = new PseudoRandom(
simpleHash(playerInfo.id) + simpleHash(gameID)
);
@@ -77,8 +72,6 @@ export class FakeHumanExecution implements Execution {
this.player = this.mg.players().find((p) => p.id() == this.playerInfo.id);
if (this.player == null) {
return;
} else {
this.player.setTroops(this.player.troops() * this.strength);
}
}
if (this.firstMove) {
@@ -522,8 +515,9 @@ export class FakeHumanExecution implements Execution {
let tries = 0;
while (tries < 50) {
tries++;
const x = this.random.nextInt(this.cell.x - delta, this.cell.x + delta);
const y = this.random.nextInt(this.cell.y - delta, this.cell.y + delta);
const cell = this.playerInfo.nation.cell;
const x = this.random.nextInt(cell.x - delta, cell.x + delta);
const y = this.random.nextInt(cell.y - delta, cell.y + delta);
if (!this.mg.isValidCoord(x, y)) {
continue;
}
+2 -1
View File
@@ -158,7 +158,8 @@ export class PlayerInfo {
// null if bot.
public readonly clientID: ClientID | null,
// TODO: make player id the small id
public readonly id: PlayerID
public readonly id: PlayerID,
public readonly nation?: Nation | null
) {}
}
+13 -13
View File
@@ -36,7 +36,7 @@ export function createGame(
gameMap: GameMap,
miniGameMap: GameMap,
nationMap: NationMap,
config: Config,
config: Config
): Game {
return new GameImpl(gameMap, miniGameMap, nationMap, config);
}
@@ -70,7 +70,7 @@ export class GameImpl implements Game {
private _map: GameMap,
private miniGameMap: GameMap,
nationMap: NationMap,
private _config: Config,
private _config: Config
) {
this._terraNullius = new TerraNulliusImpl();
this._width = _map.width();
@@ -80,8 +80,8 @@ export class GameImpl implements Game {
new Nation(
n.name,
new Cell(n.coordinates[0], n.coordinates[1]),
n.strength,
),
n.strength
)
);
}
@@ -183,11 +183,11 @@ export class GameImpl implements Game {
this,
request.requestor() as PlayerImpl,
request.recipient() as PlayerImpl,
this._ticks,
this._ticks
);
this.alliances_.push(alliance);
(request.requestor() as PlayerImpl).pastOutgoingAllianceRequests.push(
request,
request
);
this.addUpdate({
type: GameUpdateType.AllianceRequestReply,
@@ -199,7 +199,7 @@ export class GameImpl implements Game {
rejectAllianceRequest(request: AllianceRequestImpl) {
this.allianceRequests = this.allianceRequests.filter((ar) => ar != request);
(request.requestor() as PlayerImpl).pastOutgoingAllianceRequests.push(
request,
request
);
this.addUpdate({
type: GameUpdateType.AllianceRequestReply,
@@ -306,7 +306,7 @@ export class GameImpl implements Game {
removeExecution(exec: Execution) {
this.execs = this.execs.filter((execution) => execution !== exec);
this.unInitExecs = this.unInitExecs.filter(
(execution) => execution !== exec,
(execution) => execution !== exec
);
}
@@ -459,7 +459,7 @@ export class GameImpl implements Game {
}
if (!breaker.isAlliedWith(other)) {
throw new Error(
`${breaker} not allied with ${other}, cannot break alliance`,
`${breaker} not allied with ${other}, cannot break alliance`
);
}
if (!other.isTraitor()) {
@@ -470,7 +470,7 @@ export class GameImpl implements Game {
const alliances = other.alliances().filter((a) => breakerSet.has(a));
if (alliances.length != 1) {
throw new Error(
`must have exactly one alliance, have ${alliances.length}`,
`must have exactly one alliance, have ${alliances.length}`
);
}
this.alliances_ = this.alliances_.filter((a) => a != alliances[0]);
@@ -489,7 +489,7 @@ export class GameImpl implements Game {
.filter((a) => p1Set.has(a));
if (alliances.length != 1) {
throw new Error(
`cannot expire alliance: must have exactly one alliance, have ${alliances.length}`,
`cannot expire alliance: must have exactly one alliance, have ${alliances.length}`
);
}
this.alliances_ = this.alliances_.filter((a) => a != alliances[0]);
@@ -517,7 +517,7 @@ export class GameImpl implements Game {
displayMessage(
message: string,
type: MessageType,
playerID: PlayerID | null,
playerID: PlayerID | null
): void {
let id = null;
if (playerID != null) {
@@ -614,7 +614,7 @@ export class GameImpl implements Game {
}
bfs(
tile: TileRef,
filter: (gm: GameMap, tile: TileRef) => boolean,
filter: (gm: GameMap, tile: TileRef) => boolean
): Set<TileRef> {
return this._map.bfs(tile, filter);
}