Sumo - A Java Based Implementation of Sumo Wrestling with Serialization
For CSCI 315 Advanced Java Programming (Self-Paced Web Course)
CSU Chico
28 June 2003
By
Andrew Tree
520 E. California Ave.
Ridgecrest, CA 93555
Email: Andrew.Tree@navy.mil
An abbreviated UML class diagram is shown in the following figure. To get to the ADT documentation relevant to a particular class, you can click on the class in the diagram. Java JDK core classes are not shown.

Sumo is a one-on-one sport like judo or wrestling. The object of the game is simple, push your opponent out of the circle any way you can. This game of Sumo which I have created works the same way. Once both players are ready the goal is to push each other out of the circle to score points.
I choose to implement the Sumo game so that I could demonstrate the many uses of Java Serialization. In this project I am using Serialization in two different ways. First of all a user can save a game at any point during play so that it can be reopened at a later point. Second, all communication between players during actual play is done by Serialization.
When a user saves a game during play many objects must be saved so that the
game can be properly reopened at a later time. The following objects, in the
following order, are saved to a user specified "*.sumo" file:
(1) The two different player's characters.
(2) The names of each player.
(3) The physical location of each player in the game.
(4) The score for each player.
Serializing most of these objects was straight forward with the exception of the
character's images. The character's images are of Java data type "ImageIcon" which are
serializable, however, not for long. Sun has decided not to support serialization of
objects of this class in future Swing releases. So, instead of just ignoring the issue
and serializing the "ImgaeIcon" objects I converted the images into an Integer array
of pixels. Then, when the Integer array is read back in, the array is then converted back
to an ImageIcon that can be displayed. That way if this game is ever used with future
versions of Swing everything will still work.
As mentioned all communication between the users is done by passing serialized objects. For example when a user changes their player's character that image is converted to an Integer array and serialized to the opponent where it reads in the serialized Integer array and converts it back to an image so that it can be displayed. Or, as a second example, every time a player moves their new location (a "Point" object) is serialized to their opponent so that their new location can be updated on the Sumo playing area. For right now both players are restricted to play on the same computer, however, all the socket communication is set up to work across a network. The only modifications that would have to be made is to somehow specify the name of the computer your opponent is on and vice-versa. For simplicity, the decision was made to make the assumption that both players would be running on the same computer.
The program's architecture is based on the Model-View-Controller method. The PlayerModel (Model)
class controls all the game data and details. While the PlayerGUI (View-Controller) class does nothing
more than deal with how things are displayed and the handling user events. Finally, the ServerClient
class deals with all the the work to serialize objects, send the object using sockets and read in
objects when they are received.