Monday, August 30, 2010

Open Source Project: VASSAL

Overview:
"The VASSAL Engine is a game engine for creating electronic versions of traditional board and card games. It provides support for game piece rendering and interaction, and supports play by email or over a live connection. " - http://sourceforge.net/projects/vassalengine/
In a nutshell, VASSAL provides the back end code for Internet connectivity either to the VASSAL server, or over a direct P2P connection.  Vassal loads ".VMOD" files (essentially renamed zip files) called modules which contain the data for a particular game.  The VASSAL community supports hundreds of different game modules (http://www.vassalengine.org/), with varying levels of user activity and module development.  The modules themselves contain images, map files and XML data.  The engine runs by presenting the user with a blank map/board, onto which game pieces can be placed and moved.  The engine provides basic tools such as dice, rulers, space for tracking various items, and chat functionality.  The engine does not enforce any game-specific rules, so players  must audit games themselves.   


Prime Directive 1:
The system successfully accomplishes a useful task.


By providing basic tools, and excellent tutorials,  VASSAL provides the framework for implementing nearly any board or card game. 


VASSAL looks to be very useful as games that take up large amounts of space, or require many parts to play can be virtualized.  This allows for mobility, the ability to play with new people, and is considerably cheaper than buying actual game sets.


Prime Directive 2:
An external user can successfully install and use the system.

 VASSAL, unlike many other Open Source projects, provides an executable installer, which makes installation a breeze.  With more than the basic "README" file, VASSAL's startup guide, active user forums, in-game chat feature, and Wiki provide many avenues of support for new and inexperienced users.  Additional proof of VASSAL's popularity and usability can be found in its server logs, which clocks over a thousand users per day.


Using VASSAL was fairly straightforward, GUI's guided me through the setup and connection process. I chose a module for a game called "Warmachine", and imported it into VASSAL. The Engine provides many buttons and a windowed view to let you reference multiple things at once. I suppose the learning curve is quite steep for figuring out the functionality, although having people to chat with in real time is very helpful.


Prime Directive 3:
An external developer can successfully understand and enhance the system.


The project's tutorials are highly detailed and provide developers with the explanations, illustrations and documentation to develop modules.  Walkthoughs for sample games are provided, and seem simple enough to duplicate and modify.  Modules can be designed with a GUI, which makes VASSAL seem like an ideal platform for implementation. 

With respect to source code however, documentation is lacking, and it seems as though developing the engine might require reading though a lot of code.  However, the code is almost exclusively done in abstract data types, so bits of code can be taken and implemented for other projects rather easily. 
 

Saturday, August 28, 2010

FizzBuzz #1

Premise: 
As an assignment for ICS 413, I timed myself in writing a simple FizzBuzz Program.  I suspect this will become a recurring assignment that will be used as a metric of our progress in the course.

Requirements:
A method that returns a FizzBuzz String. 

A FizzBuzz String can be defined as: a String where the numbers 1 through j are printed out according to the following conditions:
  • One number per line.
  • The multiples of 3 replaced by "Fizz".
  • The multiples of 5 replaced by "Buzz".
  • The multiples of both 3 and 5 replaced by "FizzBuzz".
Time:
3m 13s

Code:

public class FizzBuzz {
  
public static void main(String[] Args){
    System.out.print
(fizzBuzz(100));
  
}

  
public static String fizzBuzz(int j){
    
String s="";
    
Boolean b=false;
    
for(int i =1;i<=j;i++){
       b
=false;
      
if(i%3==0){
        s
+="Fizz";
        
b=true;
      
}
      
if(i%5==0){
          s
+="Buzz";
          
b=true;
      
}
      
if(!b){
          s
+=i;
      
}
       s
+="\n";
    
}
    
return s;
  
}


Approach:
My approach to the problem was to iterate through the numbers 1 to j, checking for multiples of 3 or 5, and appending the correct output. My implementation removes the need to check for multiples of both 3 and 5 as both conditions will trigger (appending "Buzz" to "Fizz") before the new line character is appended.

Conclusions:
This exercise illustrates how even a simple FizzBuzz program can speak volumes about a programmer. One's attention to detail, eye for optimization, and thought process can be dissected out of a few dozen lines of code. 

 I believe I spent about a third of my time simply planning out how to solve the problem, and trying to minimize the number of checks in the program.  Despite this, I suspect there is still room for optimization in finding a way to determine whether or not the number should be printed. I implemented a Boolean variable to keep track of whether or not to print the number, but this added another check statement.  I will investigate this further in the next FizzBuzz post.

Wednesday, August 25, 2010