better partitioning, fix card table bug with extra 0 entries
This commit is contained in:
parent
79051b51fc
commit
21e2d05e93
3 changed files with 30 additions and 9 deletions
|
@ -53,5 +53,5 @@ Currently, on seeds 0-9999, we have:
|
||||||
| 2p | 3p | 4p | 5p |
|
| 2p | 3p | 4p | 5p |
|
||||||
----------|---------|---------|---------|---------|
|
----------|---------|---------|---------|---------|
|
||||||
cheating | 24.8600 | 24.9781 | 24.9715 | 24.9583 |
|
cheating | 24.8600 | 24.9781 | 24.9715 | 24.9583 |
|
||||||
info | 17.136 | 23.181 | 24.63 | 24.805 |
|
info | 17.147 | 23.357 | 24.76 | 24.824 |
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,9 @@ impl <'a> From<&'a CardCounts> for CardPossibilityTable {
|
||||||
for &value in VALUES.iter() {
|
for &value in VALUES.iter() {
|
||||||
let card = Card::new(color, value);
|
let card = Card::new(color, value);
|
||||||
let count = counts.remaining(&card);
|
let count = counts.remaining(&card);
|
||||||
possible.insert(card, count);
|
if count > 0 {
|
||||||
|
possible.insert(card, count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CardPossibilityTable {
|
CardPossibilityTable {
|
||||||
|
|
|
@ -165,18 +165,37 @@ struct CardPossibilityPartition {
|
||||||
}
|
}
|
||||||
impl CardPossibilityPartition {
|
impl CardPossibilityPartition {
|
||||||
fn new<T>(
|
fn new<T>(
|
||||||
index: usize, n_partitions: u32, card_table: &CardPossibilityTable, view: &T
|
index: usize, max_n_partitions: u32, card_table: &CardPossibilityTable, view: &T
|
||||||
) -> CardPossibilityPartition where T: GameView {
|
) -> CardPossibilityPartition where T: GameView {
|
||||||
let mut cur_block = 0;
|
let mut cur_block = 0;
|
||||||
let mut partition = HashMap::new();
|
let mut partition = HashMap::new();
|
||||||
|
let mut n_partitions = 0;
|
||||||
|
|
||||||
|
let has_dead = card_table.probability_is_dead(view.get_board()) != 0.0;
|
||||||
|
|
||||||
|
let effective_max = if has_dead {
|
||||||
|
max_n_partitions - 1
|
||||||
|
} else {
|
||||||
|
max_n_partitions
|
||||||
|
};
|
||||||
|
|
||||||
for card in card_table.get_possibilities() {
|
for card in card_table.get_possibilities() {
|
||||||
let mut block = cur_block;
|
if !view.get_board().is_dead(&card) {
|
||||||
if view.get_board().is_dead(&card) {
|
partition.insert(card.clone(), cur_block);
|
||||||
block = n_partitions - 1;
|
cur_block = (cur_block + 1) % effective_max;
|
||||||
} else {
|
if n_partitions < effective_max {
|
||||||
cur_block = (cur_block + 1) % (n_partitions - 1);
|
n_partitions += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
partition.insert(card.clone(), block);
|
}
|
||||||
|
|
||||||
|
if has_dead {
|
||||||
|
for card in card_table.get_possibilities() {
|
||||||
|
if view.get_board().is_dead(&card) {
|
||||||
|
partition.insert(card.clone(), n_partitions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n_partitions += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardPossibilityPartition {
|
CardPossibilityPartition {
|
||||||
|
|
Loading…
Reference in a new issue