Struct

IpuzGuesses

Description [src]

struct IpuzGuesses {
  /* No available fields */
}

A structure representing the users guesses.

This can be associated with an existing IpuzPuzzle and used to keep track of guesses that the user has made on the game. It can be serialized and saved/loaded from either a stream or file.

This structure is intended to be created from an IpuzBoard and is not really supposed to be meaningful independent of it. It is also not really expected that guesses will be useful if the board changes.

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_from_board

Creates a new IpuzGuesses struct modeled after the shape and pattern of board. If copy_guesses is TRUE then any initially saved guesses within board are copied to the newly created guesses.

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 is meant to be used for debugging.

ipuz_guesses_ref

Refs the guesses.

ipuz_guesses_save_to_file

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

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 becomes 0.