Class NaiveCPUPlayer

java.lang.Object
  extended by NaiveCPUPlayer
All Implemented Interfaces:
Player

public class NaiveCPUPlayer
extends java.lang.Object
implements Player

NaiveCPUPlayer is a computer-controlled Player that uses the simplest possible strategy: at each turn, it suggests a randomly-selected BoardPoint to attack.


Constructor Summary
NaiveCPUPlayer()
           
 
Method Summary
 BoardPoint getNextMove()
           Gets the next move this Player wants to execute.
 boolean isHuman()
           Returns true if this Player is human.
 Ship placeOneShip()
          This method will randomly place one ship.
 void setBoard(Grid grid)
           Sets the board for this Player to the given Grid.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NaiveCPUPlayer

public NaiveCPUPlayer()
Method Detail

placeOneShip

public Ship placeOneShip()
This method will randomly place one ship. NaiveCPUPlayer only knows how many ships of each type a player has; this ship placement may or may not be legal given the current state of the Grid.

Specified by:
placeOneShip in interface Player
Returns:
a Ship object

getNextMove

public BoardPoint getNextMove()
Description copied from interface: Player
Gets the next move this Player wants to execute. This move may not be legal, if the BoardPoint in question has already been struck. It is the responsibility of the NavalVesselGame class to check move legality, though.)

Specified by:
getNextMove in interface Player
Returns:
the BoardPoint of the Player's desired move.

isHuman

public boolean isHuman()
Description copied from interface: Player
Returns true if this Player is human.

Specified by:
isHuman in interface Player
Returns:
false

setBoard

public void setBoard(Grid grid)
Description copied from interface: Player
Sets the board for this Player to the given Grid.

Specified by:
setBoard in interface Player
Parameters:
grid - this Player's board.