buttonmen-dev / buttonmen

Buttonmen - an online dice game
Other
16 stars 24 forks source link

randomai bug with Wildcard ace #2906

Closed cgolubi1 closed 1 year ago

cgolubi1 commented 1 year ago

This is my bug, but i can't immediately find how my logic is wrong, so i'm going to file it rather than submitting a fix right away. Given this game state (encountered on the Tournaments test site):

vhoodoo_vs_bruno_cant_find_power_attack

the backend says there's a valid Power attack, but RandomAI can't find it. The exception is:

ValueError: Progressing game 54 to completion failed: Could not find valid attack with function=<bound method LoggingBMClient._is_valid_attack_of_type_Power of <random_ai.LoggingBMClient instance at 0x7fbd28a98638>>,
  attackers=[
    {u'description': u'5-sided die', u'skills': [], u'recipe': u'(5)', u'value': 1, u'properties': [], u'sides': 5},
    {u'description': u'TimeAndSpace Shadow 9-sided die', u'skills': [u'TimeAndSpace', u'Shadow'], u'recipe': u'^s(9)', u'value': 5, u'properties': [], u'sides': 9},
    {u'description': u'Wildcard die', u'skills': [], u'recipe': u'(C)', u'wildcardPropsArray': {u'colour': u'black', u'type': u'Wildcard', u'displayedValue': u'A<span class="suit_black">&spades;</span>', u'suit': u'Spades'}, u'value': 1, u'properties': [], u'sides': 20},
    {u'description': u'Z Mood Swing Die (with 4 sides)', u'skills': [u'Mood'], u'recipe': u'(Z)?', u'value': 1, u'properties': [], u'sides': 4}
  ],
  defenders=[
    {u'description': u'Berserk 8-sided die', u'skills': [u'Berserk'], u'recipe': u'B(8)', u'value': 4, u'properties': [], u'sides': 8},
    {u'description': u'Berserk 20-sided die', u'skills': [u'Berserk'], u'recipe': u'B(20)', u'value': 6, u'properties': [], u'sides': 20},
    {u'description': u'Berserk 20-sided die', u'skills': [u'Berserk'], u'recipe': u'B(20)', u'value': 17, u'properties': [], u'sides': 20},
    {u'description': u'Berserk X Swing Die (with 18 sides)', u'skills': [u'Berserk'], u'recipe': u'B(X)', u'value': 8, u'properties': [], u'sides': 18}
  ]

At a glance, i don't understand what the problem is --- _is_valid_attack_of_type_Power() appears to handle the Wildcard Ace case, and i don't see a discrepancy between what that function is looking for and what the backend reports about the state of the dice.

But obviously something is broken, because here is this stacktrace.

blackshadowshade commented 1 year ago

I guess my only query here is whether your random_ai.py that you're running here is the up-to-date version that considers Wildcard in its logic.

cgolubi1 commented 1 year ago

Hah. Good call, no, the version i'm using for Tournament testing is out-of-date. Thanks!