index_of_neighbor: Index of neighbor

Description Usage Arguments Value Examples

Description

This function could probably be minimized or done away with by encoding the data differently when checking neighboring cells.

Usage

1

Arguments

idx

The index of the matrix as a vector starting with the top left and proceeding down then right.

nr

relative cell reference. If a cell is at position idx, the corresponding cell references are as follows.

8 7 6
5 idx 4
3 2 1
bs

Board size.

Value

Returns a the index of a neighboring cell.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
board        <- random_board()
bs           <- board_size(board)

# This example returns 5.  The index of the first cell in the
# second column of a 4x4 matrix.  The first arg (idx) is set
# to 1, representing the first cell in the first row.  The
# second argument (nr) which is set to 4 indicating the cell
# to the immediate right (east).  Finally the board size is set
# to 4.
index_of_neighbor(1, 4, 4)

ezgraphs/rbogglesolver documentation built on May 16, 2019, 9:56 a.m.