Chess pieces

The package chessboard implements different methods for detecting neighbors. All are derived from the chess game and allow user to define complex moves to create direct edges (links) between nodes (sampling units). The following table provides a description of the chess pieces available in chessboard.


Function 2D network Transect only Quadrat only Description
pawn() Finds neighbors vertically (i.e. along a transect)
fool() Finds neighbors horizontally (i.e. along a quadrat)
rook() Finds neighbors vertically and horizontally
bishop()* Finds neighbors along the two diagonals
knight()* Finds neighbors in ‘L’ shape
queen() Finds neighbors horizontally, vertically, and diagonally
wizard() Finds neighbors in all directions

* These two chess pieces each have two variants: bishop_left(), bishop_right() and knight_left(), knight_right().


In this vignette, we use an extended version (9 transects x 9 quadrats) of the network used in Casajus et al. (2023) to illustrate methods for detecting neighbors implemented in chessboard and the impact of the different arguments.


Pawn

The pawn can detect neighbors vertically, i.e. among quadrats along a transect.

The function pawn() can be used to detect neighbors (black dots in Fig. 1) of a specific node (red dot in Fig. 1).

pawn(nodes, focus = "5-5", degree = 4, ...)

User can change the default settings (Fig. 1A), by adding directionality (directed = TRUE, Fig. 1B) and reversing the default directionality (directed = TRUE and reverse = TRUE, Fig. 1C).


Figure 1. Moves of the **Pawn** (with degree = 4)

Figure 1. Moves of the Pawn (with degree = 4)


Figure 2 shows the connectivity matrix of the 9 x 9 network when neighbors of all nodes are detected by the pawn method and with a degree of neighborhood of 4.

create_edge_list(nodes, method = "pawn", degree = 4, ...)
Figure 2. Connectivity matrices of the **Pawn** (with degree = 4)

Figure 2. Connectivity matrices of the Pawn (with degree = 4)


Fool

The fool can detect neighbors horizontally, i.e. among transects along a quadrat.

The function fool() can be used to detect neighbors (black dots in Fig. 3) of a specific node (red dot in Fig. 3).

fool(nodes, focus = "5-5", degree = 4, ...)

User can change the default settings (Fig. 3A), by adding directionality (directed = TRUE, Fig. 3B) and reversing the default directionality (directed = TRUE and reverse = TRUE, Fig. 3C).


Figure 3. Moves of the **Fool** (with degree = 4)

Figure 3. Moves of the Fool (with degree = 4)


Figure 4 shows the connectivity matrix of the 9 x 9 network when neighbors of all nodes are detected by the fool method and with a degree of neighborhood of 4.

create_edge_list(nodes, method = "fool", degree = 4, ...)


Figure 4. Connectivity matrices of the **Fool** (with degree = 4)

Figure 4. Connectivity matrices of the Fool (with degree = 4)

Rook

The rook can detect neighbors both horizontally and vertically, i.e. among transects along a quadrat and among quadrats along a transect.

The function rook() can be used to detect neighbors (black dots in Fig. 5) of a specific node (red dot in Fig. 5).

rook(nodes, focus = "5-5", degree = 4, ...)

User can change the default settings (Fig. 5A), by adding directionality (directed = TRUE, Fig. 5B) and reversing the default directionality (directed = TRUE and reverse = TRUE, Fig. 5C).


Figure 5. Moves of the **Rook** (with degree = 4)

Figure 5. Moves of the Rook (with degree = 4)


Figure 6 shows the connectivity matrix of the 9 x 9 network when neighbors of all nodes are detected by the rook method and with a degree of neighborhood of 4.

create_edge_list(nodes, method = "rook", degree = 4, ...)


Figure 6. Connectivity matrices of the **Rook** (with degree = 4)

Figure 6. Connectivity matrices of the Rook (with degree = 4)


Bishop

The bishop can detect neighbors diagonally.

The function bishop() can be used to detect neighbors (black dots in Fig. 7) of a specific node (red dot in Fig. 7).

