Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CheckersAI/src/Move4.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (42 sloc)
1.09 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Move4 implements Move{ | |
int[] _path; | |
Piece _piece; | |
public int source(){ return 0;} | |
public int destination(){ return 0;} | |
public Move4(Piece p, int[] path){ | |
_piece = p; | |
_path = path; | |
} | |
public Move4(Piece p, int dest){ | |
_piece = p; | |
//_path = new int[4]; | |
if(dest == 0) { | |
_path = new int[] {p._row, p._col, p._row + 1, p._col-1}; | |
} | |
else if(dest == 1) { | |
_path = new int[] {p._row, p._col, p._row + 1, p._col+1}; | |
} | |
else if(dest == 2) { | |
_path = new int[] {p._row, p._col, p._row - 1, p._col-1}; | |
} | |
else if(dest == 3) { | |
_path = new int[] {p._row, p._col, p._row - 1, p._col+1}; | |
} | |
else System.out.println("Problem in Move constructor"); | |
} | |
// Returns a list of captured positions | |
public int[] captures(){ | |
return new int[2]; | |
} | |
public Piece[] capturedPieces(){ | |
return null; | |
} | |
// Returns the string representation of a move | |
public String toString(){ | |
String output = ""; | |
for(int i = 0; i<_path.length; i++) { | |
output += "(" + _path[i] + ":" + _path[++i] + ")"; | |
} | |
return output; | |
} | |
} |