feat(SCOPONE-0008): complete iteration 0 improve ai rules
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user