Inconsistent replays

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Post Reply
ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Inconsistent replays

Post by ott »

Over at topic http://www.wesnoth.org/forum/viewtopic.php?t=3491
it was pointed out that several of the posted 0.8.5 replays were corrupt. Investigating more closely, it seems that at least one of the causes of corruption is the following error:

Code: Select all

up to replay action 499/935
up to replay action 500/935
unit 'Elvish Fighter' is too expensive to recruit: 14/13
caught replay::error
result of replay: false
The AI was recruiting Elves (the player can only recruit Walking Corpses in this map). So this seems either to be a case of the AI cheating in the original game, buying a unit costing 14 when only having 13 available, or some kind of inconsistency to do with replays.

Are unit traits preserved across replays? The above could have happened if some of the level 2/3 AI units in the original game were Loyal, but not in the replay. Or are the random numbers stored in replays insufficiently accurate, leading to small deviations in replays from the original game?

I've been seeing inexplicable corruption in replays since I started playing with 0.8. It is difficult to provide balancing feedback to campaign creators when replays are often corrupt, so it would be nice to have this fixed before 1.0.
ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Post by ott »

This is repeatable, the error always occurs on action 500.

Looking at the 0.8.5 code, there is a definite check for enough gold, so it seems unlikely to be the AI cheating during the original game.

I did notice a slight inconsistency, possibly unrelated: in ai::recruit_usage() there is

Code: Select all

if(i->second.usage() == usage && recruits.count(name)
     && current_team().gold() - i->second.cost() > min_gold
where min_gold is a constant 0, while in ai_interface::recruit() there is the snippet

Code: Select all

//check we have enough money
if(current_team().gold() < u->second.cost()) {
    return false;
}
The first snippet will stop recruitment when (i->second.cost() >= current_team().gold()), while the second will only stop recruitment when (u->second.cost() > current_team().gold()) so when there is exactly enough gold to recruit the unit being considered, the first test will fail while the second will succeed. Possibly a problem?

Continuing to investigate.
ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Post by ott »

Of my 0.8.5 single player games, around half turn out to be corrupt when replaying them.

The error is always the same, with the AI recruiting a unit it apparently cannot afford. Also, the corruption is deterministic (ie. trying to replay again gives an error in the same place). This applies to full replays as well as the Show Replay option for normal saved games. Once a saved game is corrupt then any subsequent saves of that scenario are corrupt also, at the same place.

If this can't be fixed for 1.0 then I suggest disabling replays altogether, it's going to lead to fewer headaches than leaving them buggy.

I cleared the .wesnoth/cache/ directory in case it was causing problems, but this had no effect on the replays. Here is a list of replays with problems. Notice that this is not just an off-by-one error, in one instance the AI seems to have recruited a cost 18 unit when it only had 7 gold.

Underground Pool, turn 9:
up to replay action 92/546
unit 'Dwarvish Fighter' is too expensive to recruit: 17/16
caught replay::error

Confrontation, turn 2:
up to replay action 87/2234
unit 'Fencer' is too expensive to recruit: 18/7
caught replay::error
result of replay: false

Crelanu's Book, turn 6:
up to replay action 500/935
unit 'Elvish Fighter' is too expensive to recruit: 14/13
caught replay::error

A Summer of Storms, turn 8:
up to replay action 173/524
unit 'Thief' is too expensive to recruit: 12/10
caught replay::error

A Summer of Storms, turn 8 (different game):
up to replay action 168/551
unit 'Thug' is too expensive to recruit: 13/9
caught replay::error
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

Please post a bug-report on savannah if you haven't already done so.
ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Post by ott »

silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

Thanks. The off-by-one inconsistency you quote is not related to the problem at hand.

Just in case. Did you make the whole scenarios under 0.8.5? Or did you start them in the middle from an older savefile?
ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Post by ott »

Upgraded to 0.8.5 on 7 October, and started fresh campaigns for both The Dark Hordes (3 of the replays) and Liberty 1.1.3 (the other 2). The reason I upgraded was to be able to play Liberty, which requires 0.8.3. Had to start TDH from scratch since ghosts were changed significantly after 0.8.

My 0.8 saves are mostly corrupt when trying to replay them in 0.8.5, but I was expecting that -- there were a lot of unit changes between 0.8 and 0.8.5. OTOH, I wasn't expecting my fresh 0.8.5 replays to be corrupt!
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

I will investigate why this problem occurs.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Post Reply