New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert in attack_prediction.cpp / calculate_probability_of_debuff #2608

Closed
stevecotton opened this Issue Mar 7, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@stevecotton
Contributor

stevecotton commented Mar 7, 2018

Reproducible in 16f86dd432539f8bb135e9fe388914c835ec1045 (the current trunk). Load the not-attached* save game, end turn, and there's a roughly 50% chance that the assert will be hit during the AI turn. * not attached because GitHub is refusing it, I'll upload to the forums and add a link.

If I guess correctly, the bug requires three attacks in the AI turn, all attacking the same defender:

  • The first slows a unit.
  • The second is complex enough to use a Monte Carlo simulation. As the defender is already slowed, the chance of the defender being slowed is 1, but accumulating the results of simulations gives a distribution around 1.
  • The third attack is simple, doesn't use the MC simulation, but at attack_prediction.cpp:2423 passes the result of the second attack's MC simulation to calculate_probability_of_debuff()

The assert happens after the GUI has shown the first attack, when it's analysing further attacks.

It's useful for debugging to add an assert after attack_prediction.cpp:2431 that triggers when the Monte Carlo simulation calculates a greater-than-1 probability of being slowed. Without it, the other assert happens when a later call reaches attack_prediction.cpp:2423 and passes this greater-than-1 probability to calculate_probability_of_debuff().

@stevecotton

This comment has been minimized.

Contributor

stevecotton commented Mar 7, 2018

Save file is attached in https://forums.wesnoth.org/viewtopic.php?f=5&t=47804&p=624411#p624411

Similar to #2251, #2278 and #2342; but it's reproducible with the fixes for all of those. As @jyrkive said in #2342, no-one had reported the top-end assert firing.

@Vultraz Vultraz added the Bug label Mar 7, 2018

@jyrkive jyrkive closed this in 494b2f3 Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment