Skip to content

Commit 5c5333e

Browse files
committed
fix bot not playing into trash finesse
1 parent 920c311 commit 5c5333e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/conventions/h-group/clue-interpretation/interpret-clue.js

+13-16
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ export function interpret_clue(game, action) {
592592
return game;
593593
}
594594
}
595-
596595
// Check for forward trash finesses or bluffs at level 14
597596
if (game.level >= LEVEL.TRASH_PUSH) {
598597
// trash finesses are only valid if the clue initially reveals all cards to be playable or trash.
@@ -609,32 +608,30 @@ export function interpret_clue(game, action) {
609608
inbetween_players.push(i % game.players.length);
610609
}
611610
for (const p of inbetween_players) {
612-
if (p === game.me.playerIndex)
611+
if (p === state.ourPlayerIndex)
613612
continue;
614613
const first_unclued = state.hands[p].sort((a, b) => b-a).filter(c => !state.deck[c].clued)[0];
615-
// the leftmost unclued card is either the same color as the clue, or the same rank
616-
if ((clue.type === CLUE.COLOUR && state.deck[first_unclued].suitIndex === clue.value) ||
617-
clue.type === CLUE.RANK && state.deck[first_unclued].rank === clue.value)
614+
// the leftmost unclued card is either the same color as the clue, or the same rank, and is playable
615+
if (((clue.type === CLUE.COLOUR && state.deck[first_unclued].suitIndex === clue.value) ||
616+
clue.type === CLUE.RANK && state.deck[first_unclued].rank === clue.value) && !state.isBasicTrash(state.deck[first_unclued]))
618617
last_possible_player = p;
619618
}
620619
// if no one else has the card, we have it
621620
if (last_possible_player === -1) {
622-
if (giver === game.me.playerIndex) {
621+
if (giver === state.ourPlayerIndex) {
623622
game.interpretMove(CLUE_INTERP.MISTAKE);
624623
team_elim(game);
625624
return game;
626625
}
627-
last_possible_player = game.me.playerIndex;
626+
last_possible_player = state.ourPlayerIndex;
628627
}
629-
// Mark it as finessed
630628
const { possible } = common.thoughts[state.hands[last_possible_player].sort((a, b) => b-a).filter(c => !state.deck[c].clued)[0]];
631-
const new_inferred = possible.intersect(possible.filter(i => state.isBasicTrash(i)));
629+
const new_inferred = possible.intersect(possible.filter(i => state.isPlayable(i)));
632630
common.updateThoughts(state.hands[last_possible_player].sort((a, b) => b-a).filter(c => !state.deck[c].clued)[0],
633631
(draft) => {
634632
draft.inferred = new_inferred;
635633
draft.info_lock = new_inferred;
636634
draft.finessed = true;
637-
draft.possibly_bluffed = true;
638635
});
639636
for (const order of list) {
640637
if (!state.deck[order].newly_clued)
@@ -650,9 +647,9 @@ export function interpret_clue(game, action) {
650647
});
651648
}
652649

653-
perform_cm(state, common, tfcm_orders);
650+
perform_cm(state, common, tfcm_orders.filter(x=>x!=-1000));
654651

655-
game.interpretMove(CLUE_INTERP.CM_TRASH);
652+
game.interpretMove(CLUE_INTERP.PLAY);
656653
team_elim(game);
657654
return game;
658655
}
@@ -758,7 +755,7 @@ export function interpret_clue(game, action) {
758755
}
759756
}
760757
if (giver !== game.me.playerIndex)
761-
additional_possibilities.push(new BasicCard(state.deck[order_pushed].suitIndex, state.deck[order_pushed].rank))
758+
additional_possibilities.push(new BasicCard(state.deck[order_pushed].suitIndex, state.deck[order_pushed].rank));
762759
const new_inferred = possible.intersect(possible.filter(i => state.isPlayable(i) ||
763760
additional_possibilities.some(x => {
764761
return x.suitIndex === i.suitIndex && x.rank === i.rank;
@@ -1168,15 +1165,15 @@ function interpret_trash_finesse(game, action, focus_order) {
11681165
}
11691166
// check if all new cards are actually trash
11701167
for (const order of list) {
1171-
if (state.deck[order].newly_clued && !isTrash(state, mod_common, state.deck[order].identity, order, { infer: true }))
1168+
if (state.deck[order].newly_clued && !state.isBasicTrash(state.deck[order]))
11721169
return [];
11731170
}
11741171

11751172
const oldest_trash_index = state.hands[target].findLastIndex(o => state.deck[o].newly_clued);
11761173

11771174
logger.info(`oldest trash card is ${logCard(state.deck[state.hands[target][oldest_trash_index]])}`);
11781175

1179-
const cm_orders = [];
1176+
const cm_orders = [-1000];
11801177

11811178
// Chop move every unclued card to the right of this, since trash finesses do that
11821179
for (let i = oldest_trash_index + 1; i < state.hands[target].length; i++) {
@@ -1186,6 +1183,6 @@ function interpret_trash_finesse(game, action, focus_order) {
11861183
cm_orders.push(order);
11871184
}
11881185

1189-
logger.highlight('cyan', cm_orders.length === 0 ? 'no cards to tcm' : `trash chop move on ${cm_orders.map(o => logCard(state.deck[o])).join(',')} ${cm_orders}`);
1186+
logger.highlight('cyan', cm_orders.length === 0 ? 'no cards to tcm' : `trash chop move on ${cm_orders.filter(x=>x!=-1000).map(o => logCard(state.deck[o])).join(',')} ${cm_orders.filter(x=>x!=-1000)}`);
11901187
return cm_orders;
11911188
}

0 commit comments

Comments
 (0)