ID:265567
 
I've been wanting to develop a sudoku game in BYOND for some time, to the point where I even developed a puzzle generator. Problem: Generating puzzles is only semi-fast, but rating them (to the extent that's even doable) is very slow, so adding features like difficulty level is kind of impossible. The only way to get appropriate puzzles is to generate tons of them and reject (or cache for higher levels) the ones that don't fit. About 50% of all puzzles generated are super-easy.

My best thought for a speedier solution here is to develop a Java applet to do this work, since it will doubtless be faster, and have it send its results to a BYOND interface. Any other thoughts?

Lummox JR
That seems like a good solution. My guess is that you are creating a “library” of Sudoku puzzles that program can choose from? I would try to add a check to make sure that duplicates or shifted puzzles are not created to speed up the process. For example, if you have one easy puzzle and you just flip the puzzle over, it is basically the same puzzle, so maybe you could figure out some preliminary checks before you use the rating algorithm.

In response to Drumersl
I agree with the building before hand. Make a generator to pump out a couple thousand puzzles, then make a game to read the pregenerated puzzles. Although this sounds good, the size might become an issue. That way your users see almost no time for opening, and you just have to sit there for a few hours while building up the puzzles.
In response to Drumersl
Drumersl wrote:
That seems like a good solution. My guess is that you are creating a “library” of Sudoku puzzles that program can choose from?

No; I could do that with my C++ generator. What I want is a game that can generate its own puzzles, even if it needs some sort of callable helper app to do it.

I would try to add a check to make sure that duplicates or shifted puzzles are not created to speed up the process. For example, if you have one easy puzzle and you just flip the puzzle over, it is basically the same puzzle, so maybe you could figure out some preliminary checks before you use the rating algorithm.

The odds of random generation creating functionally identical puzzles are astronomical, so this isn't a concern.

Lummox JR
Gah! A Java applet to increase speed? Gads no. If you want to increase your speed, at least use something speedy. BYOND works almost exclusively on Windows, so you're pretty safe using a Windows executable written in your choice of speedy compiled languages.
In response to PirateHead
Ah, but when was the last time you embedded an ordinary Windows executable in the browser? =) I'm assuming that's what Lummox meant, since he said "Java applet" and not "Java application" - which are two pretty different things.

I'll agree that Java is slow, but in fairness that's mostly the API's fault. For pure number-crunching (like generating Sudoku puzzles) I'm willing to bet that it's faster than BYOND.
In response to PirateHead
I would be pissed off if I couldn't play a game Lummox wrote because he assumed everyone would be using windows. 'Coz I'm not.
In response to Jp
If you have a graphical BYOND client on a non-Windows platform, you have a software emulator that could probably handle a simple number-crunching app. If you don't have a graphical BYOND client, don't complain because you can't play any of Lummox's games anyway.
In response to PirateHead
PirateHead wrote:
If you have a graphical BYOND client on a non-Windows platform, you have a software emulator that could probably handle a simple number-crunching app. If you don't have a graphical BYOND client, don't complain because you can't play any of Lummox's games anyway.

Except SotS II, which will run in text mode but probably still doesn't look terribly great on a 'nix system.

Lummox JR
In response to Lummox JR
Plus, a game of that type does naturally sort of lend itself to supporting text mode.
In response to PirateHead
I'm pretty sure BYOND doesn't run under WINE. And I can't tell Lummox's code to run 'wine SDKgenerator.exe' as opposed to 'SDKgenerator.exe'
In response to Jp
Jp wrote:
I'm pretty sure BYOND doesn't run under WINE. And I can't tell Lummox's code to run 'wine SDKgenerator.exe' as opposed to 'SDKgenerator.exe'

Which is moot anyway, as I said in no uncertain terms I would not be using an .exe for this.

Lummox JR
I seem to have hit a snag with my Java applet idea. Apparently, Java is incapable of using byond:// URLs because it doesn't recognize the protocol. Based on DM's speed at working with sudoku, though, I still think Java is the best choice of workhorse. The question arises, though, how do I get a Java applet in the browser to talk to DM?

Lummox JR
In response to Lummox JR
Howabout submiting it in a form. using hidden fields with java changing values?
In response to Scoobert
Scoobert wrote:
Howabout submiting it in a form. using hidden fields with java changing values?

Java can't really do that; JavaScript can.

Lummox JR
In response to Lummox JR
Oh, I thought you where doing java-script, for some odd reason.
In response to Lummox JR
How about dumping it into a comma seperated list and having DS pick it up?
In response to Lummox JR
this webpage seems to explain how to get java to talk to javascript, which can then pass information to BYOND. its not the most convenient method, but it doesn't seem like it should be a problem if you're just having the applet do a bunch of calculations and pass some result back to BYOND.

i haven't been able to test anything mentioned on the website to see if it works.
In response to OneFishDown
OneFishDown wrote:
this webpage seems to explain how to get java to talk to javascript, which can then pass information to BYOND. its not the most convenient method, but it doesn't seem like it should be a problem if you're just having the applet do a bunch of calculations and pass some result back to BYOND.

i haven't been able to test anything mentioned on the website to see if it works.

Well, the example on that page doesn't work, but it doesn't surprise me since it's an older page. Apparently it's using LiveConnect, a Netscape technology that seems to be difficult at best to implement in an applet.

Lummox JR