Smithers's Java Code

Downloads

I have written a sizeable quantity of Java code. The source code, object code and documentation are available below. I have built this code using Java SE 6; it should build and run successfully with Java SE 6 or higher. Some or all of it may also build and/or run under older versions. All of the code featured is released under the GNU General Public License, version 3 or any later version published by the Free Software Foundation. This mainly means that you are free to use the software any way you wish, as well as to share and modify the code, as long as any copies or derived works that you share are licensed under the same terms and you must also share the full source code.

Source code:
Download (tar.gz)
Object (executable) code:
Download (jar)
Documentation:
Download (tar.gz)
View online
Complete download:
Download (tar.gz)
Twisty puzzles collection:
Download (executable jar)
GPL v3 logo

Disclaimer

All of this software was written for my own amusement. It is made available here in the hope that someone else might find it useful, fun or interesting. It is provided with NO WARRANTY and NO SUPPORT. Some of the functionalilty may be broken and I accept NO RESPONSIBILITY for any damage thereby caused. Please see the appropriate sections of the GPL for details.

That being said, if you DO find any bugs in this code, I would like to know! Please send any bug reports to webmaster@smithers.net63.net, including as much information as possible about

Most of this software was originally written during, and in the six months after, my time as a student at Warwick University (2006-2010). As I now have a full time job, I don't have much time to update this any more. Hence updates and fixes may be extremely sparse.

Running the programs

If you know how to run programs from .jar files, you can skip this paragraph, if not, here's one way to do it. Make sure you have installed the Java Runtime Environment; you can get this from http://www.java.com/en/download/. Download the object code file (smithers.jar) and open a terminal/console/command prompt to the correct directory. Then type java -cp smithers.jar package_name.program_name arguments. Here package_name is the name of the package (e.g. smithers.twisty), program_name is the name of the program (e.g. TwistyPuzzleViewer) and arguments is the arguments to the program (e.g. -r5 -a2).

Alternatively, some programs are also available as executable jar files. These contain all of the required classes for a specific program and can be run with a command like java -jar jar_file arguments. The arguments here are the same as the arguments to the jar file's default class. Programs available in this form are:

Twisty puzzles. Jar file: puzzles.jar, default class: smithers.twisty.TwistyPuzzleViewer.

List of packages

This is the list of all the packages included, as well as the programs contained within them. All of the programs provide some level of help when run with the option "-h" or "--help". As a reference, this output is reproduced here.

smithers.calculator

Calculator

smithers.calculator.Calculator -- simple calculator utility.
Usage:
        java smithers.calculator.Calculator [options...] [expressions...]
If expressions are given, evaluate them and exit, otherwise evaluate expressions from standard input until a blank line is given.

Options:
  -h --help
        Print this help and exit.

Supported syntax and functions to follow...

smithers.cards

TerminalKlondike

smithers.cards.TerminalKlondike -- play Klondike in a terminal.
Usage:  java smithers.cards.TerminalKlondike [-h|--help]
If -h or --help is given, print this help and exit, otherwise play a game of solitare.
Commands:
  d     Draw cards (3 at a time) from the deck.
  nm    (where n and m are digits from 0 to 7)
        Move a card or cards from the postion n to position m. Positions 1-7 are the piles in the tableau from left to right. n=0 means move from the wastepile. m=0 means move to the foundations.
  q     Quit the game.

smithers.extras

Brainfuck

smithers.extras.Brainfuck -- brainfuck interpreter.

Cellular

smithers.extras.Cellular -- simulates 1-dimensional cellular automata.
Usage:  java smithers.extras.Cellular rule width steps

Cellular2D

smithers.extras.Cellular2D -- simulates 2-dimensional cellular automata.

FizzBuzz

smithers.extras.FizzBuzz -- plays the game of fizzbuzz.

ImageTool

smithers.extras.ImageTool -- performs operations on images.
Usage:
        java smithers.extras.ImageTool [-h|--help]
