Skip to main content

Games People Play

Posted by editor on November 29, 2005 at 7:24 AM PST

Playing Sudoku and Quake 2 with Java

I usually don't have time do the daily Sudoku in the newspaper, but it's a smart diversion for when the opportunity presents itself, and something I've blogged about before -- the Sept 15 Editor's Daily Blog linked to Phil Milne's Swing-based Su Doku workpad and evaluator.

So, you can play Sudoku in Java, but how about solving it? Any Java developer could probably whip up a brute-force search of the problem space, but this is badly inefficient, to put it nicely. Ideally, you should be able to express the inherent concept of Sudoku -- that every row, line, and region must contain the numbers 1-9 with no duplicates -- and let the computer efficiently work within those constraints.

As it turns out, Sudoku is a fine way to teach the concepts of "constraint programming", as illustrated by
today's Feature Article, Solving Sudokus in Java, in which Yan Georget applies the Koalog Constraint Solver, a Java constraint programming library, to solve the puzzle and show how constraint programming works:

CP differs from naive enumeration methods by the fact that constraints contain powerful filtering algorithms (usually inspired by Operational Research techniques) that will drastically reduce the search space by dynamically reducing the domains of the variables during the enumeration phase (also known as the "search phase").

Hopefully, you'll find the ideas of constraint programming flexible enough to apply them to other problems you might need to solve.

Speaking of using Java for gaming,

Jake2, the Java port of the GPL'ed Quake 2 game engine, recently got "slashdotted", with the popular technology site noting that Jake2's Java Web Start page allows you to download, configure, and launch the game from your browser. Web-Start-ing allows you to choose (and evaluate) two versions of the game, one using JOGL for its graphics, the other using LWJGL.

Also in Projects and
, the Java Web Services and XML Community page is spotlighting Lorna Stafford's blog entry on the advantages and disadvantages of XBRL, "an XML-based language which allows business information to be electronically communicated more easily than through other available formats." More information about the language is available on the XBRL home page.

In Also in
Java Today

Alexander Libman and Vladimir Gilbourd's Comparing Two High-Performance I/O Design Patterns "investigates and compares different design patterns of high performance TCP-based servers. In addition to existing approaches, it proposes a scalable single-codebase, multi-platform solution (with code examples) and describes its fine-tuning on different platforms. It also compares performance of Java, C# and C++ implementations of proposed and existing solutions."

Stephane Bailliez's blog entry ClassLoaders in JEE 5 Specifications takes the Java EE 5 spec to task over the potential hazards and side-effects of its classloading model: "I have been reading the proposed final draft of the Java Platform Enterprise Edition 5 Specification (aka JSR 244) and noticed again that nothing has changed in the classloading area (OK, I did not send any feedback to the JSR group, so I'm guilty too). It is as vague as it has always been and do not impose anything which would clearly protect the deployed applications from server implementation libraries, otherwise known as class leaking."

Kirill Grouchnikov offers a Proposal for uniform support of third-party components in custom look-and-feels in today's Weblogs: "This posting proposes an approach for uniform support of third-party components in custom look-and-feels. The approach has been successfully adopted in Liquid and Substance look-and-feels."