package net.woodyfolsom.msproj;

public class StateEvaluator {
	private final GameConfig gameConfig;
	
	public StateEvaluator(GameConfig gameConfig) {
		this.gameConfig = gameConfig;
	}
	
	public GameScore scoreGame(GameState gameState) {
		GameBoard gameBoard;
		if (gameState.getGameBoard().isTerritoryMarked()) {
			gameBoard = gameState.getGameBoard();
		} else {
			gameBoard = new GameBoard(gameState.getGameBoard());
			TerritoryMarker.markTerritory(gameBoard);
		}
		
		//TODO include komi from gameConfig
		return new GameScore(gameBoard.countSymbols(GameBoard.BLACK_STONE,GameBoard.BLACK_TERRITORY),
				gameBoard.countSymbols(GameBoard.WHITE_STONE,GameBoard.WHITE_TERRITORY),gameConfig.getKomi());
	}
}