Я хочу, чтобы рыцарь начал с (1,1)
и попытался двигаться по всему столу. Это мой код:Почему рыцарь не покрывает весь стол?
canMove :: (Int -> Int) -> (Int -> Int) -> [(Int,Int)] -> Bool
canMove (x) (y) list
| (x (fst lastMove),y (snd lastMove)) `elem` list = False
| newX> 8 || newY> 8 || newX<=0 || newY<=0 = False
| otherwise = True
where lastMove = last list
newX = x (fst lastMove)
newY = y (snd lastMove)
move :: [(Int, Int)] -> [(Int, Int)]
move list
| length list == 64 = list
| canMove (+1) (+2) list = move (list ++ [(x+1,y+2)])
| canMove (+2) (+1) list = move (list ++ [(x+2,y+1)])
| canMove (subtract 1) (+2) list = move (list ++ [(x-1,y+2)])
| canMove (subtract 2) (+1) list = move (list ++ [(x-2,y+1)])
| canMove (subtract 1) (subtract 2) list = move (list ++ [(x-1,y-2)])
| canMove (subtract 2) (subtract 1) list = move (list ++ [(x-2,y-1)])
| canMove (+1) (subtract 2) list = move (list ++ [(x+1,y-2)])
| canMove (+2) (subtract 1) list = move (list ++ [(x+2,y-1)])
| otherwise = list
where lastMove = last list
x = fst lastMove
y = snd lastMove
y=length (move [(1,1)])
main = print $ y
Почему рыцарь после остановки 34
шагов?