mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:50:45 +00:00
fixed pacing bug, improved expansion
This commit is contained in:
@@ -101,7 +101,8 @@
|
||||
* Make more colors DONE 9/8/2024
|
||||
* Have fake humans join lobby DONE 9/9/2024
|
||||
* Update landing page image DONE 9/9/2024
|
||||
* BUG: fix tile per turn pacing issues
|
||||
* BUG: fix tile per turn pacing issues DONE 9/9/2024
|
||||
* Improve expansion directions (more uniform) 9/9/2024
|
||||
|
||||
--- v3 Release
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 3.8 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 64 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB |
@@ -69,7 +69,7 @@ export class TerritoryRenderer {
|
||||
}
|
||||
}
|
||||
)
|
||||
bfs(event.boat.tile(), dist(event.boat.tile(), 2)).forEach(t => this.paintCell(t.cell(), this.theme.borderColor(event.boat.owner().id()), 255))
|
||||
bfs(event.boat.tile(), dist(event.boat.tile(), 2)).forEach(t => this.paintCell(t.cell(), this.theme.borderColor(event.boat.owner().id()), 180))
|
||||
bfs(event.boat.tile(), dist(event.boat.tile(), 1)).forEach(t => this.paintCell(t.cell(), this.theme.territoryColor(event.boat.owner().id()), 150))
|
||||
} else {
|
||||
trail.forEach(t => this.paintTerritory(t))
|
||||
|
||||
@@ -9,7 +9,7 @@ body {
|
||||
font-family: 'Overpass', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
/* body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@@ -20,7 +20,7 @@ body {
|
||||
background-position: center;
|
||||
background-attachment: fixed;
|
||||
background-blend-mode: overlay;
|
||||
}
|
||||
} */
|
||||
|
||||
.content {
|
||||
max-width: 1020px;
|
||||
|
||||
@@ -99,6 +99,7 @@ export interface TerraNullius {
|
||||
}
|
||||
|
||||
export interface Player {
|
||||
info(): PlayerInfo
|
||||
name(): string
|
||||
clientID(): ClientID
|
||||
id(): PlayerID
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {info} from "console";
|
||||
import {Config} from "./configuration/Config";
|
||||
import {EventBus} from "./EventBus";
|
||||
import {Cell, Execution, MutableGame, Game, MutablePlayer, PlayerEvent, PlayerID, PlayerInfo, Player, TerraNullius, Tile, TileEvent, Boat, MutableBoat, BoatEvent, TerrainType, PlayerType} from "./Game";
|
||||
|
||||
@@ -36,7 +36,7 @@ export interface Config {
|
||||
startTroops(playerInfo: PlayerInfo): number
|
||||
troopAdditionRate(player: Player): number
|
||||
attackTilesPerTick(attacker: Player, defender: Player | TerraNullius, numAdjacentTilesWithEnemy: number): number
|
||||
attackLogic(attacker: Player, defender: Player | TerraNullius, tileToConquer: Tile): {
|
||||
attackLogic(attackTroops: number, attacker: Player, defender: Player | TerraNullius, tileToConquer: Tile): {
|
||||
attackerTroopLoss: number,
|
||||
defenderTroopLoss: number,
|
||||
tilesPerTickUsed: number
|
||||
|
||||
@@ -33,21 +33,21 @@ export class DefaultConfig implements Config {
|
||||
}
|
||||
theme(): Theme {return pastelTheme;}
|
||||
|
||||
attackLogic(attacker: Player, defender: Player | TerraNullius, tileToConquer: Tile): {attackerTroopLoss: number; defenderTroopLoss: number; tilesPerTickUsed: number} {
|
||||
attackLogic(attackTroops: number, attacker: Player, defender: Player | TerraNullius, tileToConquer: Tile): {attackerTroopLoss: number; defenderTroopLoss: number; tilesPerTickUsed: number} {
|
||||
let mag = 0
|
||||
let speed = 0
|
||||
switch (tileToConquer.terrain()) {
|
||||
case TerrainType.Plains:
|
||||
mag = 5
|
||||
speed = 3
|
||||
speed = 10
|
||||
break
|
||||
case TerrainType.Highland:
|
||||
mag = 15
|
||||
speed = 5
|
||||
speed = 20
|
||||
break
|
||||
case TerrainType.Mountain:
|
||||
mag = 45
|
||||
speed = 10
|
||||
speed = 40
|
||||
break
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ export class DefaultConfig implements Config {
|
||||
return {
|
||||
attackerTroopLoss: within(defender.troops() / attacker.troops() * mag, 1, 1000),
|
||||
defenderTroopLoss: within(attacker.troops() / defender.troops(), 1, 1000),
|
||||
tilesPerTickUsed: within(attacker.numTilesOwned() / defender.numTilesOwned() / 2, 1, 5) * speed
|
||||
tilesPerTickUsed: within(defender.troops() / (attackTroops * 5), .2, 3) * speed
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
attackerTroopLoss: mag,
|
||||
defenderTroopLoss: 0,
|
||||
tilesPerTickUsed: Math.floor(Math.max(speed, 1))
|
||||
tilesPerTickUsed: within(this.startTroops(attacker.info()) / (attackTroops * 5), .2, 3) * speed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ export const pastelTheme = new class implements Theme {
|
||||
private land = colord({r: 194, g: 193, b: 148});
|
||||
private shore = colord({r: 204, g: 203, b: 158});
|
||||
|
||||
private water = colord({r: 110, g: 153, b: 181});
|
||||
private shorelineWater = colord({r: 100, g: 143, b: 171});
|
||||
private water = colord({r: 75, g: 142, b: 190});
|
||||
private shorelineWater = colord({r: 100, g: 143, b: 255});
|
||||
|
||||
private territoryColors: Colord[] = [
|
||||
colord({r: 230, g: 100, b: 100}), // Bright Red
|
||||
@@ -36,7 +36,6 @@ export const pastelTheme = new class implements Theme {
|
||||
colord({r: 230, g: 180, b: 180}), // Light Pink
|
||||
colord({r: 120, g: 120, b: 190}), // Periwinkle
|
||||
colord({r: 190, g: 170, b: 100}), // Sand
|
||||
colord({r: 160, g: 100, b: 100}), // Indian Red
|
||||
colord({r: 100, g: 180, b: 160}), // Aquamarine
|
||||
colord({r: 210, g: 160, b: 200}), // Orchid
|
||||
colord({r: 170, g: 190, b: 100}), // Yellow Green
|
||||
@@ -66,7 +65,6 @@ export const pastelTheme = new class implements Theme {
|
||||
colord({r: 180, g: 160, b: 180}), // Mauve
|
||||
colord({r: 160, g: 180, b: 140}), // Dark Olive Green
|
||||
colord({r: 170, g: 150, b: 170}), // Dusty Rose
|
||||
colord({r: 230, g: 100, b: 100}), // Bright Red
|
||||
colord({r: 100, g: 180, b: 230}), // Sky Blue
|
||||
colord({r: 230, g: 180, b: 80}), // Golden Yellow
|
||||
colord({r: 180, g: 100, b: 230}), // Purple
|
||||
@@ -86,7 +84,6 @@ export const pastelTheme = new class implements Theme {
|
||||
colord({r: 230, g: 180, b: 180}), // Light Pink
|
||||
colord({r: 120, g: 120, b: 190}), // Periwinkle
|
||||
colord({r: 190, g: 170, b: 100}), // Sand
|
||||
colord({r: 160, g: 100, b: 100}), // Indian Red
|
||||
colord({r: 100, g: 180, b: 160}), // Aquamarine
|
||||
colord({r: 210, g: 160, b: 200}), // Orchid
|
||||
colord({r: 170, g: 190, b: 100}), // Yellow Green
|
||||
@@ -164,14 +161,14 @@ export const pastelTheme = new class implements Theme {
|
||||
case TerrainType.Highland:
|
||||
return colord({
|
||||
r: 200 + 2 * mag,
|
||||
g: 193 + 2 * mag,
|
||||
g: 183 + 2 * mag,
|
||||
b: 138 + 2 * mag
|
||||
})
|
||||
case TerrainType.Mountain:
|
||||
return colord({
|
||||
r: 220 + mag,
|
||||
g: 220 + mag,
|
||||
b: 220 + mag
|
||||
r: 230 + mag / 2,
|
||||
g: 230 + mag / 2,
|
||||
b: 230 + mag / 2
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,12 @@ import {Terrain} from "../TerrainMapLoader";
|
||||
|
||||
export class AttackExecution implements Execution {
|
||||
private active: boolean = true;
|
||||
private toConquer: PriorityQueue<TileContainer> = new PriorityQueue<TileContainer>((a: TileContainer, b: TileContainer) => a.priority - b.priority);
|
||||
private toConquer: PriorityQueue<TileContainer> = new PriorityQueue<TileContainer>((a: TileContainer, b: TileContainer) => {
|
||||
if (a.priority == b.priority) {
|
||||
return a.tick - b.tick
|
||||
}
|
||||
return a.priority - b.priority
|
||||
});
|
||||
private random = new PseudoRandom(123)
|
||||
|
||||
private _owner: MutablePlayer
|
||||
@@ -113,7 +118,7 @@ export class AttackExecution implements Execution {
|
||||
continue
|
||||
}
|
||||
this.addNeighbors(tileToConquer)
|
||||
const {attackerTroopLoss, defenderTroopLoss, tilesPerTickUsed} = this.mg.config().attackLogic(this._owner, this.target, tileToConquer)
|
||||
const {attackerTroopLoss, defenderTroopLoss, tilesPerTickUsed} = this.mg.config().attackLogic(this.troops, this._owner, this.target, tileToConquer)
|
||||
numTilesPerTick -= tilesPerTickUsed
|
||||
this.troops -= attackerTroopLoss
|
||||
if (this.target.isPlayer()) {
|
||||
@@ -159,6 +164,7 @@ export class AttackExecution implements Execution {
|
||||
this.toConquer.enqueue(new TileContainer(
|
||||
neighbor,
|
||||
dist / 100 + this.random.nextInt(0, 3) - numOwnedByMe * 2 + mag,
|
||||
this.mg.ticks()
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -195,5 +201,5 @@ export class AttackExecution implements Execution {
|
||||
|
||||
|
||||
class TileContainer {
|
||||
constructor(public readonly tile: Tile, public readonly priority: number) { }
|
||||
constructor(public readonly tile: Tile, public readonly priority: number, public readonly tick: number) { }
|
||||
}
|
||||
@@ -60,9 +60,16 @@ export class BotExecution implements Execution {
|
||||
|
||||
const toAttack = border[this.random.nextInt(0, border.length)]
|
||||
const owner = toAttack.owner()
|
||||
if (owner.isPlayer() && (owner.type() == PlayerType.FakeHuman || owner.type() == PlayerType.Human)) {
|
||||
if (this.random.nextInt(0, 1) == 1) {
|
||||
return
|
||||
if (owner.isPlayer()) {
|
||||
if (owner.type() == PlayerType.FakeHuman) {
|
||||
if (!this.random.chance(4)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (owner.type() == PlayerType.Human) {
|
||||
if (this.random.chance(2)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
this.sendAttack(owner)
|
||||
|
||||
Reference in New Issue
Block a user