Package cs227b.teamIago.resolver

Examples of cs227b.teamIago.resolver.ExpList


      return gameSim.GetGoalValue(role.getTerm().getExpr());
    }
  }

  public Collection<? extends MoveInterface<Term>> getLegalMoves(GameState state, RoleInterface<Term> role) {
    ExpList exprlist;
    synchronized (gameSim) {
      gameSim.SetGameState(state);
      exprlist=gameSim.GetLegalMoves(role.getTerm().getExpr());
    }
    Collection<MoveInterface<Term>> moveslist;
    if (exprlist == null) {
      Logger.getLogger(Reasoner.class.getCanonicalName()).warning(role+" has no legal move!");
      moveslist = Collections.emptyList();
    } else {
      moveslist = new ArrayList<MoveInterface<Term>>(exprlist.size());
      for(int i=0;i<exprlist.size();i++){
        moveslist.add(new Move<Term>(new Term(((Connective)exprlist.get(i)).getOperands().get(1))));
      }
    }
    return moveslist;
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  public Collection<? extends FluentInterface<Term>> getFluents(GameState state) {
    Collection<FluentInterface<Term>> fluents=new LinkedList<FluentInterface<Term>>();
    Iterator<ExpList> it=state.getMap().values().iterator();
    while(it.hasNext()){
      ExpList el=it.next();
      for(int i=0;i<el.size();i++){
        Predicate true_expr=(Predicate)el.get(i);
         fluents.add(new Fluent<Term>(new Term(true_expr.getOperands().get(0))));
      }
    }
    return fluents;
  }
View Full Code Here

    }
    return fluents;
  }
 
  public Collection<Term> getSeesTerms(GameState state, RoleInterface<Term> role, JointMoveInterface<Term> jointMove) {
    ExpList movesList = getMovesListForJointMove(jointMove);
    ExpList el = null;
    synchronized (gameSim) {
      gameSim.SetGameState(state);
      el = gameSim.getSeesTerms(role.getTerm().getExpr(), movesList);
    }
    Collection<Term> terms;
    if (el != null) {
      terms = new Vector<Term>(el.size());
      for(int i=0;i<el.size();i++) {
        terms.add(new Term(el.get(i)));
      }
    } else {
      terms = Collections.emptyList();
    }
    return terms;
View Full Code Here

    }
    return terms;
  }
 
  public Collection<Term> getSeesXMLTerms(GameState state, RoleInterface<Term> role) {
    ExpList el = null;
    synchronized (gameSim) {
      gameSim.SetGameState(state);
      Expression r = role.getTerm().getExpr();
      el = gameSim.getSeesXMLTerms(r);
    }
    Collection<Term> terms;
    if (el != null) {
      terms = new Vector<Term>(el.size());
      for(int i=0;i<el.size();i++) {
        terms.add(new Term(el.get(i)));
      }
    } else {
      terms = Collections.emptyList();
    }
    return terms;
View Full Code Here

    return terms;
  }
 
  public GameState getStateFromString(String state) throws InvalidKIFException {
    // get list of fluents
    ExpList el = ParserAdapter.parseExpressionList(state);
   
    // surround with (true ...)
    Expression[] exps = new Expression[el.size()];
    for (int i = 0; i < el.size(); i++) {
      Expression e = el.get(i);
      exps[i] = new Predicate("true", new Expression[] {e});
    }
    // add to theory and extract the GameState
    Theory t = new Theory(true, false);
    t.setState(new ExpList(exps));
    GameState gs = t.getState();
    return gs;
  }
View Full Code Here

public class ParserAdapter {

  public static Expression parseExpression(String kif) throws InvalidKIFException {
    try{
      ExpList list=Parser.parseDesc("(bla "+kif+")");
      if(list.size() == 1){
        ExpList list2=((Connective)list.get(0)).getOperands();
        if(list2.size() == 1) {
          return list2.get(0);
        }
      }
    }catch(Exception ex){
      throw new InvalidKIFException("Exception while parsing \""+kif+"\":"+ex.getMessage());
    }
View Full Code Here

    try{
      kif = kif.replace(")", ") ").trim();
      if(kif.charAt(0) != '(' || kif.charAt(kif.length()-1) != ')')
        throw new InvalidKIFException("not a valid kif list:"+kif);
      kif = "(bla " + kif.substring(1, kif.length()).trim();
      ExpList list=Parser.parseDesc(kif);
      if(list.size() != 1){
        throw new InvalidKIFException("Exception while parsing \""+kif+"\":...");
      }
      return ((Connective)list.get(0)).getOperands();
    }catch(Exception ex){
      throw new InvalidKIFException("Exception while parsing \""+kif+"\":"+ex.getMessage());
    }
  }
View Full Code Here

   * this calculates the sees terms to send to "player", given that the previous moves are "moves"
   * "moves" is useful because does(Player,Action) may appear in the "sees" relation's body
   *     (like the next relation)
   */
  public ExpList getSeesTerms(Expression player, ExpList moves) {
    ExpList el = null;
    theoryObj.add(moves);
    ExpList seesArgs = new ExpList();
    seesArgs.add(player);
    seesArgs.add(vX);
    try {
      el = theoryObj.finds(vX, new Predicate(aSees,seesArgs));
    } catch (InterruptedException e) {
      wasInterrupted = true;
    }
View Full Code Here

 
  /**
   * this calculates the sees terms to put in the XML file for the visualization
   */
  public ExpList getSeesXMLTerms(Expression player) {
    ExpList el = null;
    ExpList seesArgs = new ExpList();
    seesArgs.add(player);
    seesArgs.add(vX);
    try {
      el = theoryObj.finds(vX, new Predicate(aSeesXML,seesArgs));
    } catch (InterruptedException e) {
      wasInterrupted = true;
    }
View Full Code Here

    Iterator myIt = myLists.iterator();
    long curHash = 0;

    for (; myIt.hasNext();)
    {
      ExpList myList = (ExpList) myIt.next();
      curHash += myList.hashCode();
    }
//    System.err.print("Hash: " + curHash + "   ");
    return (int)curHash;
   
  }
View Full Code Here

TOP

Related Classes of cs227b.teamIago.resolver.ExpList

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.