Skip to content

Commit

Permalink
Bug fixes:
Browse files Browse the repository at this point in the history
- when parcels are removed from the MCTS when expired
- added player row to cost matrix
  • Loading branch information
frangente committed Jan 29, 2024
1 parent 1ce4710 commit c400954
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/domain/planner/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ export class Node {
totalVisitDiff += visitDiff;
}
} else if (intention.type === IntentionType.PICKUP) {
const utilitDiff = this.partialRemoveParcel(parcelID, value);
totalUtilityDiff += utilitDiff;
if (this.children.length > i) {
const child = this.children[i];
const utilitDiff = child.partialRemoveParcel(parcelID, value);
totalUtilityDiff += utilitDiff;
}

const parcels = this.beliefs.getParcelsByPosition(intention.position);
if (parcels.length === 0) {
Expand Down Expand Up @@ -301,7 +304,7 @@ export class Node {

switch (nextIntention.type) {
case IntentionType.PUTDOWN: {
pickedParcels = this.state.pickedParcels;
pickedParcels = [...this.state.pickedParcels];
break;
}
case IntentionType.PICKUP: {
Expand Down
14 changes: 7 additions & 7 deletions src/domain/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,10 @@ export class Player {
)!;
}
} else {
throw new Error("When do we get here?");
// possibleDirections = this._beliefs.map.getNextDirection(
// this._position,
// intention.position,
// )!;
possibleDirections = this._beliefs.map.getNextDirection(
this._position,
intention.position,
)!;
}

let hasMoved = false;
Expand Down Expand Up @@ -278,7 +277,7 @@ export class Player {
};
await this._sendMessage(message);

if (allScoresZero) {
if (allScoresZero && numPutdowns > 0) {
if (numUnreachablePutdowns < numPutdowns) {
return this._getBestMoveIntention();
}
Expand Down Expand Up @@ -466,7 +465,8 @@ export class Player {
intentionUtilities: [Intention, number][],
): number[][] {
const matrix: number[][] = [];
for (let i = 0; i < mateToIdx.size; i++) {
// mateToIdx + 1 because the first row is for the player
for (let i = 0; i < mateToIdx.size + 1; i++) {
matrix.push(new Array(mateToIdx.size).fill(0));
}

Expand Down
2 changes: 0 additions & 2 deletions src/domain/structs/parcel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ export class Parcel {
}

public static deserialize(serialized: string): Parcel {
// console.log(serialized);
const obj = JSON.parse(serialized);
// console.log('obj', obj)
return new Parcel(
ParcelID.deserialize(obj.id),
DecayingValue.deserialize(obj.value),
Expand Down

0 comments on commit c400954

Please sign in to comment.