void step() { // Debug.Log ("Step forward"); // Debug.Log ("Actual state: " + actualState); counter++; if (counter == 10) { throw new Exception("StackOverflow"); } ApplicableOperator chosenOperator = actualState.getRandomOperator(); if (chosenOperator == null) { stepBack(); } else { // Debug.Log ("Searching connection for [Room: " + randomOpenDoor.room.roomId + ", Door: (" + randomOpenDoor.door.doorId + ") " + randomOpenDoor.door.position + "]"); actualState = actualState.Apply(chosenOperator); mapStates.Add(actualState); if (IsWinningState()) { winningState = actualState; return; } GenerateApplicableOperators(); } step(); }
public void GetHashCode_Transforms_AreEqual() { var exp = 16778040; var state0 = new MapState(2); state0.Set(1, 2, 13); state0.Set(2, 1, 53); state0.NextStep(2); state0.NextStep(2); var act0 = state0.GetHashCode(); Assert.AreEqual(exp, act0, "hash act0"); var state1 = new MapState(2); state1.Set(1, 2, 13); state1.Set(2, 1, 53); state1.NextStep(2); state1.Set(2, 0, 2); state1.Set(2, 2, 2); state1.Apply(Move.CreateStack(PlayerType.player2, 2, 13), this.TestMap); state1.Set(2, 1, 53); state1.Set(1, 2, 10); state1.Apply(Move.CreateStack(PlayerType.player1, 1, 3), this.TestMap); state1.NextStep(2); var act1 = state1.GetHashCode(); #if DEBUG DebugRegions debug0 = state0.ToDebug(); DebugRegions debug1 = state1.ToDebug(); #endif Assert.AreEqual(state0.Owner(1), state1.Owner(1), "Owner[1]"); Assert.AreEqual(state0.Armies(1), state1.Armies(1), "Armies[1]"); Assert.AreEqual(state0.Owner(2), state1.Owner(2), "Owner[2]"); Assert.AreEqual(state0.Armies(2), state1.Armies(2), "Armies[2]"); //Assert.AreEqual(state0.PlayerToMove, state1.PlayerToMove, "PlayerToMove"); Assert.AreEqual(state0.SubRound, state1.SubRound, "SubRound"); Assert.AreEqual(exp, act1, "hash act1"); }
public void Apply_Select_AreEqual() { var mapstate = new MapState(1); mapstate.Set(1, (ushort)PlayerType.player1, 13); Assert.AreEqual(PlayerType.player1, mapstate.Owner(1), "Owner, Before"); Assert.AreEqual(13, mapstate.Armies(1), "Armies, Before"); mapstate.Apply(Move.CreateSelect(PlayerType.player1, 1), this.TestMap); Assert.AreEqual(PlayerType.player1, mapstate.Owner(1), "Owner, After"); Assert.AreEqual(2, mapstate.Armies(1), "Armies, After"); }
public void Apply_Transform7_AreEqual() { var mapstate = new MapState(2); mapstate.Set(1, (ushort)PlayerType.player1, 13); mapstate.Set(2, (ushort)PlayerType.player1, 03); Assert.AreEqual(PlayerType.player1, mapstate.Owner(1), "Owner[1], Before"); Assert.AreEqual(13, mapstate.Armies(1), "Armies[1], Before"); Assert.AreEqual(PlayerType.player1, mapstate.Owner(2), "Owner[2], Before"); Assert.AreEqual(3, mapstate.Armies(2), "Armies[2], Before"); mapstate.Apply(Move.CreateTransfer(PlayerType.player1, 1, 2, 7), this.TestMap); Assert.AreEqual(PlayerType.player1, mapstate.Owner(1), "Owner[2], After"); Assert.AreEqual(06, mapstate.Armies(1), "Armies[1], After"); Assert.AreEqual(PlayerType.player1, mapstate.Owner(2), "Owner[2], After"); Assert.AreEqual(10, mapstate.Armies(2), "Armies[2], After"); }
public void Apply_Attack10vs20_AreEqual() { var mapstate = new MapState(2); mapstate.Set(1, (ushort)PlayerType.player1, 11); mapstate.Set(2, (ushort)PlayerType.player2, 20); Assert.AreEqual(PlayerType.player1, mapstate.Owner(1), "Owner[1], Before"); Assert.AreEqual(11, mapstate.Armies(1), "Armies[1], Before"); Assert.AreEqual(PlayerType.player2, mapstate.Owner(2), "Owner[2], Before"); Assert.AreEqual(20, mapstate.Armies(2), "Armies[2], Before"); mapstate.Apply(Move.CreateTransfer(PlayerType.player1, 1, 2, 10), this.TestMap); Assert.AreEqual(PlayerType.player1, mapstate.Owner(1), "Owner[2], After"); Assert.AreEqual(1, mapstate.Armies(1), "Armies[1], After"); Assert.AreEqual(PlayerType.player2, mapstate.Owner(2), "Owner[2], After"); Assert.AreEqual(14, mapstate.Armies(2), "Armies[2], After"); }