home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / FREI / TUBES.EXE / Help.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-05-21  |  4.9 KB  |  64 lines

  1. import java.awt.Button;
  2. import java.awt.Choice;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.Frame;
  7. import java.awt.Label;
  8. import java.awt.Panel;
  9. import java.awt.TextArea;
  10. import java.awt.TextComponent;
  11. import java.awt.Window;
  12.  
  13. class Help extends Frame {
  14.    private static String[] _contents = new String[]{"Desiderata:", "   Once upon a time we got a 6-Tubes Puzzle for", "   an exercise in Artificial Intelligence.  Then", "   I implemented a graphical simulator of the", "   puzzle (originally with Open GL), which helped", "   me a lot in figuring out an appropriate", "   heuristic for solution from an arbitrary", "   initial state. Subsequently, I rewrote the", "   puzzle as an applet with Java. It's now open", "   to the general public, so you can play it in", "   your spare time. Enjoy!", "", "Topology:", "   The original 3D game consists of two sets of", "   tubes, the upper and the lower, each having 6", "   tubes arranged in a circle according to their", "   sizes. The two sets are combined together in", "   such way that one set can be rotated", "   relatively to the other.  The proposed", "   implementation simplifies the topology by", "   stretching the circle into the line and", "   allowing circular shift of the upper set of", "   tubes.", "", "Goal:", "   The tubes contain 21 colored beads. There is", "   one red bead, two yellow beads, ..., and", "   finally, 6 magenta beads. The number of beads", "   of each color corresponds the capacity of the", "   tube of same color. The goal of the game is to", "   put all the beads into corresponding tubes.", "   As you play, monitor the status line of your", "   browser/appletviewer; it'll inform you", "   whenever the current puzzle state is the goal", "   state.", "", "Controls:", "   In order to reach the goal state from an", "   arbitrary initial bead distribution the", "   following three operations are allowed:", "", "   o FLIP:  The two sets are flipped so that the", "            lower set becomes the upper one and", "            vice versa. As a result of this", "            operation the beads fall from the", "            tubes of the new upper set into the", "            corresponding tubes of the new lower", "            set;", "", "   o RIGHT: The upper set is circularly rotated", "            once to the right. As a result, beads", "            from the upper set of tubes might", "            fall into the tubes of lower set;", "", "   o LEFT:  Same as RIGHT but in the other", "            direction;", "", "   Buttons with these names are located at the", "   bottom of the applet. Moreover, the buttons", "   divide the applet into three equally sized", "   areas, so clicking in an appropriate area", "   performs the same action as the button", "   below. The buttons located over the applet are", "   self-explanatory. The HELP frame you are", "   currently reading, contains the LEVEL widget", "   which allows to change the skill level of the", "   puzzle (the number of tubes).", null};
  15.    private static String[] _levelNames = new String[]{"I'm too young to die", "Hey, not too rough", "Hurt me plenty", "Ultra-Violence", "Nightmare!", null};
  16.    private Tubes _applet;
  17.  
  18.    Help(Tubes var1, int var2) {
  19.       super("Puzzle Help");
  20.       this._applet = var1;
  21.       ((Container)this).add("West", new Panel());
  22.       ((Container)this).add("East", new Panel());
  23.       Panel var3 = new Panel();
  24.       ((Container)this).add("South", var3);
  25.       ((Container)var3).add(new Button("Hide"));
  26.       var3 = new Panel();
  27.       ((Container)this).add("North", var3);
  28.       ((Container)var3).add(new Label("Level:"));
  29.       Choice var4 = new Choice();
  30.       ((Container)var3).add(var4);
  31.  
  32.       for(int var5 = 0; _levelNames[var5] != null; ++var5) {
  33.          var4.addItem(_levelNames[var5]);
  34.       }
  35.  
  36.       var4.select(var2);
  37.       TextArea var6 = new TextArea(20, 40);
  38.       ((TextComponent)var6).setEditable(false);
  39.  
  40.       for(int var7 = 0; _contents[var7] != null; ++var7) {
  41.          var6.appendText(" " + _contents[var7] + "\n");
  42.       }
  43.  
  44.       ((Container)this).add("Center", var6);
  45.       ((Window)this).pack();
  46.    }
  47.  
  48.    public boolean action(Event var1, Object var2) {
  49.       if ("Hide".equals(var2)) {
  50.          ((Component)this).hide();
  51.          return true;
  52.       } else {
  53.          for(int var3 = 0; _levelNames[var3] != null; ++var3) {
  54.             if (_levelNames[var3].equals(var2)) {
  55.                this._applet.setLevel(var3);
  56.                return true;
  57.             }
  58.          }
  59.  
  60.          return super.action(var1, var2);
  61.       }
  62.    }
  63. }
  64.