Stephen Davies -- University of Mary Washington
The Java zip file for this assignment actually comes with two simulators: a text-based one, and a graphical one. The text-based simulator shows verbose output with every card played in a round. It is useful for following the flow of a single round and seeing which players' strategies make which choices. The graphical one is suitable for "big screen" display, as it shows the entire unfolding drama of the 50,000-round match between four participants.
Both simulators read the names of the player's .java files from the
file called players.txt
. This is an ordinary text file that
can be edited with vim, Notepad, or your IDE's editor. It should contain
four comma-delimited lines, as so:
Rossanna,rcatahan Becky,rbrown4 Gray,gkemmey Jake,jnedza
The text before the comma is the player's name, and will show up on the
screen. The text after is the prefix of the player's .java class,
which should be followed by "_UnoPlayer
" to form the actual
class name (and "_UnoPlayer.java
" to form the actual file
name.) For instance, the above line specifies that player "Rossanna" will
be using file rcatahan_UnoPlayer.java. All player's Java files must be
compiled, and in the uno
directory in order to be found by the
simulator.
Import all the Java code in the uno
package into your IDE
of choice, and make "uno.UnoSimulation
" your main
class. If you're using the command line (as I do) make sure that all
the .java files are in an "uno" directory, and put "uno" in your CLASSPATH.
Then, compile all the code using javac. When you run the simulator, you'll
be using class uno.UnoSimulation
as the argument to
java
.
The text-based simulator takes two command-line arguments, the second of
which is optional: the number of rounds in the overall match, and the
string "verbose" or "quiet" (the default being "verbose"). When verbose,
the simulator prints out each play as shown in the figure below -- this is
best when running only a single game. When quiet, the simulator only prints
the overall scoreboard at the end of the match, to increase the speed of
long simulations (though I recommend the graphical simulator for this,
since it has more pizzazz.) The entire command line, therefore, is
something like: java uno.UnoSimulation 1
or java
uno.UnoSimulation 10000 quiet
.
The text-based simulator, like the graphical simulator, uses the
players.txt
file to determine the names of the players and
their filenames (see above).
A note about color: not all terminals support ANSI escape sequences. If
yours does, then you can see the output in color (as in the figure)
by changing line 24 of Card.java to read "true
", then
recompiling. I made the default be false
so you don't get
weird output if you have an unsupported terminal (like Windows
NetBeans).
Import all the Java code in the uno
package into your IDE
of choice, and make "uno.GraphicalUnoSimulation
" your main
class. If you're using the command line (as I do) make sure that all
the .java files are in an "uno" directory, and put "uno" in your CLASSPATH.
Then, compile all the code using javac. When you run the simulator, you'll
be using class uno.GraphicalUnoSimulation
as the argument to
java
.
The graphical simulator takes one command-line argument: the number of
rounds in the overall match. I used 50,000 for this, but it can obviously
be adjusted accordingly. The entire command line, therefore, is something
like: java uno.GraphicalUnoSimulation 50000
.
When it comes up, the simulator reads the names and filename prefixes from the players.txt file, as described above. Press the Uno card icon and you're off!