Package edu.wisc.game.sql

## Class Board.Pos

- java.lang.Object
- - edu.wisc.game.sql.Board.Pos

- Enclosing class:
    Board

      public static class Board.Pos
      extends Object

  Can be used to describe the position of a piece on the [1:N]x[1:N] grid, or that of a bucket (at (0,0), ... (N+1,N+1)

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `int` | `x` | Coordinates counted from the bottom left corner.
    `int` | `y` | Coordinates counted from the bottom left corner.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Pos​(int num)` |
    `Pos​(int _x, int _y)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `bucketNo()` | Converts the coordinates of a bucket to a bucket number.
    `boolean` | `equals​(Object o)` |
    `Board.Pos` | `flip2corner()` | Mirror image of this cell into the bottom left corner
    `HashSet<Integer>` | `nearestBucket()` | Which bucket(s) is/are the nearest to this cell?
    `int` | `norm1​(Board.Pos q)` | 1-norm distance
    `int` | `norm2sq​(Board.Pos q)` | Square of 2-norm distance
    `int` | `num()` | Counted by row (left-to-right), rows being arranged bottom-to-top.
    `HashSet<Integer>` | `remotestBucket()` | Which bucket(s) is/are the most remote from this cell?
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### x

          public final int x

      Coordinates counted from the bottom left corner. The left bottom bucket is at (0,0), the corner cell is at (1,1).

    - #### y

          public final int y

      Coordinates counted from the bottom left corner. The left bottom bucket is at (0,0), the corner cell is at (1,1).

  - ### Constructor Detail

    - #### Pos

          public Pos​(int _x,
                     int _y)

    - #### Pos

          public Pos​(int num)

      Parameters:
        `num` - in the [0 .. N*N-1] range

  - ### Method Detail

    - #### equals

          public boolean equals​(Object o)

      Overrides:
        `equals` in class `Object`

    - #### num

          public int num()

      Counted by row (left-to-right), rows being arranged bottom-to-top. In other words, the lexicoraphic order for the (y,x) pairs. The ordering for cells is 1-based.

    - #### bucketNo

          public int bucketNo()

      Converts the coordinates of a bucket to a bucket number.
      Returns:
        the bucket number, or -1 if the coordinates are not valid

    - #### norm2sq

          public int norm2sq​(Board.Pos q)

      Square of 2-norm distance

    - #### norm1

          public int norm1​(Board.Pos q)

      1-norm distance

    - #### flip2corner

          public Board.Pos flip2corner()

      Mirror image of this cell into the bottom left corner

    - #### nearestBucket

          public HashSet<Integer> nearestBucket()

      Which bucket(s) is/are the nearest to this cell?

    - #### remotestBucket

          public HashSet<Integer> remotestBucket()

      Which bucket(s) is/are the most remote from this cell?

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`