The problem statement contains an image.
Consider an empty chess board (8x8 squares), with a chess knight placed on one of the squares.
The possible movements of a chess knight are marked on the picture below.
If the knight moves n times, each time picking one
of the eight directions uniformly at random (possibly a direction which makes the knight
leave the chess board), determine the probability that it's
still on the board after n jumps. Once the knight leaves the board, it can't enter it again.
Create a class ChessKnight containing the method probability which takes an
int x, an int y (the start square of the chess knight,
where 1,1 is one of the corners)
and an int n, the number of jumps the knight will make.
The method should return a double, the probability that the knight
is still on the chess board after making n random jumps.
|