当前位置: 首页>>代码示例>>C#>>正文


C# Field.MakeMove方法代码示例

本文整理汇总了C#中Field.MakeMove方法的典型用法代码示例。如果您正苦于以下问题:C# Field.MakeMove方法的具体用法?C# Field.MakeMove怎么用?C# Field.MakeMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Field的用法示例。


在下文中一共展示了Field.MakeMove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeRandomMove

 public void MakeRandomMove(Field field)
 {
     int x = 0;
     int y = 0;
     while (true)
     {
         x = _random.Next(field.Width) + 1;
         y = _random.Next(field.Height) + 1;
         if (field[Field.GetPosition(x, y)].IsPuttingAllowed())
             break;
     }
     field.MakeMove(x, y);
 }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:13,代码来源:UctMoveGenerator.cs

示例2: PutBigBase

        private void PutBigBase(Field field, ZobristHashField hash)
        {
            int startX = 5;
            int startY = 2;

            // top.
            field.MakeMove(startX, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 11, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 11, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX + 2, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 11, startY + 2);
            hash.UpdateHash();

            field.MakeMove(startX + 3, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 11, startY + 3);
            hash.UpdateHash();

            field.MakeMove(startX + 4, startY + 1);
            hash.UpdateHash();
            field.MakeMove(startX + 11, startY + 4);
            hash.UpdateHash();

            // right.
            field.MakeMove(startX + 5, startY + 2);
            hash.UpdateHash();
            field.MakeMove(startX + 12, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 5, startY + 3);
            hash.UpdateHash();
            field.MakeMove(startX + 12, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX + 5, startY + 4);
            hash.UpdateHash();
            field.MakeMove(startX + 12, startY + 2);
            hash.UpdateHash();

            field.MakeMove(startX + 4, startY + 5);
            hash.UpdateHash();
            field.MakeMove(startX + 12, startY + 3);
            hash.UpdateHash();

            // bottom
            field.MakeMove(startX + 3, startY + 6);
            hash.UpdateHash();
            field.MakeMove(startX + 13, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 2, startY + 6);
            hash.UpdateHash();
            field.MakeMove(startX + 13, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY + 6);
            hash.UpdateHash();
            field.MakeMove(startX + 13, startY + 2);
            hash.UpdateHash();

            field.MakeMove(startX, startY + 6);
            hash.UpdateHash();
            field.MakeMove(startX + 13, startY + 3);
            hash.UpdateHash();

            field.MakeMove(startX - 1, startY + 5);
            hash.UpdateHash();
            field.MakeMove(startX + 13, startY + 4);
            hash.UpdateHash();

            // left.
            field.MakeMove(startX - 2, startY + 4);
            hash.UpdateHash();
            field.MakeMove(startX + 14, startY);
            hash.UpdateHash();

            field.MakeMove(startX - 2, startY + 3);
            hash.UpdateHash();
            field.MakeMove(startX + 14, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX - 2, startY + 2);
            hash.UpdateHash();
            field.MakeMove(startX + 14, startY + 2);
            hash.UpdateHash();

            field.MakeMove(startX - 1, startY + 1);
            hash.UpdateHash();
            field.MakeMove(startX + 14, startY + 3);
            hash.UpdateHash();
        }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:99,代码来源:ZobristHashTest.cs

示例3: CalculateHash_VeryLongGame

        public void CalculateHash_VeryLongGame()
        {
            var field = new Field(39, 32);
            ZobristHashField hash = new ZobristHashField(field, 0);

            ulong initKey = hash.Key;

            GameMove[] moves = TestUtils.LoadMovesFromPointsXt("VeryLongGame.sav");

            foreach (var move in moves)
            {
                Assert.AreEqual(true, field.MakeMove(move.Column, move.Row));
                hash.UpdateHash();
            }

            while (field.States.Count() != 0)
            {
                field.UnmakeMove();
                hash.UpdateHash();
            }

            Assert.AreEqual(initKey, hash.Key);
        }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:23,代码来源:ZobristHashTest.cs

示例4: CalculateHash_SimpleSequence

        public void CalculateHash_SimpleSequence()
        {
            int startX = 16;
            int startY = 16;

            var field = new Field(39, 32);
            ZobristHashField hash = new ZobristHashField(field, 0);

            ulong initKey = hash.Key;

            field.MakeMove(startX, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX, startY + 1);
            hash.UpdateHash();

            while (field.States.Count() != 0)
            {
                field.UnmakeMove();
                hash.UpdateHash();
            }

            Assert.AreEqual(hash.Key, initKey);
        }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:30,代码来源:ZobristHashTest.cs

示例5: CalculateHash_EnemyBaseInBase

        public void CalculateHash_EnemyBaseInBase()
        {
            int startX = 5;
            int startY = 2;

            var field = new Field(39, 32);
            ZobristHashField hash = new ZobristHashField(field, 0);

            ulong initKey = hash.Key;

            // center.
            field.MakeMove(startX + 1, startY + 3);
            hash.UpdateHash();
            field.MakeMove(startX, startY + 3);
            hash.UpdateHash();

            field.MakeMove(startX + 10, startY + 2);
            hash.UpdateHash();
            field.MakeMove(startX + 1, startY + 2);
            hash.UpdateHash();

            field.MakeMove(startX + 10, startY + 3);
            hash.UpdateHash();
            field.MakeMove(startX + 2, startY + 2);
            hash.UpdateHash();

            field.MakeMove(startX + 10, startY + 4);
            hash.UpdateHash();
            field.MakeMove(startX + 3, startY + 3);
            hash.UpdateHash();

            field.MakeMove(startX + 10, startY + 5);
            hash.UpdateHash();
            field.MakeMove(startX + 2, startY + 4);
            hash.UpdateHash();

            field.MakeMove(startX + 10, startY + 6);
            hash.UpdateHash();
            field.MakeMove(startX + 1, startY + 4);
            hash.UpdateHash();

            PutBigBase(field, hash);

            ulong firstHash = hash.Key;

            while (field.States.Count() != 0)
            {
                field.UnmakeMove();
                hash.UpdateHash();
            }

            Assert.AreEqual(initKey, hash.Key);

            startX = 16;
            startY = 16;
        }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:56,代码来源:ZobristHashTest.cs

示例6: CalculateHash_EmptyBase

        public void CalculateHash_EmptyBase()
        {
            int startX = 16;
            int startY = 16;

            var field = new Field(39, 32);
            ZobristHashField hash = new ZobristHashField(field, 0);

            ulong initKey = hash.Key;

            field.MakeMove(startX, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 10, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY + 1);
            hash.UpdateHash();
            field.MakeMove(startX + 10, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX + 2, startY + 1);
            hash.UpdateHash();
            field.MakeMove(startX + 10, startY + 2);
            hash.UpdateHash();

            field.MakeMove(startX + 3, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 10, startY + 3);
            hash.UpdateHash();

            field.MakeMove(startX + 2, startY - 1);
            hash.UpdateHash();
            field.MakeMove(startX + 10, startY + 4);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY - 1);
            hash.UpdateHash();
            field.MakeMove(startX + 1, startY);
            hash.UpdateHash();

            while (field.States.Count() != 0)
            {
                field.UnmakeMove();
                hash.UpdateHash();
            }

            Assert.AreEqual(initKey, hash.Key);
        }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:48,代码来源:ZobristHashTest.cs

示例7: CalculateHash_DifferentBaseCreationOrder

        public void CalculateHash_DifferentBaseCreationOrder()
        {
            int startX = 16;
            int startY = 16;

            var field = new Field(39, 32);
            ZobristHashField hash = new ZobristHashField(field, 0);

            ulong initKey = hash.Key;

            field.MakeMove(startX, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 1, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY + 1);
            hash.UpdateHash();
            field.MakeMove(startX + 2, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY - 1);
            hash.UpdateHash();
            field.MakeMove(startX + 2, startY - 1);
            hash.UpdateHash();

            field.MakeMove(startX + 2, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 3, startY);
            hash.UpdateHash();

            field.MakeMove(startX - 2, startY);
            hash.UpdateHash();
            field.MakeMove(startX - 2, startY - 1);
            hash.UpdateHash();

            ulong firstHash = hash.Key;

            while (field.States.Count() != 0)
            {
                field.UnmakeMove();
                hash.UpdateHash();
            }

            Assert.AreEqual(hash.Key, initKey);

            field.MakeMove(startX - 2, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 1, startY);
            hash.UpdateHash();

            field.MakeMove(startX, startY);
            hash.UpdateHash();
            field.MakeMove(startX + 2, startY + 1);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY + 1);
            hash.UpdateHash();
            field.MakeMove(startX + 2, startY - 1);
            hash.UpdateHash();

            field.MakeMove(startX + 1, startY - 1);
            hash.UpdateHash();
            field.MakeMove(startX + 3, startY);
            hash.UpdateHash();

            field.MakeMove(startX + 2, startY);
            hash.UpdateHash();
            field.MakeMove(startX - 2, startY - 1);
            hash.UpdateHash();

            ulong secondHash = hash.Key;

            Assert.AreEqual(firstHash, secondHash);

            while (field.States.Count() != 0)
            {
                field.UnmakeMove();
                hash.UpdateHash();
            }

            Assert.AreEqual(initKey, hash.Key);
        }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:82,代码来源:ZobristHashTest.cs

示例8: PlaySimulation

 // return 0=lose 1=win for current player to move
 private int PlaySimulation(Field field, UctNode n)
 {
     int randomresult = 0;
     if (n.Child == null && n.Visits < 10)
     { // 10 simulations until chilren are expanded (saves memory)
         randomresult = PlayRandomGame(field);
     }
     else
     {
         if (n.Child == null)
             CreateChildren(field, n);
         UctNode next = UCTSelect(n); // select a move
         if (next == null) { /* ERROR */ }
         field.MakeMove(next.Pos);
         int res = PlaySimulation(field, next);
         randomresult = 1 - res;
     }
     n.Update(1 - randomresult); //update UctNode (UctNode-wins are associated with moves in the Nodes)
     return randomresult;
 }
开发者ID:KvanTTT,项目名称:Dots-Game-AI,代码行数:21,代码来源:UctMoveGenerator.cs


注:本文中的Field.MakeMove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。