Class BattleShip

java.lang.Object
  |
  +--BattleShip

public class BattleShip
extends java.lang.Object

BattleShip Simulator - allows players to test strategy and determine performanc level Quick Implementation Hints

You need to do five things:

1st. Create Your Own Player class based on the super class Parent Player
2rd. write method makeMove for accepting messages and dispatching your guesses
3nd. write a method placeShips - you need placeShips only for headToHead combat
4th create a main method and declare a BattleShip object - GoForIt has sample main
5th instantiate the object and call battleship method singleUserTestMode

for placing ships you need to place one ship at a time and use the class Ship method placeShips

for making guesses, write the method makeMove the brd passed is always your current guess board, use the Message method print() to get a feel of what message are being passed to you, you may also want to use the method print in Board to see how you guess board is updated.

You are allowed to enter three players, but each player must be significantly different. Your first player should be very primitive. For example, i.e., just guess 0,0 0,1, 0,2. On you can use inheritance, of a previous player when creating a new player.

After writing your own Player subclass, look at goForIt.java.

Message Methods You may want to use.

Methods:

checkAuthenication( this )  to verify message verificaion
integer constants IDPlaceShips, ...
boolean check isPlaceShips, ...
Object getClassPointer
int getDetails

in makeMove to place ships one would use... i.e., if( msg.isPlaceShips( ) ) placeShips( msg.getClassPointer() );

Note placeShips and all methods except makeMove should be private,

Note this is a message passing system with authenication, alternaive to this is to have a parent abstract class with all abstract methods defined, no messages are created but rather specific class methods are called, for authenication, constructor is passed an authenication methods General Operations Start up thread for each user call user 1 to placeShips copy board to secure location call user 1 to makeMove pass user board with hits and misses checks for Victory


Constructor Summary
BattleShip()
           
 
Method Summary
 void headToHead(BattleShip.PlayerType[] P, boolean fDetails)
           
 void headToHead(Player p1, Player p2)
           
 void headToHead(Player p1, Player p2, boolean fDetails, int nGames)
           
 void headToHead(Player p1, Player p2, int nGames)
           
static void main(java.lang.String[] args)
           
 void multiUserTestMode(Player[] pList, int MAXGAMES, boolean fDetails, Player pShip)
          Creates same board and tests to see how long it takes each player to finish board
 void mutliUserTestMode(Player[] pList)
           
 void print()
          Print VitalStatistics off current active player list
 void singleUserTestMode(Player p)
           
 void singleUserTestMode(Player p, boolean fDetails)
           
 void singleUserTestMode(Player p, int numGames)
           
 void singleUserTestMode(Player p, int numGames, boolean fDetails)
           
 void singleUserTestMode(Player p, int MAXGAMES, boolean fDetails, Player p1)
           
 void tournamentMode()
          Call tournamentMode with current activePlayer list, fInteractive set to false and number of Games 500
 void tournamentMode(int numGames)
          Calls tournamentMode current activePlayer list, fInteractive set to false
 void tournamentMode(Player[] pList)
          Call tournamentMode with fInteractive set to false and number of Games 500
 void tournamentMode(Player[] p, boolean fInteractive, int numGames)
          Initial Tournament mode consists of Two Rounds: Round 1 SingleUserTestMode: Rankings for best Performance (Weighted x 2), most efficient time, fewest move victory Rount 2 headToHead combat: Rankings for most series victories, and most overall victories Final Tournament mode may consists of 5 rounds, each round can have multiple rankings points are assigned for place in each ranking: 1st place gets 5pts, 2nd 4, 3rd 3.., 5th 1Pth
Round one headToHead, rankings: most victories, most series victories
Round two singleUserTestMode, rankings: lowest moves to solve a board, best performance ranking, most efficient - best time
Round three headToHead, rankings: most victories, winner of most series
Rount four multiUserTestMode, users are rank 1 to 5 on each game series, points for best overall
Rount five headToHead, finals
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BattleShip

public BattleShip()
Method Detail

singleUserTestMode

public void singleUserTestMode(Player p)
Parameters:
Player - p plays 500 games with PlayerTMD0 placing ships, will produce an Officical Performance Ranking

singleUserTestMode

public void singleUserTestMode(Player p,
                               int numGames)
Parameters:
Player - p plays numGames PlayerTMD0 is placing ships

singleUserTestMode

public void singleUserTestMode(Player p,
                               boolean fDetails)

singleUserTestMode

public void singleUserTestMode(Player p,
                               int numGames,
                               boolean fDetails)

singleUserTestMode

public void singleUserTestMode(Player p,
                               int MAXGAMES,
                               boolean fDetails,
                               Player p1)
Parameters:
p - is player to benchmark, MAXGAMES is number of games to use in benchmark default 500
fDetails - is set to true to print out details after each game default false
p1 - is player that places ships, default & for Official performance ranking player must be PlayerTMD0

mutliUserTestMode

public void mutliUserTestMode(Player[] pList)

multiUserTestMode

public void multiUserTestMode(Player[] pList,
                              int MAXGAMES,
                              boolean fDetails,
                              Player pShip)
Creates same board and tests to see how long it takes each player to finish board
Parameters:
pList - is list of players, MAXGAMES is number of games default 5
fDetails - if true print game stat details default false
pShip - is player that places ships, default PlayerTMD0

headToHead

public void headToHead(Player p1,
                       Player p2)
Parameters:
plays - player p1 against player p2 in a 500 games series with fDetails set to false

headToHead

public void headToHead(Player p1,
                       Player p2,
                       int nGames)

headToHead

public void headToHead(Player p1,
                       Player p2,
                       boolean fDetails,
                       int nGames)
Parameters:
Players - player p1 against player p2 in a 500 game series
fDetails - if set true prints out stats after each game

headToHead

public void headToHead(BattleShip.PlayerType[] P,
                       boolean fDetails)

print

public void print()
Print VitalStatistics off current active player list

tournamentMode

public void tournamentMode(Player[] pList)
Call tournamentMode with fInteractive set to false and number of Games 500
Parameters:
pList - is list of players

tournamentMode

public void tournamentMode()
Call tournamentMode with current activePlayer list, fInteractive set to false and number of Games 500

tournamentMode

public void tournamentMode(int numGames)
Calls tournamentMode current activePlayer list, fInteractive set to false
Parameters:
numGames - number of games to use in simulation

tournamentMode

public void tournamentMode(Player[] p,
                           boolean fInteractive,
                           int numGames)
Initial Tournament mode consists of Two Rounds: Round 1 SingleUserTestMode: Rankings for best Performance (Weighted x 2), most efficient time, fewest move victory Rount 2 headToHead combat: Rankings for most series victories, and most overall victories Final Tournament mode may consists of 5 rounds, each round can have multiple rankings points are assigned for place in each ranking: 1st place gets 5pts, 2nd 4, 3rd 3.., 5th 1Pth
Round one headToHead, rankings: most victories, most series victories
Round two singleUserTestMode, rankings: lowest moves to solve a board, best performance ranking, most efficient - best time
Round three headToHead, rankings: most victories, winner of most series
Rount four multiUserTestMode, users are rank 1 to 5 on each game series, points for best overall
Rount five headToHead, finals

Parameters:
takes - a list of player p, each player plays a 500 game singleUserTestMode,

main

public static void main(java.lang.String[] args)