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 NextStep_13Times_AreEqual() { var state = new MapState(1); var sb = new StringBuilder(); var round = 0; var sub = SubRoundType.PlaceArmies; for (int i = 0; i < 13; i++) { sb.AppendFormat("{0:00}.{1}.{2}.D{3:00}", state.Round, state.SubRound.ToString()[0], state.PlayerToMove, state.Depth); sb.AppendLine(); state.NextStep(2); if (round != state.Round) { sb.AppendLine("================"); } else if (sub != state.SubRound) { sb.AppendLine("----------------"); } round = state.Round; sub = state.SubRound; } var act = sb.ToString(); var exp = @"00.P.player1.D00 00.P.player2.D01 ================ 01.P.player1.D04 01.P.player2.D05 ---------------- 01.A.player1.D06 01.A.player2.D07 ================ 02.P.player1.D08 02.P.player2.D09 ---------------- 02.A.player1.D10 02.A.player2.D11 ================ 03.P.player1.D12 03.P.player2.D13 ---------------- 03.A.player1.D14 "; Console.WriteLine(act); Console.WriteLine(exp); Assert.AreEqual(exp, act); }