WillFlame14 / hanabi-bot

A bot that plays on the hanab.live interface.
GNU General Public License v3.0
15 stars 9 forks source link

Avoid cluing cards that may be duplicated #235

Closed flackr closed 4 months ago

flackr commented 4 months ago

This calculates a duplicate score which is the number of newly clued cards which could overlap our own clued cards minus the minimum such score for other players (e.g. unavoidable potential duplication) and avoids clues with a non zero score when possible.

flackr commented 4 months ago

This is still a bit rough, but it's an experiment to address some of the avoidable duplication situations. Note that without level restrictions on tests this fails the endgame test solves a cluable endgame.

WillFlame14 commented 4 months ago

This looks pretty good at a glance, but have you noticed a positive difference in games? I'm not completely sure, it seems like other mistakes might be hiding the effect. :sweat_smile:

flackr commented 4 months ago

This looks pretty good at a glance, but have you noticed a positive difference in games? I'm not completely sure, it seems like other mistakes might be hiding the effect. 😅

I do feel like it has benefitted the games I've played with it. I think when playing less than level 12 this should be strictly an improvement as it will prefer clues that avoid duplication.

I strongly suspect at level 12 it should still be allowed to clue potential duplicates in some cases rather than ignoring those clues entirely. E.g. this is necessary in some end games for good tempo. That said, level 12 is still incomplete and anyone playing it is doing so at their own risk of discovering these edge cases :-)

flackr commented 4 months ago

I strongly suspect at level 12 it should still be allowed to clue potential duplicates in some cases rather than ignoring those clues entirely. E.g. this is necessary in some end games for good tempo. That said, level 12 is still incomplete and anyone playing it is doing so at their own risk of discovering these edge cases :-)

Though it's worth noting that even if I use this avoidance code regardless of level the branch currently passes all tests, even the earlier mentioned endgame test

WillFlame14 commented 4 months ago

I strongly suspect at level 12 it should still be allowed to clue potential duplicates in some cases rather than ignoring those clues entirely. E.g. this is necessary in some end games for good tempo. That said, level 12 is still incomplete and anyone playing it is doing so at their own risk of discovering these edge cases :-)

I definitely agree! I think there's also an element of others being able to perform the save in the first place. For example (seed 296): image Would you prefer giving a stall clue over saving Bob's 2's? Alice will be busy playing into the finesse (to help unlock you), and it's very likely Bob will discard on his next turn.

I think this PR is a step in the right direction, we can always tune the specifics later. :slightly_smiling_face: I don't want to explicitly support level 12 though (possibly ever), because in general I think context results in a ton of misunderstandings even when playing with a human. General principles like duplication responsibility, selfish clues, etc. should apply to all levels.

flackr commented 4 months ago

Right. I agree, most of these things can just be done at all levels which is why I put the score reduction on clues with potential duplication at all levels.

There is however the question of can you expect others to give the 2 save for you (assuming they had time to) because they know you don’t know which 2s you have.

E.g. in your example at level 12 Donald should trust that if the 2s don’t match someone else will clue it (in this case Alice) or that Cathy wouldn’t 2 save Donald if no one else could save the other 2s. It can be really frustrating if for example both of those 2s match Donald’s and that’s why Cathy saved Donald instead of Bob or letting Donald save Bob.

I think there are tempo exceptions, though they should mostly be allowed by the addition that you can create known duplicates, and not yet handled but cases where no one else had time to clue the cards.

WillFlame14 commented 4 months ago

In the example, Cathy needs to clue either Bob or Donald since it's still Early Game. The fact that she clues Donald means that this save is urgent (i.e. Donald's chop is not r2 or g2). Otherwise, she would clue Bob and let Donald discard. Also, Bob's g2 may need to be saved regardless of whether r2 is duplicated or not. Donald knows he has y2 in slot 1, so the likelihood of Donald not holding the copy of g2 is 5/6 * 4/6 = 55.6%.

The likelihood of both g2 and r2 being in Donald's hand is only 2/6 * 1/6 = 5.56%, but it probably feels extra bad when you see it happen. Even though Alice is in the best place to make a decision, I think Donald giving the save here is better for tempo and efficiency so Alice can play into the finesse, but I do think this is more of a playstyle rather than a solid rule.

Figuring out such situations can probably be done in a similar way to clue_safe(), but might be beyond the scope of this PR.