Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

NEWS:
setting Difficulty level question, attempted second repost
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku
View previous topic :: View next topic  
Author Message
louwin

Joined: 03 Jan 2010
Posts: 11
:
Location: Western Australia

Items
PostPosted: Tue Jan 12, 2010 11:50 am    Post subject: debug run Reply with quote

JFYI I put in a counter in the difficulty routine out of curiousity. In one that ran for a minute, it looped around the difficulty routine 21000 times, no wonder it is slow!!!!

These times are from the Emulator but they are comparable with the actual unit from my experience.

humble_programmer, a question:-

"An obvious--and easily implemented optimization--would be to discard a puzzle as soon as all of the level-specific solving techniques are exhausted"

How obvious? Could you hazzard a quess what sort of improvement will it give?

Tongue in cheek! What do I change? It is easier to ask you then spend a few hours working it out for myself. Wink Wink

I'm a sponge! I can suck up good techniques....

Could you please do my homework for me Wink
Back to top
View user's profile Send private message Send e-mail
humble_programmer

Joined: 27 Jun 2006
Posts: 69
:
Location: Colorado Springs, USA

Items
PostPosted: Tue Jan 12, 2010 2:54 pm    Post subject: Reply with quote

Wapati: thank you for responding with courtesy and maturity. And to answer your question, "Yes" I was somewhat dismayed by the internal logic and structure of Pocket Sudoku.

louwin: if you are legitimately interested in .NET programming--at least in regards to Sudoku--I suggest you take a look at some open source C# code I posted at http://www.humble-programmer.com/bb_sudoku.htm. It is a reasonably straight-forward sudoku generator/solver that attempts to strike a balance between performance and code readability. Moreover, I would be happy to answer any questions you may have about it.
_________________
Cheers!
Humble Programmer
,,,^..^,,,
www.humble-programmer.com
Back to top
View user's profile Send private message Visit poster's website
lkSudoku

Joined: 16 May 2009
Posts: 95
:

Items
PostPosted: Tue Jan 12, 2010 9:36 pm    Post subject: Reply with quote

louwin wrote:
I am an expert Assembly and commercial programmer and I said, up front, that this is my first attempt at C#. I'm too impatient to learn the language so I just jumped in

Assembly is a low level language while C# is an object oriented high level language, it is quite a jump to go from assembly to C#

I would suggest starting with C# and object oriented tutorials before trying to modify or write a ready to use program
Back to top
View user's profile Send private message Send e-mail
louwin

Joined: 03 Jan 2010
Posts: 11
:
Location: Western Australia

Items
PostPosted: Wed Jan 13, 2010 3:16 pm    Post subject: Reply with quote

I take your point, lkSudoku, but I do have 20 years in 5 or 6 BASICs, though not OO it is still a high level language. I did touch on VB5 a long time ago.

I should learn C# (I keep telling myself that every day) as I stumble around in the program. There are a hundred things I don't understand and another hundred things I don't know how to do like how do you declare a method in one source file so it can be called from another method in another file? How do you declare data so it is accessible from lots of methods? How much time do you have?

I am treating this as a learning exercise as well as modifying the program to my very specific requirements. You never know, one day I may write my own Sudoku Solver/generator borrowing logic from all and sundry. Game play from here, generation logic from there and so on. I can hear you groan "we don't need ANOTHER solver/generator"!!!!

I have started several tutes but the learning is so slow and the questions I have don't get answered. I don't know who these tutes are aimed at but obviously not at me. I have tried tutes from CodeProject, and several "Learn C#" tutes from half a dozen sites. I will try to perservere....

I have acheived some success, if I must say so myself. I have totally reworked the display to the way I like it when I use solve puzzles on paper with a pen, a pencil and an eraser. e.g. I have incorporated about 5 additional font sizes in the pencil mark display. Again, I display naked singles in a font (in red) just smaller than the givens. Hidden singles I display also in large font amid the other candidates to show that it is a hidden as opposed to naked. The display modifications do not solve the puzzle just displays the pencil marks how i write them on paper in pencil.

Do you know of a tute that would answer the two questions I posed? If so, I would love a link.

Humble Programmer, thank you, I did find your site and I downloaded the source this morning. I am sorry to say I haven't had the time to peruse it yet (I am looking forward to it though!). I have 4 daughters and 5 grandkids and babysit 4 full days a week (during which I play a LOT of Sudoku but don't program near enough!)

I have also been given source of a generation routine that generates 30 to 40 thousand grids a second (the routine was written in VB.NET but the author kindly transalated it to C# for me). But I'm more after a faster "difficulty setting routine" than a faster generation routine.

I am IMPATIENT and love to get my hands dirty. I (hopefully) have a long time to acheive my aims and even longer to enjoy them. I hate to have unanswered questions but I program around them. I improvise. If I can't call a display method in another source file I read my required results in the debugger.

Another thing I don't understand, after playing 3 or 4 games the available memory (of which there is only about 40Mb) drops by 10Mb and this appears to contribute to the delay in "difficulty setting". I can't find where this memory goes (some sort of bleed?) (garbage collection?). A "soft reset" restores the memory availability.

Sorry I ramble a bit....

Humble, I would REALLY be interested in your implementation of your source on the PPC. I would kill to see it! I also noticed that your site doesn't boast of an executable so I couldn't run your solver/generator or check out YOUR gameplay. How do you handle "difficulty setting"? I would love to play your PPC version on my 640x480 HP hx4700 PPC. I fear I may ask too many questions about your code.

Thank you for your replies, they are really appreciated.
Back to top
View user's profile Send private message Send e-mail
lkSudoku

Joined: 16 May 2009
Posts: 95
:

Items
PostPosted: Wed Jan 13, 2010 6:38 pm    Post subject: Reply with quote

I do not know C#, but I know C++ and Java, and I consider C# as the Microsoft imitation of Java

louwin wrote:
how do you declare a method in one source file so it can be called from another method in another file? How do you declare data so it is accessible from lots of methods?


In object oriented languages, a method is a modifier of the class object, you declare a method in the class, then you instansiate an object of that class, and call the method for the specific object; There are also functions that can be called without an instance, these are called static methods, and cannot use the class non static members, usually there is a class header declaring its data members and functions, and a source file implementing the declared functions

In C++ there are 3 levels of access to class members and functions:
private - can only be accessed by the class internally
protected - can be accessed by all derived classes also
public - can be accessed everywhere

I remember an online Java tutorial by O'Reilly but unfortunately, this site is no longer free http://online-books.oreilly.com/, there are also some free tutorials by Sun for java that can answer your two questions, http://java.sun.com/docs/books/tutorial/java/index.html (and specifically for the second question http://java.sun.com/docs/books/tutorial/java/javaOO/variables.html)

louwin wrote:
Another thing I don't understand, after playing 3 or 4 games the available memory (of which there is only about 40Mb) drops by 10Mb and this appears to contribute to the delay in "difficulty setting". I can't find where this memory goes (some sort of bleed?) (garbage collection?).


My guess is that there is somekind of memory leak; if C# is like java, it has a garbage collector that frees all memory for objects that are not referenced, so there are probably some references in the program to objects that remain between games although not used in the next games
Back to top
View user's profile Send private message Send e-mail
louwin

Joined: 03 Jan 2010
Posts: 11
:
Location: Western Australia

Items
PostPosted: Wed Jan 13, 2010 10:42 pm    Post subject: VS2008 compiler Reply with quote

Thanks lkSudoku but....

There is a method called Status as below that displays a message in the status area:-

private void Status(string text)

The first thing I did was change the private to public but the compiler still didn't like it.

I posted the question in the VS2008 forum but didn't get a reply, too simple a question for those clever people? I tried reading about private, public and many others in a tute but it was still as clear as mud after I finished reading.

Humble, I copied your batch file and activated it and got an error that Program.cs was missing. I tried copying MY Program.cs and changing the namespace constant but ran into other more complicated errors beyond my experience. Sorry, newbie alert!
Back to top
View user's profile Send private message Send e-mail
lkSudoku

Joined: 16 May 2009
Posts: 95
:

Items
PostPosted: Thu Jan 14, 2010 6:45 pm    Post subject: Reply with quote

It's not simple to tell what is the compiler error based on the sole function decleration, but I can think of a few problems

- Perhaps the class containing the Status function is inherited from a class which defines the same function as private
- Perhaps you did not instantiate or referenced the correct object when calling its method

You could create a new public function in the class containing Status, and call the private function from that public function
Back to top
View user's profile Send private message Send e-mail
louwin

Joined: 03 Jan 2010
Posts: 11
:
Location: Western Australia

Items
PostPosted: Sat Jan 16, 2010 7:32 am    Post subject: new hx4700 Reply with quote

Just a quick update:-

I bought another HP hx4700 PDA off eBay, but this time, running Windows Mobile 6 Classic.

I loaded my latest version onto it and it appears to run MUCH faster. I have played about 20 games on it and the longest "generation" time was 1m35s.

This still isn't great but much better than on the WM2003SE....

I hope your port to the PPC is going well, Humble.

Still glancing at your open source code.... Phew! complex!!!!
Back to top
View user's profile Send private message Send e-mail
louwin

Joined: 03 Jan 2010
Posts: 11
:
Location: Western Australia

Items
PostPosted: Wed Jan 20, 2010 10:37 pm    Post subject: Reply with quote

humble_programmer wrote:


I hope to spend a few hours this weekend looking at porting my own home-grown sudoku solver/generator to a Windows Mobile-compatible format, so that I can post some real PC vs. PocketPC comparisons.



I hope your port went well unless, like me something more important came up....

I would be really interested in the results.

I have changed the "Hint" code to display the number of Hints used rather than "Yes or No" and drastically changed the filtering logic in the Statistics display.

I still haven't tackled the setting difficulty logic (no time!). Sad
Back to top
View user's profile Send private message Send e-mail
chautygorcy

Joined: 27 Apr 2012
Posts: 3
:
Location: Nome

Items
PostPosted: Fri Apr 27, 2012 6:42 am    Post subject: Reply with quote

I had vb dot NET in the article! I also removed all the slashes in desperation. The third posting finally went through. Thank Heavens!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Setting sudoku All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron
FREE FORUM HOSTING by AtFreeForum. Terms of Service - Privacy Policy
FASHION ACCESSORIES - BLING BLING - LADIES WATCHES - KOREAN CHILDREN CLOTHING - ONLINE BARGAIN STORE - FASHION JEWELLERIES