Description Usage Arguments Value Examples
This function could probably be minimized or done away with by encoding the data differently when checking neighboring cells.
1 | index_of_neighbor(idx, nr, bs)
|
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.
| ||||||||||
bs |
Board size. |
Returns a the index of a neighboring cell.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.