help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Knight's tour


From: Doug Stewart
Subject: Re: Knight's tour
Date: Sun, 10 Feb 2019 10:45:03 -0500



On Sun, Feb 10, 2019 at 7:40 AM Doug Stewart <address@hidden> wrote:


On Sun, Feb 10, 2019 at 6:56 AM Simon Allen <address@hidden> wrote:
Very well done.  Yes I will keep Octave in the loop.  Can they be incorporated into the code?

Simon 

We normally bottom post on this list.

Try this.


 
Now that I have spent some time figuring out spiral-numbers, I can understand the code at
 https://oeis.org/A316667/a316667.m.txt    much better.
 With my version of spiralNumbers the move number 1 is at the centre of the square matrix, but
they seem to call that spot x0=0 y0=0. So a simple offset should convert between the 2 systems.

this line
 xy2num = @(x,y) SpiralNumbering(x,y);
is making a function xy2num(x,y)  that if you give it an x,y location
in a spiral array,it gives you back a move number. 
this part remembers what we have done.
 % add current square to sequence
    seqX(end+1) = x0;
    seqY(end+1) = y0; 
seqNum(end+1) = xy2num(x0,y0);

this part
  % apply all possible moves
    x = x0 + dx;
    y = y0 + dy;
gets all 8 new positions.

So I think I am close :-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]