taiga-simulator - 0.0.0

Apps.Sudoku

Description

A Sudoku puzzle application

To start an instance of the application a Dealer publishes a partial transaction which creates two Resources:

1.1 A Sudoku Resource that contains the initial state of the puzzle.

1.2 A Resource containing a logic function that checks the completed solution to the puzzle.

And consumes another resource:

2.1 A Reward Resource with quantity equal to the number of unfilled squares in the puzzle.

Participants publish partial transactions which consume:

3.1 A Sudoku Resource which represents the current parital solution to the puzzle.

And create:

3.2. A Reward Resource with quantity equal to the number of squares that the participant fills in on the Sudoku grid.

3.3. A Sudoku Resource that contains an updated Sudoku grid with their solutions filled in.

In the partial transaction which contains a full solution to the puzzle, the participant additionally consumes the Resource containing the Dealer's logic function which was created in 1.2.

Definitions

module SudokuSource#

Definitions related to the Sudoku Resource in the application

checkTransition (fromResource : Resource) (toResource : Resource) (reward : Resource) : BoolSource#

Checks the state transition. * The new Resource represents a valid Sudoku grid * The size of the encoded solution doesn't change. * The number of filled in squares does not decrease. * The claimed reward is equal to the number of newly filled in squares. * The only squares that change between the previous and new solutinos are changes from zero (i.e unfilled) to non-zero (i.e filled).

logicFunction : Sudoku.Puzzle -> LogicFunctionSource#

The logic function for the Sudoku solution parital transaction.

Performs the following check:

If there is a consumed Resource representing a Sudoku puzzle then:

1. There is exactly one created Resource corresponding to a new solution and exactly one created Resource representing the claimed reward.

2. The transition from a Sudoku puzzle to the new solution and reward satisfies the checkTransition function.

If the partial transaction does not consume a Sudoku puzzle then it is vacuously valid.

If the logic function part of a Resource that is created by the partial transaction then it is valid.

logicFunction : Sudoku.Puzzle -> LogicFunctionSource#

The logic function for the Sudoku dealer parital transaction. Performs the following check: If there is exactly one consumed Resource representing a Sudoku puzzle then: 1. The solution matches the Dealer's solution. If the partial transaction does not consume a Sudoku puzzle then it is vacuously valid. If the logic function part of a Resource that is created by the partial transaction then it is valid.