bug: Fix state hash for empty piles
The current implementation of state hash doesn't represent empty columns or foundations properly. This leads to a potential collision if there is a full column next to an empty column, as it's indistinguishable which column the data lies on. (In practice, this can't happen for foundations, as they only hold cards of distinct types, so the collision only occurs with columns.) This commit fixes the issue and makes sure to represent empty piles properly.
This commit is contained in:
parent
985e99cf77
commit
bea2be5f63
|
@ -451,8 +451,10 @@ QString GameState::generateStateHash() const {
|
|||
stateHash += slot->isRevealed() ? "t" : "f";
|
||||
stateHash += ",";
|
||||
}
|
||||
stateHash.removeLast();
|
||||
stateHash += " ";
|
||||
|
||||
if (stateHash.last(1) != "|")
|
||||
stateHash.removeLast();
|
||||
stateHash += "|";
|
||||
}
|
||||
|
||||
stateHash.removeLast();
|
||||
|
@ -462,8 +464,9 @@ QString GameState::generateStateHash() const {
|
|||
for (const PlayingCard* card : foundationPile) {
|
||||
stateHash += QString::number(card->value()) + "." + QString::number(card->suit()) + ",";
|
||||
}
|
||||
stateHash.removeLast();
|
||||
stateHash += " ";
|
||||
if (stateHash.last(1) != "|")
|
||||
stateHash.removeLast();
|
||||
stateHash += "|";
|
||||
}
|
||||
|
||||
stateHash.removeLast();
|
||||
|
|
Loading…
Reference in a new issue