[Kde-games-devel] Changes in KPat trunk

Parker Coates parker.coates at gmail.com
Wed Apr 1 16:38:56 CEST 2009


Hello folks,

In the last 5 weeks, I've been putting a fair bit of effort into KPat.
For the most part, it's been a lot of incremental changes and small
cleanups, but there have also been a few larger and more visible
features as well, such as using the fancy game selection screen
whenever the game type is changed and adding the option to remember
the game state between sessions.

Unfortunately, some of the changes have invalidated some assumptions
in the code, revealing (new?) bugs. I've been cleaning these up as I
find them, but I'm nervous that others might have slipped by. If any
of you play KPat regularly, I would appreciated it if you used KPat
trunk to help flush out any potential issues earlier.

I've also put in an effort to improve the accuracy of the statistics
gathering. This is a tricky thing to get right. Since the statistics
are just for fun, we don't want them to be too strict, but if they're
too forgiving then they aren't very accurate. What follows is a
description of the current statistics handling in KPat trunk. If you
have the time to review and comment, I'd appreciate.

In 4.2 there were a few cases where it was easy to get nonsensical
stats. For example, the games played count was incremented on game
start but wins were obviously on counted at the end of the game. As a
result, if you saved a game to file, reopened it, beat it, reopened
it, beat it... you could easily get a win percentage way above 100%.
On the flip side, if KPat crashed midway through a game, that game
would be counted as a loss, which hardly seemed fair. So statistics
are now updated only at the end of a game.

There are currently 7 ways that one can "end" a game:
• Winning the game
• "New"
• "Load..."
• "Load Recent"
• "Choose Game..." (a.k.a. choose game number)
• "Change Game Type..."
• "Quit" (but only if "Remember State on Exit" isn't enabled)

The "Restart Game" action does not "end" the game in progress. It is
essentially equivalent to "Undo"ing back to the original game state,
but also works as expected for games loaded from file. Of course, if
the game has just been won, restarting is considered starting a new
game.

When a game is ended, the stats will be recorded except for in the
following cases:
• The current game hasn't been started. (When a card is moved by the
player or by the demo, the game is considered started. Cards moved by
autodrop are not counted.)
• The game has just been saved to file and no further moves have been made.

Note that the "started" state is now stored in the save file, so it
preserved across sessions, whether automatically or manually saved.

There is a dialog to warn the user if they are about end the game in
progress, which would result in a loss being recorded to the
statistics. The dialog is skipped in following situations:
• The user has previously checked the "Do no ask again" checkbox.
• The game is won.
• The game is lost.
• The application is quitting

I've debated this last point back in forth. Confirmation dialogs at
shutdown are annoying. Period. But for consistency, it makes sense to
show the dialog in all situations where it applies. I guess this is a
"lesser of two evils" situation. Input is welcome.

There are obviously still ways to game the system. If a game is lost,
you can just save it to file, never open it again and it will never
count toward you stats. But in the end, if a user really want's to
forge their stats, there's nothing we can do to stop them. I'm more
interested in avoiding cases where the statistics handling doesn't
match the user's intent or expectations.

If you've made it this far, thank you very much for your time.

Parker


More information about the kde-games-devel mailing list