Skip to content
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

Bot doesn't play multiple cards #5

Open
aod opened this issue Sep 13, 2022 · 0 comments
Open

Bot doesn't play multiple cards #5

aod opened this issue Sep 13, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@aod
Copy link
Owner

aod commented Sep 13, 2022

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.

@aod aod added enhancement New feature or request good first issue Good for newcomers labels Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant