public ZobristHashField(Field field, int? seed = null, RandomGenerateMethod randomGenerateMethod = RandomGenerateMethod.Standart) { Field = field; Seed = seed; RandomGenerateMethod = randomGenerateMethod; CaptureCountOffset_ = field.RealDotsCount * 2; HashTable_ = new ulong[CaptureCountOffset_ + Field.RealWidth * 2]; Key ^= HashTable_[CaptureCountOffset_ + Field.Player0CaptureCount % Field.RealWidth]; Key ^= HashTable_[CaptureCountOffset_ + Field.RealWidth + Field.Player1CaptureCount % Field.RealWidth]; FillWithRandomValues(); Key = 0; }
public AlphaBetaAlgoritm(Field field, MoveGenerator moveGenerator = null, Estimator estimator = null) { Field = field; MoveGenerator = moveGenerator ?? new StandartMoveGenerator(field); Estimator = estimator ?? new Estimator(field); }
public Field Clone() { var result = new Field(); result._tempList = new List<int>(_tempList); result._chainPositions = new List<short>(_chainPositions); result._surroundPositions = new List<short>(_surroundPositions); result._emptyBaseCreated = _emptyBaseCreated; result.Player0CaptureCount = Player0CaptureCount; result.Player1CaptureCount = Player1CaptureCount; result.OldPlayer0CaptureCount = OldPlayer0CaptureCount; result.OldPlayer1CaptureCount = OldPlayer1CaptureCount; result.Player0Square = Player0Square; result.Player1Square = Player1Square; result.CurrentPlayer = CurrentPlayer; result.LastPosition = LastPosition; //result.LastBaseCaptureCount_ = LastBaseCaptureCount_; //result.LastBaseFreedCount_ = LastBaseFreedCount_; result.LastMoveCaptureCount = LastMoveCaptureCount; result.LastMoveFreedCount = LastMoveFreedCount; //result.LastSquareCaptureCount_ = LastSquareCaptureCount_; //result.LastSquareFreedCount_ = LastSquareFreedCount_; result.LastState = LastState.Clone(); result.LastMoveState = LastMoveState; result._chainDotsPositions = new List<DotPosition>(_chainDotsPositions); result._surroundDotsPositions = new List<DotPosition>(_surroundDotsPositions); result._dots = (DotState[])_dots.Clone(); var newDotsSequanceStates = new List<State>(_dotsSequenceStates.Capacity); _dotsSequenceStates.ForEach(state => newDotsSequanceStates.Add(state.Clone())); result._dotsSequenceStates = newDotsSequanceStates; result._inputChainDots = new List<int>(InputSurroundDotsCount); result._inputSurroundedDots = new List<int>(InputSurroundDotsCount); result.Width = Width; result.Height = Height; result.SurroundCondition = SurroundCondition; result.DiagonalLinkedGroupsCount = DiagonalLinkedGroupsCount; return result; }
public void IsRedDotTest() { GameMove[] moves = TestUtils.LoadMovesFromPointsXt("DotFunctionsTest.sav"); Field field = new Field(39, 32); foreach (var move in moves) { field.MakeMove(move.Column, move.Row); if (field.DotsSequenceCount == 25) { int pos = Field.GetPosition(13, 13); Assert.IsTrue(field[pos].IsPlayer0Putted()); Assert.IsTrue(field[pos + 1].IsPlayer0Putted()); Assert.IsTrue(field[pos + 2].IsPlayer0Putted()); Assert.IsTrue(field[pos + 3].IsPlayer0Putted()); } else if (field.DotsSequenceCount == 58) { int pos = Field.GetPosition(13, 13); Assert.IsTrue(field[pos].IsPlayer1Putted()); Assert.IsTrue(field[pos + 1].IsPlayer1Putted()); Assert.IsTrue(field[pos + 2].IsPlayer1Putted()); Assert.IsTrue(field[pos + 3].IsPlayer1Putted()); Assert.IsTrue(field[Field.GetPosition(13 - 3, 13 - 1)].IsPlayer1Putted()); Assert.IsTrue(field[Field.GetPosition(13 + 5, 13)].IsPlayer1Putted()); Assert.IsFalse(field[pos].IsPlayer0Putted()); Assert.IsFalse(field[pos + 1].IsPlayer0Putted()); Assert.IsFalse(field[pos + 2].IsPlayer0Putted()); Assert.IsFalse(field[pos + 3].IsPlayer0Putted()); } } Assert.AreEqual(0, field.Player0CaptureCount); Assert.AreEqual(16, field.Player1CaptureCount); field.UnmakeAllMoves(); Assert.AreEqual(0, field.Player0CaptureCount); Assert.AreEqual(0, field.Player1CaptureCount); Assert.IsTrue(field.IsEmpty); }