A Wedding in the Bestiary

Ken Webb Sun, 08 Aug 2010 16:25:00 +0000

My daughter is getting married soon. In honor of that happy occasion, I've put together the starting point for how a traditional wedding ceremony (not the same as the ceremony for my daughter's wedding) might work in the Bestiary. We need three things to get started: a Church building, the Groom, and of course the Bride. Let's call the bride Nan, and the groom Rolyn.

This post is partly an exercise to test out my new Toshiba NB305 netbook, and get started using it to do Java development. For now, I am sticking with Windows 7 Starter that comes pre-installed on the netbook. I am using Notepad++ (version 5.7) as my editor for text, Java source code, and XML content. I'm using the Bestiary applet to "compile", test, run, and debug the code.

Start up the Bestiary applet in another browser page.

Here's a traditional layout for a Christian Church building: (W)all, (P)orch, (D)oor, (E)ntry, (.) interior, (_) exterior. To paste this somewhere in the center of the grid:

<BestiaryPattern>
_________P
____WWWWWDWWWWW
____W....E....W
____W.........W
____W.........W
____W.........W
____W.........W
____W.........W
____W.........W
____W.........W
____W.........W
____W.........W
WWWWW.........WWWWW
W.................W
W.................W
W.................W
W.................W
W.................W
WWWWW.........WWWWW
____W.........W
____W.........W
____W.........W
____W.........W
____W.........W
____W.........W
____WWWWWWWWWWW
</BestiaryPattern>

Add Rolyn the groom in the lower part of the church near the bottom wall, and directly in line with the door at the top. If he's not placed properly the indignant bride will walk right by and on through the wall. Rolyn waits near the alter for the bride to appear.

<Groom roleName="Rolyn"/>

Now add Nan the bride. She should be placed outside the church, a few spaces to the north of the only door. Nan walks slowly down the aisle in a southerly direction until she reaches Rolyn, and then she stops.

<Bride roleName="Nan" implName="org.primordion.user.app.Bestiary.Beast">
<MovingBridebehavior implName="org.primordion.script.Behavior_beanshell"><![CDATA[
import org.primordion.xholon.base.AbstractGrid;
import org.primordion.xholon.base.IGrid;
import org.primordion.xholon.base.IXholon;
import org.primordion.xholon.util.MiscRandom;
behavior() {
int direction = IGrid.P_SOUTH;
int state = 1;
public void act() {
 switch(state) {
 case 1:
   move();
   if (isGroomCell()) {
     state = 3;
   }
   else {
     state = 2;
   }
   break;
 case 2:
   state = 1;
   break;
 case 3:
   break;
 default: // error
   state = 1;
   break;
 }
}
protected void move() {
 IXholon bride = contextNodeKey.getParentNode();
 AbstractGrid destination = (AbstractGrid)bride.getParentNode();
 destination = (AbstractGrid)destination.port[direction];
 if (destination != null) {
   bride.removeChild();
   bride.appendChild(destination);
 }
}
protected boolean isGroomCell() {
 IXholon node = contextNodeKey.getParentNode().getParentNode().getFirstChild();
 while (node != null) {
   if ("Groom".equals(node.getXhcName())) {
     return true;
   }
   node = node.getNextSibling();
 }
 return false;
}
return this;
}
behaviorObject = behavior();
]]></MovingBridebehavior>
</Bride>

There will probably also be a number of cats and other humans scurrying about inside the church.

Comment from Eagore

Hi Nan,

I'm the city by-law enforcer for cat problems. I can solve your too many cats problem by catching most of the strays and putting them in the pound (animal shelter). To get me working on this:

<CatBylawEnforcer roleName="Eagore" implName="org.primordion.user.app.Bestiary.Beast">

