cs1705.tetris
Class Move

java.lang.Object
  extended bycs1705.tetris.Move

public class Move
extends Object

This class represents a single move made by or considered by a Tetris "Brain" class. A move can have a "score" associated with it. This score can be used by a Brain class to reflect the relative value of this move in comparison with alternatives, where higher scores are associated with less valuable moves (think "higher score" means "higher buildup of bricks").

Version:
2003.10.13
Author:
Stephen Edwards

Constructor Summary
Move()
          Create a new Move object with zero/null fields.
Move(int x, int y, Piece piece, double score)
          Create a new Move object.
 
Method Summary
 boolean equals(Object other)
          Check whether two moves are the same.
 Piece piece()
          Retrieve the piece associated with this move.
 double score()
          Retrieve the score associated with this move.
 void setPiece(Piece value)
          Change the piece associated with this move.
 void setScore(double value)
          Change the score associated with this move.
 void setX(int value)
          Change the x-coordinate of the location for this move's piece.
 void setY(int value)
          Change the y-coordinate of the location for this move's piece.
 String toString()
          Returns a human-readable string representation of this Move.
 int x()
          Retrieve the x-coordinate of the location for this move's piece.
 int y()
          Retrieve the y-coordinate of the location for this move's piece.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Move

public Move()
Create a new Move object with zero/null fields.


Move

public Move(int x,
            int y,
            Piece piece,
            double score)
Create a new Move object.

Parameters:
x - the x-coordinate to use
y - the y-coordinate to use
piece - the piece to use
score - the score to use
Method Detail

equals

public boolean equals(Object other)
Check whether two moves are the same.

Parameters:
other - the move to compare against
Returns:
true if this move is the same as the provided one

piece

public Piece piece()
Retrieve the piece associated with this move.


score

public double score()
Retrieve the score associated with this move. Higher scores are associated with "worse" moves that are more likely to weaken the player's current position. Lower scores are associated with the best moves.


setPiece

public void setPiece(Piece value)
Change the piece associated with this move.

Parameters:
value - the new piece to use

setScore

public void setScore(double value)
Change the score associated with this move.

Parameters:
value - the new score to use

setX

public void setX(int value)
Change the x-coordinate of the location for this move's piece.

Parameters:
value - the new x-coordinate to use

setY

public void setY(int value)
Change the y-coordinate of the location for this move's piece.

Parameters:
value - the new y-coordinate to use

toString

public String toString()
Returns a human-readable string representation of this Move. Note that this produces a multi-line representation.

Returns:
the printable representation of this move

x

public int x()
Retrieve the x-coordinate of the location for this move's piece.


y

public int y()
Retrieve the y-coordinate of the location for this move's piece.