Package de.axxeed.animosy.model

Examples of de.axxeed.animosy.model.Node


        if(game.getCurrentMove() != moveNo) {
          this.setPriority(6);
          log.info("Moving MrX in separate thread (move #"+game.getCurrentMove()+")...");
          moveNo = game.getCurrentMove();
         
          Node mrXMove = moveMrX();
          int type = game.getBoard().getMrX().changePosition(mrXMove);
          Manager.getGame().getTracker().nextMove(type);
          log.debug("MrX move done...");
          this.setPriority(Thread.NORM_PRIORITY);
          Manager.getGame().nextDetective();
View Full Code Here


  }
 
  private Node moveMrX() {
    long ts = System.currentTimeMillis();

    Node n = myMrX.getMove();
    /*
    Node n = null;
    if(Manager.getOptions().getMrXAlgorithm()==MRX_INTELLIGENT) {
      log.debug("MrX intelligent move");
      VirtualBoard vb = new VirtualBoard(Manager.getGame().getBoard());
      n = BoardModel.getNode(vb.moveMrX().getNode());
    }
    if(Manager.getOptions().getMrXAlgorithm()==MRX_MAXDIST) {
      log.debug("MrX maxdist move");
      n = maxDistMove();
    }
    else {
      log.debug("MrX random move");
      n = randomMove();
    }
    */
    log.info("Moving MrX");
    log.debug("to "+n.getPosition()+" in "+(System.currentTimeMillis()-ts)+"ms");
    return n;
  }
View Full Code Here

    /**This method makes a move for MrX with the maximum distance to the nearest detective
     * @return a random legal Node position for the MrX
   * @see de.axxeed.animosy.ai.MrXInterface#getMove()
     */
  public Node getMove() {
    Node n=Manager.getGame().getBoard().getMrX().getPosition();
    Link[] lk=n.getLinks();
    int noOfNodes=lk.length;
    int[] minDist = new int[noOfNodes];
    int[] sumDist = new int[noOfNodes];
    int minMinDist = 99;
    for(int i=0;i<noOfNodes;i++) {
View Full Code Here

  this.currentMoves=board.currentMoves;
        this.checkPoints=board.checkPoints;
        detectives=new Detective[board.detectives.length];
        for(int i=0;i<detectives.length;i++)
      {
    Node n=board.detectives[i].getPosition();
    if(n==null) {
      log.warn("No position node found for detective "+i);
    }
    detectives[i]=new Detective(n);
      }
        Node n=board.MrX.getPosition();
        MrX=new Fugitive(n);
    }
View Full Code Here

        int weight=INF;
        {
            Link []lk=x.getLinks();
            for(int i=0;i<lk.length;i++)
    {
        Node n=lk[i].getToNode();
        if(n.equals(y)) weight=lk[i].getType();
    }
        }
        return weight;
    }
View Full Code Here

    private boolean isLegalMove(Node to)
    {
        boolean canMove=true;
        for(int i=0;i<detectives.length;i++)
      {
    Node n=detectives[i].getPosition();
    if(n.getPosition()==to.getPosition()) canMove=false;
      }
        return canMove;
    }
View Full Code Here

    {
  Link []xLinks=MrX.getPosition().getLinks();
  boolean isBlocked=true;
  for(int i=0;i<xLinks.length;i++)
      {
    Node xNode=xLinks[i].getToNode();
    boolean thisIsOccupied=false;
    for(int j=0;j<Manager.getOptions().getNumberOfDetectives();j++)
        {
      Node dNode=detectives[j].getPosition();
      if(dNode.equals(xNode)) thisIsOccupied=true;
        }
    if(!thisIsOccupied) isBlocked=false;
      }
  boolean isCaptured=false;
  for(int i=0;i<Manager.getOptions().getNumberOfDetectives();i++)
      {
    Node detNode=detectives[i].getPosition();
    if(detNode.equals(MrX.getPosition())) isCaptured=true;
      }
  return(isBlocked||isCaptured);
    }
View Full Code Here

     * It returns the best possible move by calling the evaluate() method
     * @return the best node posiion of  MrX
     */
    private Node bestMove()
    {
  Node n=MrX.getPosition();
  Link[] lk=n.getLinks();
  int score[]=new int[20];  
  Node possibleNodes[]=new Node[20];
  int legalMoves=0;
  int noOfNodes=lk.length;
  for(int i=0;i<lk.length;i++)
      {
    if(isLegalMove(lk[i].getToNode()))
        {
      VirtualBoard board=new VirtualBoard(this);
      board.MrX.change(lk[i].getToNode());
      possibleNodes[legalMoves]=lk[i].getToNode();
      score[legalMoves]=evaluateMove(board,false,0);
      legalMoves++;
        }
      }
  Node toNode=possibleNodes[0];
  int max=score[0];
  for(int i=0;i<legalMoves;i++)
      {
    if(max<score[i])
        {
View Full Code Here

    private int evaluateMove(VirtualBoard b,boolean isMachineMove,int depth)
    {
        VirtualBoard board=new VirtualBoard(b);
        if(isMachineMove)
      {
    Node dPos=board.MrX.getPosition();
    Link []lk=dPos.getLinks();
    int score[]=new int[lk.length];
    int legalMoves=0;
    for(int i=0;i<lk.length;i++)
        {
      Node newPos=lk[i].getToNode();
      if (!board.isLegalMove(newPos)) continue;
      board.MrX.change(newPos);
      if(board.isUserWin()) score[legalMoves]=LOSE;
      else if(board.isUserWin()) score[legalMoves]=WIN;
      else if(depth==DEPTH) score[legalMoves]=scoreBoard(board);
View Full Code Here

     *@return all possible board positions in a TreeSet
     */
    private TreeSet generateUserMoves(VirtualBoard b) {
     TreeSet possibleMoves=new TreeSet();
     int nrOfDetectives = Manager.getOptions().getNumberOfDetectives();
    Node n[]=new Node[nrOfDetectives];
    Node detNode[]=new Node[nrOfDetectives];
    for(int i=0;i<nrOfDetectives;i++)
        detNode[i]=b.detectives[i].getPosition();

    for(int detLnk=0;detLnk<detNode[0].getLinks().length;detLnk++) {
      VirtualBoard board=new VirtualBoard(b);
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.