package net.woodyfolsom.msproj.policy;

import static org.junit.Assert.assertEquals;
import net.woodyfolsom.msproj.Action;
import net.woodyfolsom.msproj.GameConfig;
import net.woodyfolsom.msproj.GameState;
import net.woodyfolsom.msproj.Player;

import org.junit.Test;


public class RandomTest {
	
	@Test(expected = IllegalArgumentException.class)
	public void testGenmoveForNone() {
		Policy moveGenerator = new RandomMovePolicy();
		GameState gameState = new GameState(5);
		moveGenerator.getAction(new GameConfig(), gameState, Player.BLACK);
		gameState = new GameState(5);
		moveGenerator.getAction(new GameConfig(), gameState, Player.WHITE);
		
		assertEquals(Action.PASS, moveGenerator.getAction(new GameConfig(), gameState, Player.NONE));
	}
	
	@Test
	public void testAlternativeToIllegalMove() {
		GameState gameState = new GameState(4);
		gameState.playStone(Player.BLACK, Action.getInstance("A1"));
		gameState.playStone(Player.BLACK, Action.getInstance("A2"));
		gameState.playStone(Player.BLACK, Action.getInstance("A3"));
		gameState.playStone(Player.BLACK, Action.getInstance("A4"));
		gameState.playStone(Player.BLACK, Action.getInstance("B1"));;
		gameState.playStone(Player.BLACK, Action.getInstance("B2"));
		
		//gameState.playStone('B', 3, GameBoard.BLACK_STONE);
		
		gameState.playStone(Player.BLACK, Action.getInstance("B4"));
		
		gameState.playStone(Player.BLACK, Action.getInstance("C2"));
		gameState.playStone(Player.BLACK, Action.getInstance("C3"));
		gameState.playStone(Player.BLACK, Action.getInstance("C4"));
		
		gameState.playStone(Player.BLACK, Action.getInstance("D4"));
		
		gameState.playStone(Player.WHITE, Action.getInstance("C1"));
		gameState.playStone(Player.WHITE, Action.getInstance("D2"));
		gameState.playStone(Player.WHITE, Action.getInstance("D3"));
		
		System.out.println("State before random WHITE move selection:");
		System.out.println(gameState);
		//This is correct - checked vs. MFOG
		assertEquals(Action.getInstance("B3"), new RandomMovePolicy().getAction(new GameConfig(), gameState, Player.WHITE));
		
		System.out.println(gameState);
	}
}
