There are three kinds of actuaries: those who can count, and those who can't.
"Il y a peu de choses qui me soient impossibles..."
That is unnecessary. You can move to ±(2 × row ±1) or ±(row ± 2), where row means length of a row, e.g. 8.Piet Souris wrote:. . .
Then write a method that transforms a number to a chess field notation,
and a method that converts from a chess field notation to a number.
. . .
That is one version of the Knight's Tour, the closed tour. There is a simpler version, the open tour, which is this:-Stevens Miller wrote:. . . "Knight's Tour" problem, . . . start at any square, move once to every other square, and finish back where you started.
Does any of that help?
Campbell Ritchie wrote:Unless you use very small boards (e.g. 5×5) there is a combinatorial explosion; the number of different tours on an 8×8 board has about 11 digits in.
"Il y a peu de choses qui me soient impossibles..."
Campbell Ritchie wrote:That is unnecessary. (...)
There are three kinds of actuaries: those who can count, and those who can't.
Kevin Garcia wrote:Thank you all! I think I can do it now.
But now I am not sure if I have the open tour or closed tour?
Here is my assignment:
The object is to move a knight from one square to another on an otherwise empty chess board until it has visited every square exactly once. Write a program that solves this puzzle using a depth-first search.
"Il y a peu de choses qui me soient impossibles..."
I suspect working out when you have fallen off the edges of the board is the same difficulty for both approaches.Piet Souris wrote:. . . Of course it is, but I've found my wat the easiest way by far. . . .
There are three kinds of actuaries: those who can count, and those who can't.
Carey Brown wrote:isLegitMove() almost right. still needs a tweak.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Yes, but also what about x > 0?
What is your moves-array currently (see lines 25, 26 and 27)?
Did you test your solve method? For instance on a 3x3 board?
A possibility that might make the solution a bit easier:
Can you find a Knight's Toiur on a 3×3 board at all? I thought it was impossible for that size. Try 4×4.Piet Souris wrote:. . . Did you test your solve method? For instance on a 3x3 board?
. . .
Kevin Garcia wrote:(...)
And what about x > 0?
There are three kinds of actuaries: those who can count, and those who can't.
Campbell Ritchie wrote:
Can you find a Knight's Toiur on a 3×3 board at all? I thought it was impossible for that size. Try 4×4.
There are three kinds of actuaries: those who can count, and those who can't.
Stephan van Hulst wrote:(...)
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Stephan van Hulst wrote:The Board can take a Position and return if it's been visited...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
"Il y a peu de choses qui me soient impossibles..."
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:I wish Winston would comment, Piet and Stephan, because his oft-spoken words would apply here: what Kevin needs to do is stop coding...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:
Stevens Miller wrote:. . . "Knight's Tour" problem, . . . start at any square, move once to every other square, and finish back where you started. ...
As an aside...
A closed tour is impossible on a 5x5 board or indeed on any (odd)x(odd) board. Right?
(The diagram provided in the original post gives a hint why it's easy to make this assertion.)
Winston Gutkowski wrote:
Stevens Miller wrote:I wish Winston would comment, Piet and Stephan, because his oft-spoken words would apply here: what Kevin needs to do is stop coding...
But you've said it so eloquently, what do you need me for?
"Il y a peu de choses qui me soient impossibles..."
Ryan McGuire wrote:
...Campbell Ritchie wrote:
...Stevens Miller wrote:...
Popeye has his spinach. I have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|