knight: Chess knight

Description Usage Arguments Note Author(s) Examples

Description

Generating function for a chess knight on an infinite $d$-dimensional chessboard

Usage

1
knight(d, can_stay_still = FALSE)

Arguments

d

Dimension of the board

can_stay_still

Boolean, with default FALSE meaning that the knight is obliged to move and FALSE meaning that it has the option of remaining on its square

Note

The function is a slight modification of spray::knight().

Author(s)

Robin K. S. Hankin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
knight(2)      # regular chess knight on a regular chess board
knight(2,TRUE) # regular chess knight that can stay still

# Q: how many ways are there for a 4D knight to return to its starting
# square after four moves?

# A:
constant(knight(4)^4)

# Q ...and how many ways in four moves or fewer?

# A1:
constant(knight(4,TRUE)^4)

# A2:
constant((1+knight(4))^4)

mvp documentation built on Feb. 4, 2019, 5:05 p.m.