Live game foul probabilities reworked.

This commit is contained in:
gyboth 2009-03-08 11:34:30 +00:00
parent 67296fb402
commit 78fc4a8af7
9 changed files with 79 additions and 13 deletions

View File

@ -4,6 +4,9 @@
- added more meaning to autosave filenames (user, country etc.)
- added W-L-D and cup round robin rank info to the next opponent view
- added possibility to edit player names in the second player list
- corrected some supercup definition errors which resulted in
crashes
- foul probabilities in the live game are more sophisticated now
29/01/2009: v2.3.1
- added possibility for multiple tables in leagues (think

View File

@ -2993,7 +2993,7 @@ msgstr "Gehalt "
#. 'Wager' is the amount of money the user placed on a bet.
#: src/misc3_callbacks.c:162
msgid "Wager"
msgstr "Gehalt"
msgstr "Einsatz"
#. How much the user wagers; how much he won or lost.
#: src/treeview2.c:401
@ -3001,7 +3001,7 @@ msgid ""
"Wager/\n"
"Win/Loss"
msgstr ""
"Gehalt/\n"
"Einsatz/\n"
"Gewinn/Verlust"
#: src/treeview.c:1505

View File

@ -40,8 +40,8 @@
/**
* Program version number and year (copyright).
*/
#define VERS "2.3.1"
#define YEAR "2005 - 2008"
#define VERS "2.3.2"
#define YEAR "2005 - 2009"
/** Home dir name */
//#define HOMEDIRNAME ".bygfoot-cvs"

View File

@ -648,6 +648,37 @@ game_player_injury(Player *pl)
}
}
/** Calculate the probability of a foul event occurring. */
gfloat
game_get_foul_prob(const LiveGame *live_game, const LiveGameUnit *unit)
{
gfloat prob;
gint i;
/* Base probability (a linear function of match time). */
prob = const_float("float_live_game_foul_base") +
const_float("float_live_game_foul_max_inc") * MIN(1, (gfloat)(unit->minute) / 90);
/* Add possible boost influence of the team not in possession. */
prob *= (1 + live_game->fix->teams[!unit->possession]->boost *
const_float("float_team_boost_foul_factor"));
/* Reduce probability depending on the current cards of
the team not in possession, except if their boost is on. */
if(live_game->fix->teams[!unit->possession]->boost != 1)
{
for(i = 0; i < 11; i++)
if(g_array_index(live_game->fix->teams[!unit->possession]->players, Player, i).card_status ==
PLAYER_CARD_STATUS_YELLOW)
prob *= (1 - const_float("float_live_game_foul_prob_reduction_yellow"));
else if(g_array_index(live_game->fix->teams[!unit->possession]->players, Player, i).card_status ==
PLAYER_CARD_STATUS_RED)
prob *= (1 - const_float("float_live_game_foul_prob_reduction_red"));
}
return prob;
}
/** Return a factor influencing who's fouled whom
depending on the states of the team boosts.
@param boost1 Boost of the team in possession.

View File

@ -122,4 +122,7 @@ game_get_default_penalty_shooter(const Team *tm);
void
game_boost_cost(void);
gfloat
game_get_foul_prob(const LiveGame *live_game, const LiveGameUnit *unit);
#endif

View File

@ -232,9 +232,6 @@ live_game_fill_new_unit(LiveGameUnit *new)
(1 + (const_float("float_player_boost_injury_effect") *
(tm0->boost != 0 || tm1->boost != 0)));
foul_event_prob = const_float("float_live_game_foul") *
(1 + (tm0->boost + tm1->boost) * const_float("float_team_boost_foul_factor"));
new->possession = old->possession;
if(old->event.type == LIVE_GAME_EVENT_GENERAL)
@ -244,6 +241,8 @@ live_game_fill_new_unit(LiveGameUnit *new)
scoring_chance = const_float("float_live_game_scoring_chance") *
live_game_pit_teams(new, const_float("float_live_game_scoring_chance_team_exponent"));
foul_event_prob = game_get_foul_prob(match, new);
if(rndom < foul_event_prob)
new->event.type = LIVE_GAME_EVENT_FOUL;
else if(rndom < foul_event_prob +
@ -360,6 +359,7 @@ live_game_event_foul(void)
#endif
gfloat rndom = math_rnd(0, 1);
gfloat reduction_factor = 1;
gint type, fouled_player, foul_player, foul_team;
if((debug > 100 && stat2 != -1) ||
@ -393,16 +393,22 @@ live_game_event_foul(void)
last_unit.area, 0, -1, FALSE);
}
if(rndom < const_float("float_live_game_foul_red_injury"))
/* Probability of hard foul gets reduced if the player is already booked, except when boost is on. */
if(tms[foul_team]->boost != 1 &&
player_of_id_team(tms[foul_team], foul_player)->card_status == PLAYER_CARD_STATUS_YELLOW)
reduction_factor = 1 - const_float("float_live_game_foul_booked_reduction");
if(rndom < const_float("float_live_game_foul_red_injury") * reduction_factor)
type = LIVE_GAME_EVENT_FOUL_RED_INJURY;
else if(rndom < const_float("float_live_game_foul_red"))
else if(rndom < const_float("float_live_game_foul_red") * reduction_factor)
type = LIVE_GAME_EVENT_FOUL_RED;
else if(rndom < const_float("float_live_game_foul_yellow"))
else if(rndom < const_float("float_live_game_foul_yellow") * reduction_factor)
{
type = LIVE_GAME_EVENT_FOUL_YELLOW;
player_card_set(player_of_id_team(tms[foul_team], foul_player),
match->fix->clid, PLAYER_VALUE_CARD_YELLOW, 1, TRUE);
player_of_id_team(tms[foul_team], foul_player)->career[PLAYER_VALUE_CARD_YELLOW]++;
player_of_id_team(tms[foul_team], foul_player)->card_status = PLAYER_CARD_STATUS_YELLOW;
}
else
type = LIVE_GAME_EVENT_FOUL;
@ -420,6 +426,7 @@ live_game_event_foul(void)
query_live_game_second_yellow(foul_team, foul_player));
if(type == LIVE_GAME_EVENT_FOUL_RED_INJURY)
live_game_event_injury(!foul_team, fouled_player, TRUE);
player_of_id_team(tms[foul_team], foul_player)->card_status = PLAYER_CARD_STATUS_RED;
}
if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK && foul_team !=

