jaige.statistics
Class SeasonStats

java.lang.Object
  extended by jaige.statistics.SeasonStats
All Implemented Interfaces:
GameListener, GameOverListener, MoveListener, NewGameListener, TurnListener

public class SeasonStats
extends java.lang.Object
implements MoveListener, TurnListener, NewGameListener, GameOverListener

This class keeps track of statistics throughout season The current stats it keeps track of the following for each match:
winner
total moves
total time
Once completed, we can calculate many other statistics based on the data stored here. wins/losses for each player wins/losses for each matchup average moves per win / loss (winner gets odd number) average move time quickest / longest win

Copyright: Copyright (c) Jaige 2007

Version:
1.0
Author:
Rob Taft

Constructor Summary
SeasonStats()
           
 
Method Summary
 java.util.ArrayList<Match> getAllMatches()
          Returns a copy of the list of matches.
 int[][] getLongestWin(java.util.List<? extends AI> ais)
          Returns the most number of turns per win for each matchup.
 int[][] getMatchupStandings(java.util.List<? extends AI> ais)
          The total wins against each player.
 int[][] getQuickestWin(java.util.List<? extends AI> ais)
          Returns the least number of turns per win for each matchup.
 int[][] getStandings(java.util.List<? extends AI> ais)
          Returns the total games and total wins per player.
 int[][] getTotalMoves(java.util.List<? extends AI> ais)
          Returns the total moves per win, loss, and overall.
 int[][] getTotalMoveTime(java.util.List<? extends AI> ais)
          Gets the total turn time for each win, loss, and game per player.
 boolean isPlaying()
          Check this to see if any stats are being gathered.
 void processGameOverEvent(GameOverEvent event)
           
 void processMoveEvent(MoveEvent event)
          Keeps track of the total move time and the move count.
 void processNewGameEvent(NewGameEvent event)
          Prepairs the new match for data collection.
 void processTurnEvent(TurnEvent event)
          Keeps track of the turn as well as the move time.
 void reset()
          Removes all match data stored in this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeasonStats

public SeasonStats()
Method Detail

reset

public void reset()
Removes all match data stored in this class.


processMoveEvent

public void processMoveEvent(MoveEvent event)
Keeps track of the total move time and the move count.

Specified by:
processMoveEvent in interface MoveListener
Parameters:
event - MoveEvent

processNewGameEvent

public void processNewGameEvent(NewGameEvent event)
Prepairs the new match for data collection.

Specified by:
processNewGameEvent in interface NewGameListener
Parameters:
event - NewGameEvent

processTurnEvent

public void processTurnEvent(TurnEvent event)
Keeps track of the turn as well as the move time.

Specified by:
processTurnEvent in interface TurnListener
Parameters:
event - TurnEvent

isPlaying

public boolean isPlaying()
Check this to see if any stats are being gathered. It is recommended that this be called before getting any statistics to make sure all processing has completed.

Returns:
boolean True if a game is still in progress.

processGameOverEvent

public void processGameOverEvent(GameOverEvent event)
Specified by:
processGameOverEvent in interface GameOverListener

getStandings

public int[][] getStandings(java.util.List<? extends AI> ais)
Returns the total games and total wins per player. The order is based on the order of the list passed into this method. The first column is the total games, the second is the total wins. Losses can be calculated from this externally.

Parameters:
ais - List of players.
Returns:
int[][] The total games and wins for each player. [Players][0=total, 1=wins]

getMatchupStandings

public int[][] getMatchupStandings(java.util.List<? extends AI> ais)
The total wins against each player. The column and row order are both in order of the players in the list passed in. The diagonal contains 0's since the season does not let a player play itself.

Parameters:
ais - List of players
Returns:
int[][] Win record of each player vs player matchup. [Winner][Loser]=win count.

getTotalMoves

public int[][] getTotalMoves(java.util.List<? extends AI> ais)
Returns the total moves per win, loss, and overall.

Parameters:
ais - List of players
Returns:
int[][] Total number of moves for each player [Player][0=win moves, 1=loss moves, 2=total moves]

getTotalMoveTime

public int[][] getTotalMoveTime(java.util.List<? extends AI> ais)
Gets the total turn time for each win, loss, and game per player.

Parameters:
ais - List of players
Returns:
int[][] Total turn time in milliseconds. [Players][0=win turn time, 1=loss turn time; 2=total turn time]

getQuickestWin

public int[][] getQuickestWin(java.util.List<? extends AI> ais)
Returns the least number of turns per win for each matchup.

Parameters:
ais - List of players
Returns:
int[][] Least number of turns per matchup. [Winner][Loser]=lowest number of turns for the winner to win.

getLongestWin

public int[][] getLongestWin(java.util.List<? extends AI> ais)
Returns the most number of turns per win for each matchup.

Parameters:
ais - List of players
Returns:
int[][] Most number of turns per matchup. [Winner][Loser]=highest number of turns for the winner to win.

getAllMatches

public java.util.ArrayList<Match> getAllMatches()
Returns a copy of the list of matches. If the stats are reset, this copy returned will still exist.

Returns:
ArrayList