Error message

  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /data03/toxictux/public_html/main/includes/common.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /data03/toxictux/public_html/main/includes/menu.inc).

Customising GuessHoo

Have you ever played the classic MB board game Guess Who? During Christmas I decided to write my own version of that game in java. My java version of the original Guess Who game is in the games section here.
 
This article will describe how to use my java engine "GuessHoo" to create your own custom guessing games.  All you need to do is provide your own pictures and a XML configuration file.
 
If you just want to play Guess Who , then You can play my version of the Guess Who game here
 
Embeding the applet
The GuessHoo engine is a java applet and requires one parameter. The location where it can find it's configuration file.
 
<applet code="GuessHooApplet.class" codebase="/GuessHoo/" archive="GuessHoo.jar" width=750 height=400>
<param name="urlpath" value="http://www.badpenguin.co.uk/GuessHoo/classic">
</applet>
 
The urlpath parameter should be set to the directory containing the "people.xml" configuration file. The applet code above would expect to find it's configuration file at this location: http://www.badpenguin.co.uk/GuessHoo/classic/people.xml.
 
To get an idea of what is required, you can see all the files I use in my classic themed game right here.
 
So what's in the config file
The configuration file contains a  <GuessHooPeople> root element, which must contain an attibute called "datums". The datums attribute should be the number of attributes used within the game. In my classic version there are 17 attributes, so the datums value is set to 17.
 
Within <GuessHooPeople> we have <DatumMap>, which maps the datum IDs to short descriptions. We have 24 <Person> elements, one for each of the 24 playing cards. The Person elements all have an "id" attribute (0-23) in a full deck. The Person elements contain a <Name>, <Image> and <datum> elements. Finally we have a <Questions> element which maps the datum ID's to a "Yes/No"  question for that attribute.
 
A simple example with just 2 datums and 1 playing card....
 
<GuessHooPeople datums="2">
  <DatumMap>
    <datum id="0">man</datum>
    <datum id="1">woman</datum>  
  </DatumMap> 
  <Person id="0">
    <name>Mark</name>
    <image>mark.jpg</mark>
    <datum id="0">true</datum>
  </Person>
  <Questions>
    <datum id="0">Is this person a man?</datum>
    <datum id="1">Is this person a woman?</datum> 
  </Questions>
</GuessHooPeople> 
 
In the above example you should be able to see that datum ID 0 refers to "man". The question for that datum is "Is this person a man". You can also see from the Person element that person 0 has a name of "Mark", his image is stored in "mark.jpg" and he is a man (datum 0 is set to true).
 
All datums by default are false. So it is not necessary for Person 0 to have "<datum id="1">false</datum>". Obviously Name and Image are mandatory. The applet will attempt to find the file "mark.jpg" in the directory specified by the urlpath parameter. So if "Mark" was in the classic game, the computer would look for the picture at http://www.badpenguin.co.uk/GuessHoo/classic/mark.jpg. In other words, "urlpath/mark.jpg".
 
I would recommend you refer to my people.xml and people.dtd from the classic game for more information. You will need to have a copy of people.dtd on your site and have your people.xml reference it.
 
Adding your pictures
All of the pictures I used in the classic version are 90 x 130 pixels. The game board has been designed with this size in mind. I may make sizing an optional parameter at some point, but for now it would look best with pictures of that size. I'm affarid you do need 24 of them at the moment. I may consider adding a half size option with just 12 characters if anyone wants it?
 
Changing the code 
I'm a big believer in Open Source, so this game is released under the terms of the GNU GPL version 2. The terms of which you can read here. If you accept those terms the source code is here
 
 
Tags: