Package org.ggp.base.util.symbol.grammar

Examples of org.ggp.base.util.symbol.grammar.SymbolList


     * @return
     */
    public List<Gdl> getRules() {
      try {
          List<Gdl> rules = new ArrayList<Gdl>();
          SymbolList list = (SymbolList) SymbolFactory.create(theRulesheet);
          for (int i = 0; i < list.size(); i++)
          {
              rules.add(GdlFactory.create(list.get(i)));
          }
          return rules;
      } catch (GdlFormatException e) {
        e.printStackTrace();
        return null;
View Full Code Here


{
  public Request create(Gamer gamer, String source) throws RequestFormatException
  {
    try
    {
      SymbolList list = (SymbolList) SymbolFactory.create(source);
      SymbolAtom head = (SymbolAtom) list.get(0);

      String type = head.getValue().toLowerCase();
      if (type.equals("play"))
      {
        return createPlay(gamer, list);
View Full Code Here

      throw new IllegalArgumentException("Expected at least 5 arguments!");
    }

    SymbolAtom arg1 = (SymbolAtom) list.get(1);
    SymbolAtom arg2 = (SymbolAtom) list.get(2);
    SymbolList arg3 = (SymbolList) list.get(3);
    SymbolAtom arg4 = (SymbolAtom) list.get(4);
    SymbolAtom arg5 = (SymbolAtom) list.get(5);

    String matchId = arg1.getValue();
    GdlConstant roleName = (GdlConstant) GdlFactory.createTerm(arg2);
    String theRulesheet = arg3.toString();
    int startClock = Integer.valueOf(arg4.getValue());
    int playClock = Integer.valueOf(arg5.getValue());

    // For now, there are only five standard arguments. If there are any
    // new standard arguments added to START, they should be added here.
View Full Code Here

      return null;
    }
    else
    {
      List<GdlTerm> moves = new ArrayList<GdlTerm>();
      SymbolList list = (SymbolList) symbol;

      for (int i = 0; i < list.size(); i++)
      {
        moves.add(GdlFactory.createTerm(list.get(i)));
      }

      return moves;
    }
  }
View Full Code Here

  private static Gdl createGdl(Symbol symbol)
  {
    if (symbol instanceof SymbolList)
    {
      SymbolList list = (SymbolList) symbol;
      SymbolAtom type = (SymbolAtom) list.get(0);

      if (type.getValue().equals("<="))
      {
        return createRule(list);
      }
View Full Code Here

  private static GdlLiteral createLiteral(Symbol symbol)
  {
    if (symbol instanceof SymbolList)
    {
      SymbolList list = (SymbolList) symbol;
      SymbolAtom type = (SymbolAtom) list.get(0);

      if (type.getValue().toLowerCase().equals("distinct"))
      {
        return createDistinct(list);
      }
View Full Code Here

            moveHistory.add(theMove);
        }
        JSONArray theStates = theMatchObject.getJSONArray("states");
        for (int i = 0; i < theStates.length(); i++) {
            Set<GdlSentence> theState = new HashSet<GdlSentence>();
            SymbolList stateElements = (SymbolList) SymbolFactory.create(theStates.getString(i));
            for (int j = 0; j < stateElements.size(); j++)
            {
                theState.add((GdlSentence)GdlFactory.create("( true " + stateElements.get(j).toString() + " )"));
            }
            stateHistory.add(theState);
        }
        JSONArray theStateTimes = theMatchObject.getJSONArray("stateTimes");
        for (int i = 0; i < theStateTimes.length(); i++) {
View Full Code Here

    return species;
  }

  public InfoResponse(Symbol symbol) {
    if (symbol instanceof SymbolList) {
      SymbolList pairs = (SymbolList)symbol;
      for (int i = 0; i < pairs.size(); i++) {
        Symbol pairSymbol = pairs.get(i);
        if (pairSymbol instanceof SymbolList) {
          SymbolList pair = (SymbolList)pairSymbol;
          if (pair.size() < 2) continue;
          String key = pair.get(0).toString().toLowerCase();
          String value = "";
          for (int j = 1; j < pair.size(); j++) {
            value += pair.get(j).toString();
          }
          if (key.equals("name")) {
            name = value;
          } else if (key.equals("status")) {
            status = value;
View Full Code Here

TOP

Related Classes of org.ggp.base.util.symbol.grammar.SymbolList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.