Skip to content

feat(kore): ts interpreter fixes #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ function boardTick(board:Board, agents: Agent[]) {
const playerKore = player.kore;
const shipyards = player.shipyards;
const fleets = player.fleets;
const shipsInShipards = shipyards.reduce((acc, shipyard) => acc + shipyard.shipCount, 0);
const canSpawn = shipyards.length > 0 && playerKore >= board.configuration.spawnCost;

if(agent.status === 'ACTIVE' && shipyards.length === 0 && fleets.length === 0) {
agent.status = 'DONE';
agent.reward = board.step - board.configuration.episodeSteps - 1;
}
if(agent.status === 'ACTIVE' && playerKore === 0 && fleets.length === 0 && !canSpawn) {
if(agent.status === 'ACTIVE' && shipsInShipards === 0 && fleets.length === 0 && !canSpawn) {
agent.status = 'DONE';
agent.reward = board.step - board.configuration.episodeSteps - 1;
}
Expand Down Expand Up @@ -230,7 +231,7 @@ async function stepAgent(episodes: number, agentsNames: string[], callback: Func
// rotate the board to the agent's perspective
// and assign agent action to game board
gameBoard.currentPlayerId = i;
agent.tickFunc(gameBoard);
await agent.tickFunc(gameBoard);

gameBoard.currentPlayer.shipyards.forEach(shipyard => {
// console.log(gameBoard.currentPlayerId, shipyard.position.toString(), shipyard.nextAction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export class Board {
for (let cell of board.cells) {
if (cell.fleetId === "" && cell.shipyardId === "") {
if (cell.kore < configuration.maxRegenCellKore) {
const nextKore = Board.roundToThreePlaces(cell.kore * (1 + configuration.regenRate) * 1000.0) / 1000.0;
const nextKore = Board.roundToThreePlaces(cell.kore * (1 + configuration.regenRate));
cell.kore = nextKore;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Fleet {
}

public get collectionRate(): number {
return Math.min(Math.log(this.shipCount) / 10, .99);
return Math.min(Math.log(this.shipCount) / 20, .99);
}

/**
Expand Down