herzbube / littlego

Little Go. An iOS application that lets you play the game of Go on the iPhone or iPad.
https://littlego.herzbube.ch/
Apache License 2.0
138 stars 54 forks source link

Improve editing of setup #417

Open herzbube opened 7 months ago

herzbube commented 7 months ago

Currently setup can be changed only on board position 0. This can be improved by allowing the user to also edit setup on board positions beyond 0. New rule: Allow switching to board setup mode if there are no moves at or before the current board position.

Add a new user preference where the user can choose what they want to do if a setup change would cause future board positions with setup and/or moves to be invalidated:

When user performs a change to the board:

When user performs a change to the handicap in the root node:

herzbube commented 4 months ago

The following notes, which I wrote down elsewhere, need to be reviewed - they may or may not be useful anymore.

Allow multiple board setups, one for each variation
---------------------------------------------------
- How should the editing process work?
  - q5Go
    - The user enters board setup mode with "Edit position"
    - The user can leave board setup mode with "Cancel" to discard all changes
      made.
    - The user also has other options with which to save the changes. The
      available options vary with the edited node's direct children.
    - When editing occurs on the root node there is no option "Insert before",
      otherwise the behaviour is the same as for setup nodes.
    - The node is the root node (with or without setup), and it has no children
      - Append = Creates a new node after the current node. The new node
        contains the changes to achieve the setup that the user defined.
      - Replace = Replaces the setup in the current node with the one that the
        user defined.
    - The node is the root node (with or without setup), and it has children,
      and at least one of them is a move node
      - Append = Creates a new variation splitting off from the current node.
        Changes are applied in the new variation's first node. The existing
        variation is thus unaffected by the change.
    - The node is the root node (with or without setup), and it has children,
      and all of them are setup nodes
      - Append = Creates a new variation splitting off from the current node.
        Changes are applied in the new variation's first node. The existing
        variation is thus unaffected by the change.
      - Replace: Replaces the setup in the current node with the one that the
        user defined. All child nodes are modified so that they re-establish the
        same position they already established before.
    - The node is a setup node that is not the root node, and it has no children
      - Append = Creates a new node after the current node. The new node
        contains the changes to achieve the setup that the user defined.
      - Insert before = Creates a new node in front of the current node. The new
        node contains the setup that the user defined. The current node contains
        changes that revert the setup in the new node so that the same board
        position is established that existed when the user started the editing
        process.
      - Replace = Replaces the setup in the current node with the one that the
        user defined.
    - The node is a setup node that is not the root node, and it has children,
      and at least one of them is a move node
      - Append = Creates a new variation splitting off from the current node.
        Changes are applied in the new variation's first node. The existing
        variation is thus unaffected by the change.
      - Insert before = Creates a new node in front of the current node. The new
        node contains the setup that the user defined. The current node contains
        changes that revert the setup in the new node so that the same board
        position is established that existed when the user started the editing
        process.
      - No replace: Because on the lines where the child contains a move there
        is no setup node that could revert what was changed in this node.
    - The node is a setup node that is not the root node, and it has children,
      and all of them are setup nodes
      - Append: Creates a new variation splitting off from the current node.
        Changes are applied in the new variation's first node. The existing
        variation is thus unaffected by the change.
      - Insert before: Creates a new node in front of the current node. The new
        node contains the setup that the user defined. The current node contains
        changes that revert the setup in the new node so that the same board
        position is established that existed when the user started the editing
        process.
      - Replace: Replaces the setup in the current node with the one that the
        user defined. All child nodes are modified so that they re-establish the
        same position they already established before.
    - The node is a move node that is not the root node and it has no children
      - Append = Creates a new node after the current node. The new node
        contains the changes to achieve the setup that the user defined.
      >>> Will not be supported by Little Go for the moment (#401)
    - The node is a move node that is not the root node and it has children,
      regardless of whether they contain setup or move or both
      - Append = Creates a new variation splitting off from the current node.
        Changes are applied in the new variation's first node. The existing
        variation is thus unaffected by the change.
      >>> Will not be supported by Little Go for the moment (#401)
  - Little Go
    - Unlike q5go the user does not have to select an option with which to
      save changes. Changes are either applied to the current node (if
      possible), or a new child node is created when the editing process
      begins. The "Insert before" option offered by q5go is not possible in
      Little Go. In a later stage there will be options that allow to insert
      new, empty nodes independently of whether they are going to hold setup,
      markup or annotations.
    - When is board setup available?
      - The user can enter board setup if the current node is not a move node
        and none of the ancestors of the current node are move nodes.
      - The user cannot enter board setup mode if the current node is a move
        node, or if any of the ancestors of the current node are move nodes.
    - When the user enters board setup mode nothing happens yet because the user
      could choose to leave board setup mode without making any changes.
    - When the user makes the first change a decision is made what happens next
      depending on the current node and its children.
      - The node is the root node
        - The node has no children
          - A new child node is created automatically.
          - All setup occurs within the new node.
        - The node has children, and all of them are non-move nodes
          - A new child node that starts a new variation is created
            automatically.
          - All setup occurs within the new node.
        - The node has children, and at least one of them is a move node
          - Ditto
      - The node is not the root node
        - The node has no children
          - No new node is created.
          - All setup occurs within the current node.
        - The node has children, and all of them are non-move nodes
          - No new node is created.
          - All setup occurs within the current node.
          - All non-move child nodes are modified to revert the change made
            by the user so that after the child node the same board position
            is achieved as before the user made the change. Children that did
            not contain a GoNodeSetup will receive a new GoNodeSetup.
        - The node has children, and at least one of them is a move node
          - A new child node that starts a new variation is created
            automatically.
          - All setup occurs within the new node.
- Manipulating handicap with setup
  - Current implementation
    - Issues a warning when the user taps a handicap stone, then if the user
      confirms deletes the stone.
    - There is a user preference for the warning.
  - New implementation
    - When the user taps a handicap stone that stone is simply removed (AE), or
      replaced with a white stone (AW). If the user places a black stone again
      then no change occurs.
    - Reason for this change: Several variations can manipulate the handicap
      in different ways. Also handicap may be manipulated in a GoNode that is
      not a direct descendant of the root node.
    - LoadGameCommand, setupSetup, step 2: Contains validation that refuses SGF
      files that perform this kind of manipulation.
      => Must be changed