A horse is in chessboard. given its x,y find the probability through program that it will remain in board after n moves.
In the 8X8 matrix, place 1 for [x,y] position. Then place 1 for all next permissible places for the next. Increment the value by 1 if cell not empty. After n moves, Add all the numbers in matrix divided by (8*n) is the probability that knight will be in chess board.
Here, in (8*n) , 8 is because 8 are max. moves by knight.
And next move co-ordinates can be found by given function.
In the 8X8 matrix, place 1 for [x,y] position. Then place 1 for all next permissible places for the next. Increment the value by 1 if cell not empty. After n moves, Add all the numbers in matrix divided by (8*n) is the probability that knight will be in chess board.
Here, in (8*n) , 8 is because 8 are max. moves by knight.
And next move co-ordinates can be found by given function.
No comments:
Post a Comment