Struct
IpuzGuesses
Description [src]
struct IpuzGuesses {
/* No available fields */
}
An opaque data type representing the user’s guesses. It allows storing an arbitrary string per cell.
This is typically associated with an existing IpuzGrid
and
used to keep track of guesses that a user has made in a game. It
can be serialized and saved/loaded from either a stream or
file. This provides a way to keep changes separate from a puzzle
file, which may be read-only or shared across users.
Guesses can also be used as an overlay to store additional data on a grid or other structure. In those instances, the guess must be manually initialized.
Representation
Every puzzle type will define how it expects the guesses to be
structured for the purposes of game_won()
. Please check out the
Guesses section of each puzle types documentation to understand
how to use the guesses object for that puzzle type.
It is not expected that guesses files are necessarily portable across applications: applications are free to store application-specific values and provide their own winning conditions.
Note
This struct is separate from the ‘saved-guess` value stored in an ipuz file, though it has a very similar on-disk json format. In the future, we will support writing/reading guesses from those values.
Instance methods
ipuz_guesses_get_checksum
Returns a SHA1 HASH representing the current state of the
puzzle. It can be compared against a stored hash in the puzzle to
check for a victory condition, without actually storing the answer
in the puzzle. salt
is optional. If used, it should be included
along with the hash when saving.
ipuz_guesses_get_guess
Returns the guess in the cell at coord
. If the user hasn’t guessed
a value there then NULL
is returned.
ipuz_guesses_get_percent
Calculates the completion percentage of guesses
. This just
calculates the percentage of IPUZ_CELL_NORMAL
cells filled in, and
has no bearing on the correctness of the guessses given. It will be
a value between 0.0 and 1.0 inclusive.
ipuz_guesses_save_to_file
Writes guesses
to filename
as a guesses file, overwriting the
current contents.