(toX, toY)
| 19 | } |
| 20 | |
| 21 | export function canMoveKnight(toX, toY) { |
| 22 | const [x, y] = knightPosition; |
| 23 | const dx = toX - x; |
| 24 | const dy = toY - y; |
| 25 | |
| 26 | return (Math.abs(dx) === 2 && Math.abs(dy) === 1) || |
| 27 | (Math.abs(dx) === 1 && Math.abs(dy) === 2); |
| 28 | } |
| 29 | |
| 30 | export function moveKnight(toX, toY) { |
| 31 | knightPosition = [toX, toY]; |