import java.util.*;
/**
 * A slightly more interesting use of he clobberboard class
 * This actually plays an entire game with alternate moves
 * Each player's moves are randomly selected from
 * among its legal moves
 * @author gtowell
 *
 */
public class Clobber2
{

	public static void main ( String[] args )
	{
		ClobberBoard cb=new ClobberBoard(args[0]);
		System.out.println(cb);
		char[] wb = {'w', 'b'};
		boolean keepGoing=true;
		Random r = new Random();
		while (keepGoing)
		{
			for (int i=0; i<wb.length && keepGoing; i++)
			{
				ArrayList<Amove> am = cb.legalMoves(wb[i]);
				if (am.size()==0)
				{
					keepGoing=false;
					System.out.println(wb[i] + " lost");
					System.out.println(cb);
				}
				else
				{
					Amove aa = am.get(r.nextInt(am.size()));
					cb.makeMove(aa);
					System.out.println(wb[i] + "  " + aa);
				}
			}
		}
	}

}