If -h or --help is given, print this help and exit. Otherwise interpret commands sequentially.
At the program's prompt, type `help' to list commands, and `help command' for help on a specific command

NumberString

smithers.extras.NumberString -- converts numbers to and from strings.
Usage:  java smithers.extras.NumberString [options...]
Creates a number and attempts to output it as digits and words.

Options: 
  -n n  Sets the number to the integer n.
  -d d  Sets the number to the real value d.
  -p s  Sets the number to the integer obtained by parsing the string s. Currently only valid if the language is English.
  -nr   Sets the number to a random integer.
  -dr   Sets the number to a random real value.
  -en   Sets the language to English.
  -fr   Sets the language to French/Francais.
  -de   Sets the language to German/Deutsch.
  -s    Sets the scale to the short scale.
  -l    Sets the scale to the long scale (no milliard).
  -m    Sets the scale to the long scale with milliard.
  -h
  --help
        Print this help and exit.

NumberStringTest

smithers.extras.NumberStringTest -- graphical test program for NumberString.

smithers.files

No programs

smithers.games

JTron

smithers.games.JTron -- light cycles game.
Usage: java smithers.games.JTron [options...]
Options:
  -p n  Set the number of players to n.
  -s n  Set the grid size to n.
  -t n  Set the speed to 1 frame per n milliseconds.
  -h
  --help
        Display this help message and exit.

In-game controls:
  Player 1 (Red): W/A/S/D
  Player 2 (Blue): Cursor Up/Left/Down/Right
  Player 3 (Green): I/J/K/L
  Player 4 (Yellow): T/F/G/H
Have Fun!

smithers.java3d

No programs

smithers.logicpuzzles

Hanjie

smithers.logicpuzzles.Hanjie -- Graphical solver of hanjie puzzles.
Usage:
        java smithers.logicpuzzles.Hanjie -h|--help
        java smithers.logicpuzzles.Hanjie puzzle

If -h or --help is given, display this help and exit.
Otherwise puzzle must be the path to a hanjie puzzle file (in the format output by smithers.logicpuzzles.HanjieBuilder).
In this case, the puzzle is displayed on the screen. Click outside the puzzle to solve it; left-click to advance one step, middle-click to advance one pass or right-click to solve as completely as possible.

HanjieBuilder

smithers.logicpuzzles.HanjieBuilder -- Creates hanjie puzzles from images.
Usage:
        java smithers.logicpuzzles.HanjieBuilder -h|--help
        java smithers.logicpuzzles.HanjieBuilder image

If -h or --help is given, display this help and exit.
Otherwise image must be the path to an image from which to create a hanjie puzzle. The puzzle will be printed to standard output.
The image should be of the same size as the puzzle to be produced, and can contain up to 26 colours, plus white which is used as the blank colour.

Mosaic

smithers.logicpuzzles.Mosaic -- Graphical solver of mosaic puzzles.
Usage:
        java smithers.logicpuzzles.Mosaic -h|--help
        java smithers.logicpuzzles.Mosaic puzzle

If -h or --help is given, display this help and exit.
Otherwise puzzle must be the path to a mosaic puzzle file (in the format output by smithers.logicpuzzles.MosaicMaker).
In this case, the puzzle is displayed on the screen. Click outside the puzzle to solve it; left-click to advance one step, middle-click to advance one pass or right-click to solve as completely as possible.

MosaicMaker

smithers.logicpuzzles.MosaicMaker -- Creates mosaic puzzles from images.
Usage:
        java smithers.logicpuzzles.MosaicMaker -h|--help
        java smithers.logicpuzzles.MosaicMaker image

If -h or --help is given, display this help and exit.
Otherwise image must be the path to an image from which to create a mosaic puzzle. The puzzle will be printed to standard output.
The image should be of the same size as the puzzle to be produced, and all non-white pixels are treated as black.

smithers.svg

No programs

smithers.twisty

Requires smithers.java3d

TwistyPuzzleViewer

smithers.twisty.TwistyPuzzleViewer -- Rubik's Cubes and similar puzzles.
Options:
  -r[s] Set puzzle to Rubik's Cube with side length s (default is 3).
  -s    Set puzzle to Square One / Cube21.
  --snake
        Set puzzle to Rubik's Snake.
  -a[t] Turn animation on (with time t) or off (-a) (does not apply to Rubik's Snake).
  -d
  --demo
        Run in demonstration mode (Rubik's Cube only).
  -i fName
        Get the face images from the image file fName (Rubik's Cube only).
  -h
  --help
        Display this help message and exit.

smithers.util

No programs