![]() |
|
#1
|
||||
|
||||
Knights Tour - Reloaded .Hey guys.
Last night I was thinking about the Knight's tour thread. I decided to write some code and try to solve the problem with the next approach : I keep track of the places I already visited and avoid calling the recursion function "knight" if I recognize a pre-visited cell. Now, when I print the board it seems that the function "legal" allows illegal moves, but I think that the illegal moves are created because of a logical bug I'm having (and I can't track). I also add a function "print_visit" to display an error (probably the same logical error) I have. How could it be that any "visit[i][j]" gets a value other than 1 ? Anyone notices the bug(s) ? Here is my code : CPP / C++ / C Code:
Oh, and yes, I use globals ... I'll fix it when I track the problem. Best Regards, Kobi Hikri. __________________
It's actually a one time thing (it just happens alot). |
||||
|
#2
|
||||
|
||||
Re: Knights Tour - Reloaded .O.k , Here is one error :
I didn't check upper array bound ... Here is the fixed start of the "if" statement : CPP / C++ / C Code:
Now, I need to check the other bugs (like how come my app gives duplicate numbers to different cells. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#3
|
||||
|
||||
The code so far.At the end, I wish to repeat the test done a few years ago :
For each given dimension of the board, I will look for all the solutions available and store them in a linked list. Here is the code for the knight's tour I have this far : CPP / C++ / C Code:
This has to be debuged yet. I solved the problem of duality of "moves" that was with the pre posted code.You can see the differences in the flow control of the program. Soon to be updated. Kobi Hikri. __________________
It's actually a one time thing (it just happens alot). Last edited by JdS : 29-Sep-2005 at 07:10.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#4
|
||||
|
||||
Re: Knights Tour - Reloaded .Hey guys.
I see I'm the only one interested in this little puzzle. I promised my code and here it is (Dave supplied the skeleton for some of the code - Thanks alot.): CPP / C++ / C Code:
Currently, All the solutions are being found. I'm working on checking the solutions ... Shabat shalom to you all. Kobi Hikri. __________________
It's actually a one time thing (it just happens alot). |
|
#5
|
||||
|
||||
Re: Knights Tour - Reloaded .Hey guys.
Sorry if I'm boring you. Somehow, this knight's tour problem caught me and I had to implement a solution. Here is the final code I'll post about this. Try it if you wish, I think it's interesting. CPP / C++ / C Code:
Best regards, Kobi Hikri. __________________
It's actually a one time thing (it just happens alot). |
|
#6
|
|||
|
|||
Re: Knights Tour - Reloaded .Quote:
The topic of using a simple recursive implementation to investigate a centuries-old problem is not boring to me, and I appreciate your efforts. (I haven't actually tried to run your code.) How the heck did those guys a couple of hundred years ago (or even more ancient) come up with all of those solutions that you can find by browsing the web? How about giving us a little information about the sizes of boards for which you have data. Summary of results, run time (on what system?), etc. Regards, Dave |
|
#7
|
||||
|
||||
Re: Knights Tour - Reloaded .Quote:
I started a reply to this earlier today but got sidetracked. It essentially echoed Dave's sentiment. Effort such as yours is exactly what I find so interesting about this forum. Perhaps I can shed some light on what I have found in the short time I have been here. As you well know by now, the bulk of the posts are requests for help with a particular task. Some are well thought out, some, well, not so much. Some try to learn the rules of the road (at least our short list from the Guidelines Thread) and others come in like a blown 454 jammed in a heavy hunk of Detroit Iron entered into a pickup demolition derby match. In my humble opinion, adding to the colorfulness of it all. It would be my guess based on my own experience that many a person has read your thread and perhaps even learned a bit from it. I know I have, so you can take that one to the bank. The fun part is, since you were not actually asking for help, the response on this type of post is minimal. Take it as a complement. You stated your goals, posted a handfull of posts with code, and found an endpoint. Your last post compiled fine for me with my CygWin gcc and the -Wall option. It ran and gave results for me with various board sizes. I had to quit out of my attempt at a 7x7 board, it was pegging my processor for about a half hour and reached a pair of millions and a half on the recursion counter. No reason for my quitting except I had other things to convince my processor to do this fine morning. Bored, not even close. I say Thank You and keep them coming. Good examples that compile cleanly are EXACTLY what we seem to strive for here. Interesting, "You bet your Bippy!" __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#8
|
||||
|
||||
Re: Knights Tour - Reloaded .Quote:
I will summarize my results soon (how did you know I was doing that ? As my compulsive character drives me to. It will take a few days ... Thanks again for your guidance with some issues (don't be so humble, Dave Kobi Hikri. __________________
It's actually a one time thing (it just happens alot). |
|
#9
|
||||
|
||||
Re: Knights Tour - Reloaded .Quote:
Hey Mark. What is the Wall option ? I've read about CygWin earlier today (even tried to install two dll's I downloaded). Thanks for your support, it is really important. Kobi. __________________
It's actually a one time thing (it just happens alot). |
|
#10
|
||||
|
||||
Re: Knights Tour - Reloaded .Quote:
As you most likely know, the number of switches available to get GCC to do your bidding is monsterous. One of the simpler is the level of error reporting that will be given. Using -Wall will enable warnings that you would not usually see. Things like declared but unused variables, "falling off the end" of functions that declare a return type, etc, etc. For the curious, google ISBN 0954161793 for an open source book "An Introduction to GCC", it will give a good foundation for using the compiler from the command line. Quote:
You are most welcome, my mother used to tell us endlessly while we were young, "If you don't have anything nice to say, don't say it." Simple and to the point, kind of what we do around here. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
Recent GIDBlog
Problems with the Navy (Officers) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Free 1 GB Space PLESK RELOADED Reseller Account - Unmetered Bandwidth | john_robot | Free Web Hosting | 2 | 02-Oct-2005 23:09 |
| knight tour (chess program) | kai85 | C++ Forum | 10 | 25-Mar-2005 06:12 |
| Knight tour (arrays help needed) | dilmv | C++ Forum | 7 | 18-Oct-2004 14:31 |
| Robs World Tour | jrobbio | Open Discussion Forum | 3 | 29-Mar-2004 22:04 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The