bishop(nodes, focus = "5-5", degree = 4, ...)

User can change the default settings (Fig. 7A), by adding directionality (directed = TRUE, Fig. 7B) and reversing the default directionality (directed = TRUE and reverse = TRUE, Fig. 7C).


Figure 7. Moves of the **Bishop** (with degree = 4)

Figure 7. Moves of the Bishop (with degree = 4)


Figure 8 shows the connectivity matrix of the 9 x 9 network when neighbors of all nodes are detected by the bishop method and with a degree of neighborhood of 4.

create_edge_list(nodes, method = "bishop", degree = 4, ...)


Figure 8. Connectivity matrices of the **Bishop** (with degree = 4)

Figure 8. Connectivity matrices of the Bishop (with degree = 4)


Knight

The knight has a complex move, like an ‘L’ shape. It’s the difference between the wizard and the queen.

The function knight() can be used to detect neighbors (black dots in Fig. 9) of a specific node (red dot in Fig. 9).

knight(nodes, focus = "5-5", degree = 4, ...)

User can change the default settings (Fig. 9A), by adding directionality (directed = TRUE, Fig. 9B) and reversing the default directionality (directed = TRUE and reverse = TRUE, Fig. 9C).


Figure 9. Moves of the **Knight** (with degree = 4)

Figure 9. Moves of the Knight (with degree = 4)


Figure 10 shows the connectivity matrix of the 9 x 9 network when neighbors of all nodes are detected by the knight method and with a degree of neighborhood of 4.

create_edge_list(nodes, method = "knight", degree = 4, ...)


Figure 10. Connectivity matrices of the **Knight** (with degree = 4)

Figure 10. Connectivity matrices of the Knight (with degree = 4)


Queen

The queen can detect neighbors horizontally, vertically and diagonally. It’s a combination the rook and the bishop.

The function queen() can be used to detect neighbors (black dots in Fig. 11) of a specific node (red dot in Fig. 11).

queen(nodes, focus = "5-5", degree = 4, ...)

User can change the default settings (Fig. 11A), by adding directionality (directed = TRUE, Fig. 11B) and reversing the default directionality (directed = TRUE and reverse = TRUE, Fig. 11C).


Figure 11. Moves of the **Queen** (with degree = 4)

Figure 11. Moves of the Queen (with degree = 4)


Figure 12 shows the connectivity matrix of the 9 x 9 network when neighbors of all nodes are detected by the queen method and with a degree of neighborhood of 4.

create_edge_list(nodes, method = "queen", degree = 4, ...)


Figure 12. Connectivity matrices of the **Queen** (with degree = 4)

Figure 12. Connectivity matrices of the Queen (with degree = 4)


Wizard

The wizard can detect neighbors in any direction. It’s a combination the queen and the knight.

The function wizard() can be used to detect neighbors (black dots in Fig. 13) of a specific node (red dot in Fig. 13).

wizard(nodes, focus = "5-5", degree = 4, ...)

User can change the default settings (Fig. 13A), by adding directionality (directed = TRUE, Fig. 13B) and reversing the default directionality (directed = TRUE and reverse = TRUE, Fig. 13C).

Figure 13. Moves of the **Wizard** (with degree = 4)

Figure 13. Moves of the Wizard (with degree = 4)


Figure 14 shows the connectivity matrix of the 9 x 9 network when neighbors of all nodes are detected by the wizard method and with a degree of neighborhood of 4.

create_edge_list(nodes, method = "wizard", degree = 4, ...)


Figure 14. Connectivity matrices of the **Wizard** (with degree = 4)

Figure 14. Connectivity matrices of the Wizard (with degree = 4)


Custom moves

It’s possible to create any kind of scenarios by combining the previous moves and by changing the values of the arguments degree, directed, and reverse.

Figure 15. Custom moves

Figure 15. Custom moves

References

Casajus N, Rievrs Borges E, Tabacchi E, Fried G & Mouquet N (2023) chessboard: An R package for creating network connections based on chess moves. R package version 0.1. URL: https://github.com/frbcesab/chessboard.