예제 #1
0
 public void SetSquareTarget(GameObject gameObject, SquareTypes _sqType, GameObject prefabLink)
 {
     if (_sqType.ToString().Contains(target.name))
     {
         var subTargetContainer = subTargetsContainers.FirstOrDefault(i => _sqType.ToString().Contains(i.targetPrefab.name));
         if (subTargetContainer == null)
         {
             Debug.LogError("Check Target Editor for " + _sqType);
         }
         subTargetContainer.changeCount(1);
         gameObject.AddComponent <TargetComponent>();
     }
 }
예제 #2
0
        private static void PlayVSHuman()
        {
            int           inputCount            = 9;
            int           outputCount           = 9;
            int           depth                 = 3;
            int           hiddenNeuronsPerLayer = 5;
            TicTacToeGame game = new TicTacToeGame();

            NeuralPlayer champion = MakeNeuralPlayer(inputCount, outputCount, depth, hiddenNeuronsPerLayer, new DNA(bestDNA));

            champion.SquareType = SquareTypes.X;
            SquareTypes winner = SquareTypes.N;

            for (int moveNum = 0; moveNum < 9 && winner == SquareTypes.N; moveNum++)
            {
                Console.WriteLine($"+- Turn {moveNum + 1} -+");
                TicTacToeGame.DisplayBoard(game.Board);

                SquareTypes curSquareType;
                Move        move;

                if (moveNum % 2 == 1)
                {
                    curSquareType = SquareTypes.O;
                    move          = AskHumanForMove();
                }
                else
                {
                    curSquareType = SquareTypes.X;
                    move          = champion.GetMove(game.Board);
                }

                if (game.IsEmpty(move.X, move.Y))
                {
                    game.Board[move.X, move.Y] = curSquareType;
                }
                else
                {
                    Console.WriteLine($"Player {curSquareType.ToString()} tried to use non-empty space [{move.X}, {move.Y}]");
                }

                if (moveNum > 3)
                {
                    winner = game.GetWinner();
                }
            }

            Console.WriteLine($"The winner is {winner.ToString()}");
        }