feat(SCOPONE-0008): complete iteration 0 improve ai rules

This commit is contained in:
Giancarmine Salucci
2026-04-02 20:10:55 +02:00
parent e4edc4d660
commit 747da35190
6 changed files with 397 additions and 122 deletions

View File

@@ -61,6 +61,27 @@ export class CardTracker {
return this.getUnseenCards(myHand, table).filter(c => c.suit === suit).length;
}
/** Count how many unseen cards share a value */
countRemainingValue(value: number, myHand: Card[], table: Card[]): number {
return this.getUnseenCards(myHand, table).filter(c => c.value === value).length;
}
/** Probability that a hidden hand contains at least one card with the requested value */
probabilityHandHasValue(value: number, handSize: number, myHand: Card[], table: Card[]): number {
if (handSize <= 0) return 0;
const unseen = this.getUnseenCards(myHand, table);
const matching = unseen.filter(c => c.value === value).length;
if (matching === 0) return 0;
if (handSize >= unseen.length) return 1;
let probNone = 1;
for (let i = 0; i < handSize; i++) {
probNone *= Math.max(0, unseen.length - matching - i) / (unseen.length - i);
}
return 1 - probNone;
}
/** Get count of all played/seen cards */
get playedCount(): number {
return this.played.size;