mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-19 20:22:18 +01:00
Moved DroidFish project to trunk/
This commit is contained in:
70
DroidFish/src/org/petero/droidfish/gamelogic/Move.java
Normal file
70
DroidFish/src/org/petero/droidfish/gamelogic/Move.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
DroidFish - An Android chess program.
|
||||
Copyright (C) 2011 Peter Österlund, peterosterlund2@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.gamelogic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author petero
|
||||
*/
|
||||
public class Move {
|
||||
/** From square, 0-63. */
|
||||
public int from;
|
||||
|
||||
/** To square, 0-63. */
|
||||
public int to;
|
||||
|
||||
/** Promotion piece. */
|
||||
public int promoteTo;
|
||||
|
||||
/** Create a move object. */
|
||||
public Move(int from, int to, int promoteTo) {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.promoteTo = promoteTo;
|
||||
}
|
||||
|
||||
public Move(Move m) {
|
||||
this.from = m.from;
|
||||
this.to = m.to;
|
||||
this.promoteTo = m.promoteTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ((o == null) || (o.getClass() != this.getClass()))
|
||||
return false;
|
||||
Move other = (Move)o;
|
||||
if (from != other.from)
|
||||
return false;
|
||||
if (to != other.to)
|
||||
return false;
|
||||
if (promoteTo != other.promoteTo)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (from * 64 + to) * 16 + promoteTo;
|
||||
}
|
||||
|
||||
/** Useful for debugging. */
|
||||
public final String toString() {
|
||||
return TextIO.moveToUCIString(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user