Speak Spanish

Ken Webb 2010-12-01T15:50:07Z

Some Sample Spanish Phrases that a fairly advanced beast might be able to speak.

Some possible Spanish Word Lists. Each list should have a set of related words.

A new behavior that will let a beast say something in Spanish.

<Gatobehavior implName="org.primordion.script.Behavior_beanshell"><![CDATA[
import org.primordion.xholon.base.IXholon;

behavior() {
 
public void act() {
  speakSpanish();
}
 
protected void speakSpanish()
{
  IXholon gato = contextNodeKey.getParentNode();
  gato.println("Buenos dios");
}
 
return this;
}
behaviorObject = behavior();
]]></Gatobehavior>

The following is a more comprehensive behavior. Add this behavior as a child of any single beast. The beast will say something in Spanish each time it moves into a grid cell that contains a passive object (see below).

<SpeakSpanishbehavior implName="org.primordion.script.Behavior_beanshell"><![CDATA[

/**
 * ex: Veo un libro.
 * TODO
 * - If there are 2+ passive objects, include all of them in the phrase.
 *   ex: Veo un libro y una mesa.
*/

import org.primordion.xholon.base.IXholon;

behavior() {
 
public void act() {
  speakSpanish();
}
 
protected void speakSpanish()
{
  IXholon aBeast = contextNodeKey.getParentNode();
  if (aBeast.hasSiblingNodes()) {
    IXholon sib = aBeast.getParentNode().getFirstChild();
    while (sib != null) {
      if (sib != aBeast) {
        if (isPassiveObject(sib)) {
          StringBuffer sb = new StringBuffer()
          .append("Veo ");
          if (isMasculine(sib)) {
            sb.append("un ");
          }
          else {
            sb.append("una ");
          }
          String xhcName = sib.getXhcName();
          sb.append(xhcName.substring(0,1).toLowerCase() + xhcName.substring(1));
          sb.append(".");
          aBeast.println(sb);
        }
      }
      sib = sib.getNextSibling();
    }
  }
}

protected boolean isPassiveObject(IXholon node)
{
  String rn = node.getRoleName();
  if (rn == null) {return false;}
  if (rn.equals("PassiveObject")) {
    return true;
  }
  return false;
}

/**
 * TODO might want to check to see if roleName = "Gender"
 */
protected boolean isMasculine(IXholon node)
{
  IXholon attrNode = node.getFirstChild();
  if (rn == null) {return true;}
  String val = attrNode.getVal_String();
  if (val == null) {return true;}
  if (val.equals("M")) {
    return true;
  }
  return false;  
}

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

Before a beast can say anything in Spanish, you will need to add some passive objects to the simulation. The following is a sample list of ten words (palabres). Paste this word list into the simulation while Bestiary/Beasts is the context node.

<_-.palabras>
<Libro roleName="PassiveObject"><Attribute_String roleName="Gender">M</Attribute_String></Libro>
<Mapa roleName="PassiveObject"><Attribute_String roleName="Gender">M</Attribute_String></Mapa>
<Papel roleName="PassiveObject"><Attribute_String roleName="Gender">M</Attribute_String></Papel>
<Lapiz roleName="PassiveObject"><Attribute_String roleName="Gender">M</Attribute_String></Lapiz>
<Silla roleName="PassiveObject"><Attribute_String roleName="Gender">F</Attribute_String></Silla>
<Cama roleName="PassiveObject"><Attribute_String roleName="Gender">F</Attribute_String></Cama>
<Mesa roleName="PassiveObject"><Attribute_String roleName="Gender">F</Attribute_String></Mesa>
<Reloj roleName="PassiveObject"><Attribute_String roleName="Gender">M</Attribute_String></Reloj>
<Anillo roleName="PassiveObject"><Attribute_String roleName="Gender">M</Attribute_String></Anillo>
<Botella roleName="PassiveObject"><Attribute_String roleName="Gender">F</Attribute_String></Botella>
</_-.palabras>

Because the existing cats and humans are already doing a lot of talking, it would be best to delete all of them first, and then just recreate one new cat or human or other beast. Then add the new SpeakSpanish behavior as a child of that beast, and add in the word list. The Java Console will display the resulting Spanish phrases. It would be best to paste in the word list mltiple times so the beast has a better chance of finding the passive objects from the word list, or you can paste in multiple instances of the beast.

return to main page