Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bot doesn't play multiple cards #5

@aod

Description

@aod

The bot currently doesn't play multiple cards at all. There should be a random chance of the bot playing multiple cards when possible.

Things to change:

zhithead/src/bot.ts

Lines 8 to 15 in 8399216

if (visibleHand !== undefined) {
const playable = playableCards(pile);
const choice = visibleHand.filter((card) =>
playable.some((playableCard) => getRank(playableCard) === getRank(card))
);
if (!choice.length) return;
return choice[Math.floor(Math.random() * choice.length)];
}

Return an amount of cards when possible at a random chance.

if (e.type === "ASK_PICK_CARD") {
id = delayedTimeout(MIN_DELAY, MAX_DELAY, () =>
callback({
type: "CARD_CHOSEN",
card: bot(e.pile, e.player),
n: undefined,
})
);
}

Use that value returned by the bot function and pass it to the state machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions