Android Open Source - iSlide Move






From Project

Back to project page iSlide.

License

The source code is released under:

MIT License

If you think the Android project iSlide listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.csun.group2.islide.engine;
//w  w w .  j a  v  a  2 s  . c  o m
public class Move extends Board implements Comparable<Move>{

  int h;//! the Manhattan distance heuristic
  int g;//! how many moves have gone before
  
  Move parent;
  
  public Move(Board _parent) {
    super(_parent);
    parent = null;
    eval();
    g= 0;
  }
  
  public Move(Move other) {
    super(other);
    parent = other.parent;
    h = other.h;
    g = other.g;
    
  }
  
  public Move(Move other, boolean deep_copy) {
    super(other);
    if(deep_copy)
      parent = other.parent;
    else
      parent = other;
    h = other.h;
    g = other.g;    
  }
  
  @Override
  public boolean move(int index)
  {
    if( super.move(index))
    {
      ++g;
      eval();
      return true;
    }
    return false;    
  }

  
  /**
   *  /brief Evaluates the heuristic value of the configuration of board
   * 
   */
  void eval(){
    h = 0;
    int num;
    for(int i = 0; i < board_size; ++i)
    {
      num = Math.abs(ary.get(i) - i);
      h += (num/width) + (num%width);
    }
  }

  @Override
  public int compareTo(Move y) {
    if ((h + g) < (y.h + y.g))
     {
         return -1;
     }
     if ((h + g) > (y.h + y.g))
     {
         return 1;
     }
     return 0;
  }
  
  public int hashCode()
  {
    return super.hashCode();
  }
    
}




Java Source Code List

edu.csun.group2.islide.CameraPreview.java
edu.csun.group2.islide.HighScore.java
edu.csun.group2.islide.MainActivity.java
edu.csun.group2.islide.MainMenuActivity.java
edu.csun.group2.islide.PhotoHandler.java
edu.csun.group2.islide.PlayMenu.java
edu.csun.group2.islide.SelectImageActivity.java
edu.csun.group2.islide.SettingsMenu.java
edu.csun.group2.islide.TakePictureActivity.java
edu.csun.group2.islide.UtilityInfo.java
edu.csun.group2.islide.Utility.java
edu.csun.group2.islide.engine.BoardTest.java
edu.csun.group2.islide.engine.Board.java
edu.csun.group2.islide.engine.GameBoardTest.java
edu.csun.group2.islide.engine.GameBoard.java
edu.csun.group2.islide.engine.GameManager.java
edu.csun.group2.islide.engine.InputHandler.java
edu.csun.group2.islide.engine.MoveComparator.java
edu.csun.group2.islide.engine.MoveTest.java
edu.csun.group2.islide.engine.Move.java
edu.csun.group2.islide.engine.Pair.java
edu.csun.group2.islide.engine.entity.SlideTile.java
edu.csun.group2.islide.engine.entity.TileManager.java
edu.csun.group2.islide.global.GameInfo.java
edu.csun.group2.islide.interfaces.IRenderable.java
edu.csun.group2.islide.iSlide.java