View File

@ -94,6 +94,7 @@ player_new(Team *tm, gfloat average_talent, gboolean new_id)
const_float("float_player_lsu_upper"));
new.cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
new.games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals));
new.card_status = PLAYER_CARD_STATUS_NONE;
for(i=0;i<PLAYER_VALUE_END;i++)
new.career[i] = 0;
@ -1313,6 +1314,8 @@ player_update_post_match(Player *pl, const Fixture *fix)
player_card_set(pl, fix->clid, PLAYER_VALUE_CARD_RED, 1, FALSE);
}
pl->card_status = PLAYER_CARD_STATUS_NONE;
if(pl->cpos == PLAYER_POS_GOALIE &&
((fix->result[0][0] == 0 && fix->teams[1] == pl->team) ||
(fix->result[1][0] == 0 && fix->teams[0] == pl->team)))

View File

@ -109,6 +109,14 @@ enum PlayerValue
PLAYER_VALUE_END
};
/** Enumeration for the yellow/red
card status during the live game. */
enum PlayerCardStatus
{
PLAYER_CARD_STATUS_NONE = 0,
PLAYER_CARD_STATUS_YELLOW,
PLAYER_CARD_STATUS_RED
};
/**
Representation of a player.
@ -127,7 +135,8 @@ typedef struct
value, /**< Value of the player. */
wage, /**< Wage of the player. */
offers, /**< Number of times the player received a contract offer. */
streak; /**< The streak the player is on. */
streak, /**< The streak the player is on. */
card_status; /**< The card status of the player during a live game. */
gfloat skill, /**< Skill. Between 0 and a constant
(specified in the constants file). */

View File

@ -517,13 +517,23 @@ float_live_game_stadium_event_riots 30000
float_live_game_stadium_event_fire 10000
# foul probabilities.
float_live_game_foul 11000
float_live_game_foul_base 7000
float_live_game_foul_max_inc 8000
# if a team already got booked it fouls less often
float_live_game_foul_prob_reduction_yellow 10000
float_live_game_foul_prob_reduction_red 20000
# a player who's already booked fouls more carefully
float_live_game_foul_booked_reduction 50000
# probabilities for special foul consequences
float_live_game_foul_red_injury 1500
float_live_game_foul_red 3800
float_live_game_foul_yellow 28000
# ban duration probabilities
# should add up to 1000
# should add up to 100000
float_live_game_ban_1 70000
float_live_game_ban_2 15000
float_live_game_ban_3 10000