|
|
|
@ -37,18 +37,18 @@ class Roll(object):
@@ -37,18 +37,18 @@ class Roll(object):
|
|
|
|
|
|
|
|
|
|
# Map star ratings to new spaces |
|
|
|
|
# Expected outcome |
|
|
|
|
player_attr_min = 0.25 |
|
|
|
|
player_attr_max = 0.75 |
|
|
|
|
player_attr_min = 0.4 |
|
|
|
|
player_attr_max = 0.8 |
|
|
|
|
player_attr_space = np.linspace(player_attr_min, player_attr_max, nstars) |
|
|
|
|
# Consistency (alpha param of beta distribution) |
|
|
|
|
player_con_space = np.logspace(-0.5, 0.5, nstars) |
|
|
|
|
player_con_space = np.logspace(-0.4, 0.4, nstars) |
|
|
|
|
|
|
|
|
|
# Expected outcome |
|
|
|
|
gator_attr_min = 0.25 |
|
|
|
|
gator_attr_max = 0.75 |
|
|
|
|
gator_attr_min = 0.3 |
|
|
|
|
gator_attr_max = 0.6 |
|
|
|
|
gator_attr_space = np.linspace(gator_attr_min, gator_attr_max, nstars) |
|
|
|
|
# Consistency |
|
|
|
|
gator_con_space = np.logspace(-0.5, 0.5, nstars) |
|
|
|
|
gator_con_space = np.logspace(-0.4, 0.4, nstars) |
|
|
|
|
|
|
|
|
|
# Get attribute |
|
|
|
|
pa = player.attr[attr_lab] |
|
|
|
@ -70,7 +70,7 @@ class Roll(object):
@@ -70,7 +70,7 @@ class Roll(object):
|
|
|
|
|
return (p_outcome, g_outcome) |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def roll(cls, player, gator): |
|
|
|
|
def roll(cls, player, gator, context=None): |
|
|
|
|
""" |
|
|
|
|
Given a player and a gator, run the various rolls and find an outcome. |
|
|
|
|
""" |
|
|
|
@ -83,45 +83,52 @@ class Roll(object):
@@ -83,45 +83,52 @@ class Roll(object):
|
|
|
|
|
rea_diff = rea[0] - rea[1] |
|
|
|
|
rxn_diff = rxn[0] - rxn[1] |
|
|
|
|
|
|
|
|
|
if context: |
|
|
|
|
prefix = f"{context}: " |
|
|
|
|
else: |
|
|
|
|
prefix = "" |
|
|
|
|
|
|
|
|
|
if agg_diff > 0 and rea_diff > 0: |
|
|
|
|
# Player won |
|
|
|
|
if rxn_diff < 0: |
|
|
|
|
# Player won but gator got reversal |
|
|
|
|
logger.debug(f"Player flinched!") |
|
|
|
|
logger.debug(prefix + f"Player was about to poke but flinched!") |
|
|
|
|
return 0 |
|
|
|
|
else: |
|
|
|
|
# Outcome: runs |
|
|
|
|
diff = rxn[0] - rxn[1] |
|
|
|
|
if diff > 0.8: |
|
|
|
|
logger.debug(f"Gator got slapped!") |
|
|
|
|
if rxn_diff > 0.66: |
|
|
|
|
logger.debug(prefix + f"Gator got slapped!") |
|
|
|
|
return 6 |
|
|
|
|
elif diff > 0.5: |
|
|
|
|
logger.debug(f"Gator got booped in the snoot!") |
|
|
|
|
elif rxn_diff > 0.33: |
|
|
|
|
logger.debug(prefix + f"Gator got booped in the snoot!") |
|
|
|
|
return 4 |
|
|
|
|
else: |
|
|
|
|
logger.debug(f"Gator got poked!") |
|
|
|
|
elif rxn_diff > 0.05: |
|
|
|
|
logger.debug(prefix + f"Gator got poked!") |
|
|
|
|
return 1 |
|
|
|
|
else: |
|
|
|
|
logger.debug(prefix + f"Player poked wildly, missing the gator!") |
|
|
|
|
return 0 |
|
|
|
|
|
|
|
|
|
elif agg_diff < 0 and rea_diff < 0: |
|
|
|
|
# Gator won |
|
|
|
|
if rxn_diff > 0: |
|
|
|
|
# Gator won but player got reversal |
|
|
|
|
logger.debug(f"Gator flinched!") |
|
|
|
|
logger.debug(prefix + f"Gator was about to chomp but flinched!") |
|
|
|
|
return 0 |
|
|
|
|
else: |
|
|
|
|
# Outcome: wickets |
|
|
|
|
if abs(rxn_diff) > 0.8: |
|
|
|
|
logger.debug(f"Player was eaten by gator!") |
|
|
|
|
if abs(rxn_diff) > 0.66: |
|
|
|
|
logger.debug(prefix + f"Player was eaten by gator! **************************") |
|
|
|
|
return -3 |
|
|
|
|
elif abs(rxn_diff) > 0.5: |
|
|
|
|
logger.debug(f"Player's arm got chomped by the gator!") |
|
|
|
|
elif abs(rxn_diff) > 0.33: |
|
|
|
|
logger.debug(prefix + f"Player's arm chomped by gator!") |
|
|
|
|
return -2 |
|
|
|
|
elif abs(rxn_diff) > 0.2: |
|
|
|
|
logger.debug(f"Player's finger got chomped by the gator!") |
|
|
|
|
elif abs(rxn_diff) > 0.05: |
|
|
|
|
logger.debug(prefix + f"Player's finger chomped by gator!") |
|
|
|
|
return -1 |
|
|
|
|
else: |
|
|
|
|
logger.debug(f"Player escaped!") |
|
|
|
|
logger.debug(prefix + f"Gator chomped but narrowly missed!") |
|
|
|
|
return 0 |
|
|
|
|
else: |
|
|
|
|
logger.debug(f"Nothing happened!") |
|
|
|
|
logger.debug(prefix + f"The gator retreated...") |
|
|
|
|
return 0 |
|
|
|
|