public void TestIsTigerGoalState() { State s = new State(); Board b = s.Board; Assert.IsNotNull(b); Assert.IsNotNull(b.GetSpace(2,2)); Assert.IsNotNull(s.GetSpaceState(2,2)); GoatPlacementMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat); TigerCaptureMove t1 = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger); TigerCaptureMove t2 = new TigerCaptureMove(b.GetSpace(2,2), b.GetSpace(0,4), b.GetSpace(1, 3), s.Tiger); Assert.IsFalse(s.IsTigerGoalState()); Assert.IsFalse(s.IsGoatGoalState()); g.ExecuteMove(s); t1.ExecuteMove(s); // 1 down g.ExecuteMove(s); t2.ExecuteMove(s); // 2 down g.ExecuteMove(s); t1.ExecuteMove(s); // 3 down g.ExecuteMove(s); t2.ExecuteMove(s); // 4 down g.ExecuteMove(s); t1.ExecuteMove(s); //5 down Assert.IsTrue(s.IsTigerGoalState()); Assert.IsFalse(s.IsGoatGoalState()); }
public void TestSlideMovesMove() { State s = new State(); Board b = s.Board; Assert.IsNotNull(b.GetSpace(1, 3)); Assert.IsNotNull(s.Tiger); AbstractMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat); g.ExecuteMove(s); AbstractMove ts = new SlideMove(b.GetSpace(4, 4), b.GetSpace(3, 3), s.Tiger); Assert.IsNotNull(ts.StartSpace); Assert.IsNotNull(ts.EndSpace); Assert.IsNotNull(ts.Player); ts.ExecuteMove(s); Assert.AreEqual(b.GetSpace(4, 4).GetSpaceState(), 'X'); Assert.AreEqual(b.GetSpace(3, 3).GetSpaceState(), 'T'); AbstractMove gs = new SlideMove(b.GetSpace(1, 3), b.GetSpace(1, 4), s.Goat); gs.ExecuteMove(s); Assert.AreEqual(b.GetSpace(1, 3).GetSpaceState(), 'X'); Assert.AreEqual(b.GetSpace(1, 4).GetSpaceState(), 'G'); Console.WriteLine("Tested placement 1,3, tiger slide 4,4 to 3,3 and goat slide 1,3 to 1,4 \r\n" + s.Board.GetBoardPic()); }
public void TestGoatPlacementMove() { State s = new State(); Board b = s.Board; Assert.IsNotNull(b.GetSpace(1, 3)); Assert.IsNotNull(s.Goat); AbstractMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat); Assert.IsNotNull(g.Player.Symbol); Assert.IsNotNull(g.EndSpace); g.ExecuteMove(s); Assert.AreEqual(b.GetSpace(1, 3).GetSpaceState(), 'G'); Assert.AreEqual(b.GetSpace(0, 4).GetSpaceState(), 'T'); Assert.AreEqual(s.Goat.GoatsInHand, 19); }
public void TestMoveList() { State s = new State(); Board b = s.Board; Assert.AreEqual(s.Goat.GetCountLegalMoves(s), 21); Assert.AreEqual(s.Tiger.GetCountLegalMoves(s), 12); GoatPlacementMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat); g.ExecuteMove(s); Assert.AreEqual(s.Goat.GetCountLegalMoves(s), 20); TigerCaptureMove t = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger); t.ExecuteMove(s); Assert.AreEqual(s.Goat.GetCountLegalMoves(s), 21); Assert.AreEqual(s.Tiger.GetCountLegalMoves(s), 17); }
public void TestCloneMove() { State s = new State(); Board b = s.Board; Assert.IsNotNull(b.GetSpace(1, 3)); Assert.IsNotNull(s.Tiger); GoatPlacementMove g1 = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat); GoatPlacementMove g2 = (GoatPlacementMove) g1.Clone(); Assert.AreNotEqual(g1, g2); Assert.AreEqual(g1.EndSpace, g2.EndSpace); TigerCaptureMove t1 = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger); Assert.IsNotNull(t1.StartSpace); TigerCaptureMove t2 = (TigerCaptureMove) t1.Clone(); Assert.AreNotEqual(t1, t2); Assert.AreEqual(t1.EndSpace, t2.EndSpace); SlideMove s1 = new SlideMove(b.GetSpace(4, 4), b.GetSpace(3, 3), s.Tiger); Assert.IsNotNull(s1.StartSpace); SlideMove s2 = (SlideMove) s1.Clone(); Assert.AreNotEqual(s1, s2); Assert.AreEqual(s1.EndSpace, s2.EndSpace); }
private AbstractMove getRandomFirstGoatMove(State s) { Random r = new Random(); int randInt = r.Next(4); BoardSpace b = null; switch (randInt) { case 0: b = new BoardSpace(0, 2); break; case 1: b = new BoardSpace(2, 0); break; case 2: b = new BoardSpace(2, 4); break; case 3: b = new BoardSpace(4, 2); break; } GoatPlacementMove m = new GoatPlacementMove(null, b, s.Goat); return m; }
public void TestTigerCaptureMove() { State s = new State(); Board b = s.Board; Assert.IsNotNull(b.GetSpace(1, 3)); Assert.IsNotNull(s.Tiger); AbstractMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat); g.ExecuteMove(s); TigerCaptureMove t = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger); Assert.IsNotNull(t.StartSpace); Assert.IsNotNull(t.EndSpace); Assert.IsNotNull(t.JumpSpace); Assert.IsNotNull(t.Player); t.ExecuteMove(s); Assert.AreEqual(b.GetSpace(0, 4).GetSpaceState(), 'X'); Assert.AreEqual(b.GetSpace(2, 2).GetSpaceState(), 'T'); Assert.AreEqual(b.GetSpace(1, 2).GetSpaceState(), 'X'); Assert.AreEqual(s.Goat.GoatsKilled, 1); Console.WriteLine("Tested placement 1,3 and capture from 0,4 to 2,2 \r\n" + s.Board.GetBoardPic()); }