Package de.axxeed.animosy.model

Examples of de.axxeed.animosy.model.Node


  return compare(this,b);
    }

    public Move moveMrX()
    {
  Node bestNode=bestMove();
  int type=MrX.changePosition(bestNode);
  int pos=MrX.getPosition().getPosition();
  currentMoves++;
  return (new Move(pos,type));
    }
View Full Code Here


    /**Checks if the detective can make a move or not
     * @return true if the detective can move,false if the detective is stranded
     */
    private boolean canMove(VirtualBoard board, int detNo)
    {
        Node n=board.getDetectives()[detNo].getPosition();
        // log.debug("Detective #"+detNo+", Node: "+n+" on board ("+board.hashCode()+")");
        Link []lk=n.getLinks();
        boolean canMove=false;
        for(int i=0;i<lk.length;i++)
        {
      boolean canGoToThisNode=true;
      Node toNode=lk[i].getToNode();
      Detective[] det=Manager.getGame().getBoard().getDetectives();
      for(int j=0;j<det.length;j++)
    if (toNode.equals(det[j].getPosition())) canGoToThisNode=false;

            int t=lk[i].getType();
            switch(t)
            {
                case TAXI:if(getDetectives()[detNo].getTaxiTickets()<=0) if(canGoToThisNode) canGoToThisNode=false;
View Full Code Here

     */
    private TreeSet getPossibleMoves(VirtualBoard board, int detNo)
    {
  if(!canMove(board, detNo)) return null;
  boolean added=false;
  Node n=board.getDetectives()[detNo].getPosition();
  Link []lk=n.getLinks();
      TreeSet possibleMoves=new TreeSet();
  for(int i=0;i<lk.length;i++)
  {
      boolean canGoToThisNode=true;
      Node toNode=lk[i].getToNode();
      Detective[] det=Manager.getGame().getBoard().getDetectives();
      for(int j=0;j<det.length;j++)
    if(toNode.equals(det[j].getPosition())) canGoToThisNode=false;

      int t=lk[i].getType();
        switch(t)
        {
            case  TAXI:if(getDetectives()[detNo].getTaxiTickets()<=0) if(canGoToThisNode) canGoToThisNode=false;
                       break;
            case   BUS:if(getDetectives()[detNo].getBusTickets()<=0) if(canGoToThisNode) canGoToThisNode=false;
                        break;
            case    UG:if(getDetectives()[detNo].getUndergroundTickets()<=0) if(canGoToThisNode) canGoToThisNode=false;
                  break;
            case BLACK:canGoToThisNode=false;
                  break;
        }
      if(canGoToThisNodepossibleMoves.add(new Move(toNode.getPosition(),t));
  }
  return possibleMoves;
    }
View Full Code Here

    /**This method makes a random move for the MrX
     * @return a random legal Node position for the MrX
   * @see de.axxeed.animosy.ai.MrXAbstract#getMove()
     */
  public Node getMove() {
    Node n=Manager.getGame().getBoard().getMrX().getPosition();
    Node toNode=n;
    Link[] lk=n.getLinks();
    // int noOfNodes=lk.length;
    boolean done=false;
    while(!done) {
      int rnd=(int)(lk.length*Math.random());
 
View Full Code Here

     */
    protected boolean isLegalMove(Node to)
    {
        boolean canMove=true;
        for(int i=0;i<Manager.getGame().getBoard().getDetectives().length;i++) {
      Node n=Manager.getGame().getBoard().getDetectives()[i].getPosition();
      if(n.getPosition()==to.getPosition()) {
        canMove=false;
      }
      }
        return canMove;
    }
View Full Code Here

TOP

Related Classes of de.axxeed.animosy.model.Node

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.