package cs6601.p1.generator;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import cs6601.p1.GameBoard;
import cs6601.p1.GameConfig;
import cs6601.p1.GameState;
import cs6601.p1.generator.MoveGenerator;
import cs6601.p1.generator.RandomMoveGenerator;

public class RandomTest {
	
	@Test
	public void testGenmove() {
		MoveGenerator moveGenerator = new RandomMoveGenerator();
		GameState gameState = new GameState(5);
		moveGenerator.genMove(new GameConfig(), gameState, "b");
		gameState = new GameState(5);
		moveGenerator.genMove(new GameConfig(), gameState, "w");
		
		assertEquals(MoveGenerator.PASS,moveGenerator.genMove(new GameConfig(), gameState, "?"));
		
		System.out.println(gameState);
	}
	
	@Test
	public void testAlternativeToIllegalMove() {
		GameState gameState = new GameState(4);
		gameState.playStone('A', 1, GameBoard.BLACK_STONE);
		gameState.playStone('A', 2, GameBoard.BLACK_STONE);
		gameState.playStone('A', 3, GameBoard.BLACK_STONE);
		gameState.playStone('A', 4, GameBoard.BLACK_STONE);
		gameState.playStone('B', 1, GameBoard.BLACK_STONE);
		gameState.playStone('B', 2, GameBoard.BLACK_STONE);
		//gameState.playStone('B', 3, GameBoard.BLACK_STONE);
		gameState.playStone('B', 4, GameBoard.BLACK_STONE);
		gameState.playStone('C', 2, GameBoard.BLACK_STONE);
		gameState.playStone('C', 3, GameBoard.BLACK_STONE);
		gameState.playStone('C', 4, GameBoard.BLACK_STONE);
		gameState.playStone('D', 4, GameBoard.BLACK_STONE);
		assertTrue(gameState.playStone('C', 1, GameBoard.WHITE_STONE));
		assertTrue(gameState.playStone('D', 2, GameBoard.WHITE_STONE));
		assertTrue(gameState.playStone('D', 3, GameBoard.WHITE_STONE));
		System.out.println(gameState);
		//This is correct - checked vs. MFOG
		assertEquals("B3", new RandomMoveGenerator().genMove(new GameConfig(), gameState, "w"));
		System.out.println(gameState);
	}
}
