help-octave
[Top][All Lists]
Advanced

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

Re: Knight's tour


From: Simon Allen
Subject: Re: Knight's tour
Date: Mon, 11 Feb 2019 22:47:17 +0000

It also produced a table of all the moves and Figure 1 as well


On Mon, 11 Feb 2019 at 22:40, Simon Allen <address@hidden> wrote:
and adding that third file into the same path it runs.  Yay.   It works.   It produces the Figure and the Command Window reports

STOPPED
###### a316667 ######
Move: knight
Board: spiral
Condition: none
Data: 1, 10, 3, 6, 9, 4, 7, 2, 5, 8, 11, 14, 29, 32, 15, 12, 27, 24, 45, 20, 23, 44, 41, 18, 35, 38, 19, 16, 33, 30, 53, 26, 47, 22, 43, 70, 21, 40, 17, 34, 13, 28, 25, 46, 75, 42, 69, 104, 37, 62, 95, 58, 55, 86, 51, 48, 77, 114, 73, 108, 151, 68, 103, 64, 67, 36
Sequence finite, at step 2016, square 2084 is visited, after which there are no unvisited squares within one move.
#####################

So what a learning curve for me.  I see now what went wrong.  When the original author posted his code he forgot about the support code.  Hence the error.  With the code restored/rewritten with grateful thanks, we now have the expected result.

With many, many thanks.  What a story to share at the next Mathsjam next week.

In lines 19 to 33 of the original code, there is mention of the king, queen, bishop and rook.  Can the same code be used for that?  How do I tell it to do the king for instance?

Simon



On Mon, 11 Feb 2019 at 22:25, Doug Stewart <address@hidden> wrote:


On Mon, Feb 11, 2019 at 5:04 PM SimonAllen <address@hidden> wrote:
The error I am seeing is this

error: 'SpiralNumbering' undefined near line 52 column 25
error: called from
    spiralknightsmove>@<anonymous> at line 52 column 25
    spiralknightsmove at line 78 column 19

What I suddenly realised is that spiralknightsmove calls spiralNumbers 

I had it in my head that the subroutine had to be within the main code.  It
should work provided spiralknightsmove can see spiralNumbers.

So what I have done is to use 'pwd' and that tells me where Octave is
looking.  In my case it is

>> pwd
ans = /Users/Simon

Next I accessed both files in Dropbox.  I used direct download and then
moved both files to /Users/Simon

Next to be sure I typed

>> ls
spiralNumbers.m
spiralknightsmove.m

There is a lot of other stuff there folders and files but both of these
files are there

Next I opened spiralknightsmove.m in Octave and hit Run.  That gives the
error above.  So Octave is not seeing the other file even though it is in
the same path.  I am not sure why it is still not seeing it.

I am on a Mac but that should not make any difference or is it a file
permission issue?

Simon




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


get this file also



--
DASCertificate for 206392



--
Simon


--
Simon

reply via email to

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