Struct

IpuzGuesses

Description [src]

struct IpuzGuesses {
  /* No available fields */
}

A structure 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.

Constructors

ipuz_guesses_new
No description available.

ipuz_guesses_new_from_file

Returns a newly allocated IpuzGuesses loaded from filename.

ipuz_guesses_new_from_stream

Returns a newly allocated IpuzGuesses loaded from @stream.

Instance methods

ipuz_guesses_copy

Makes a copy of guesses.

ipuz_guesses_equal

Compares two guesses and returns TRUE if they are identical.

ipuz_guesses_get_cell_type

Returns the cell type of the cell at coord.

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_height

Returns the height of guesses.

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_get_width

Returns the width of guesses.

ipuz_guesses_print

Prints guesses to stdout. This method is meant to be used for debugging.

ipuz_guesses_ref

Refs the guesses.

ipuz_guesses_resize
No description available.

ipuz_guesses_save_to_file

Writes guesses to filename as a guesses file, overwriting the current contents.

ipuz_guesses_set_cell_type
No description available.

ipuz_guesses_set_guess

Sets the user’s guess at coord to be guess. If NULL, the guess is cleared.

ipuz_guesses_unref

Unrefs guesses, which will be freed when the reference count reaches 0.