<MoveCatToPoundEnforcerbehavior implName="org.primordion.script.Behavior_beanshell"><![CDATA[
import org.primordion.xholon.base.IXholon;
 
behavior() {

IXholon pound = null;

public void postConfigure() {
  pound = contextNodeKey.getParentNode().getParentNode();
}

public void act() {
  moveCatToPound();
}
 
protected void moveCatToPound() {
  IXholon enforcer = contextNodeKey.getParentNode();
  IXholon node = enforcer.getFirstSibling();
  while (node != null) {
    if ((node != this) && ("Cat".equals(node.getXhcName()))) {
      node.removeChild();
      node.appendChild(pound);
      return;
    }
    node = node.getNextSibling();
  }
}

return this;
}
behaviorObject = behavior();
]]></MoveCatToPoundEnforcerbehavior>

<MovingEnforcerbehavior implName="org.primordion.script.Behavior_beanshell"><![CDATA[
import org.primordion.xholon.base.AbstractGrid;
import org.primordion.xholon.base.IGrid;
import org.primordion.xholon.base.IXholon;
import org.primordion.xholon.util.MiscRandom;
 
behavior() {

public void postConfigure() {
  IXholon enforcer = contextNodeKey.getParentNode();
  AbstractGrid habitatCell = enforcer.getParentNode();
  while (habitatCell.hasChildNodes()) {
    habitatCell = (AbstractGrid)habitatCell.port[IGrid.P_EAST];
  }
  enforcer.removeChild();
  enforcer.appendChild(habitatCell);
}

public void act() {
  move();
}
 
protected void move()
{
  IXholon enforcer = contextNodeKey.getParentNode();
  boolean foundNewLocation = false;
  int count = 0;
  while ((!foundNewLocation) && (count < 10)) {
    int moveX = MiscRandom.getRandomInt(0, 3) - 1;
    int moveY = MiscRandom.getRandomInt(0, 3) - 1;
    int portX = moveX > 0 ? IGrid.P_EAST : IGrid.P_WEST;
    int portY = moveY > 0 ? IGrid.P_NORTH : IGrid.P_SOUTH;
    int moveIncX = moveX > 0 ? -1 : 1;
    int moveIncY = moveY > 0 ? -1 : 1;
    count++;
    AbstractGrid destination = (AbstractGrid)enforcer.getParentNode();
    while ((destination != null) && (moveX != 0)) {
      destination = (AbstractGrid)destination.port[portX];
      moveX += moveIncX;
    }
    while ((destination != null) && (moveY != 0)) {
      destination = (AbstractGrid)destination.port[portY];
      moveY += moveIncY;
    }
    IXholon artifact = destination.getFirstChild();
    if (artifact != null) {
      switch (artifact.getXhcId()) {
      case 15: //CeBestiary.DoorCE:
        // can the beast move through the door?
        if (!canMoveThruDoor(artifact)) {
          destination = null;
        }
        break;
      case 16: //CeBestiary.WallSectionCE:
        destination = null;
        break;
      default:
        break;
      }
    }
    if (destination != null) {
      enforcer.removeChild();
      enforcer.appendChild(destination);
      foundNewLocation = true;
    }
  }
}
 
protected boolean canMoveThruDoor(IXholon door) {
  return false;
}
 
return this;
}
behaviorObject = behavior();
]]></MovingEnforcerbehavior>

</CatBylawEnforcer>

Comment from Nan - Too many cats

I'm allergic to cats, and there are just too many of them running amok, even in the church. That Licorice with his green eyes sure is cute, but I'll break out in a rash if he or his friends get too close. What can I do?

Comment from Nan - How can I invite my neighbors to the wedding?

I'd like to invite my neighbors to the wedding, but all they ever seem to do is go whizzing by and say "Hi". Any ideas out there?

Comment from anon

The easiest way to invite your neighbors, is to reuse Eagore the cat by-law enforcer. Just change "Cat" in the moveCatToPound() method to "Human". Eagore's a big guy and he moonlights as a bouncer; he'll start reeling them in.

return to main page