Exemple #1
0
        bool isCompatible(string path)
        {
            int timeout;

            if (String.IsNullOrWhiteSpace(textBox3.Text) || !Int32.TryParse(textBox3.Text, out timeout))
            {
                MessageBox.Show(this, "Invalid Value For The Timeout.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            this.timeout = timeout;
            ExternalAI ai = new ExternalAI();

            ai.Init(path, executor, timeout);
            int[,] board = { { 2, 1, 1, 0, 1, 1, 1 },
                             { 0, 0, 0, 1, 0, 0, 0 },
                             { 1, 1, 1, 0, 1, 1, 1 },
                             { 0, 0, 0, 1, 0, 0, 0 },
                             { 1, 1, 1, 0, 1, 1, 1 },
                             { 0, 0, 0, 1, 0, 0, 0 } };
            p        = ai.GetNextMove(1, 2, board);
            state    = ai.state;
            exitCode = ai.exitCode;
            if (p.first != 0)
            {
                if (state == ExternalAI.State.OK)
                {
                    state = ExternalAI.State.Invalid_Output;
                }
                return(false);
            }
            board = new int[, ] {
                { 1, 1, 1, 0, 1, 1, 2 },
                { 0, 0, 0, 1, 0, 0, 0 },
                { 1, 1, 1, 0, 1, 1, 1 },
                { 0, 0, 0, 1, 0, 0, 0 },
                { 1, 1, 1, 0, 1, 1, 1 },
                { 0, 0, 0, 1, 0, 0, 0 }
            };
            p        = ai.GetNextMove(1, 2, board);
            state    = ai.state;
            exitCode = ai.exitCode;
            if (p.first != 6)
            {
                if (state == ExternalAI.State.OK)
                {
                    state = ExternalAI.State.Invalid_Output;
                }
                return(false);
            }
            return(true);
        }
Exemple #2
0
 private void machineBgw_DoWork(object sender, DoWorkEventArgs e)
 {
     if (players[game.turn].type == 1)
     {
         Pair ret = players[game.turn].brain.GetNextMove();
         bgwCol = ret.first;
         bgwExp = ret.second;
     }
     else if (players[game.turn].type == 2)
     {
         bgwCol = players[game.turn].externalBrain.GetNextMove(
             players[game.turn].id, game.spaceID, game.board).first;
         state    = players[game.turn].externalBrain.state;
         exitCode = players[game.turn].externalBrain.exitCode;
         if (state == ExternalAI.State.OK)
         {
             state = game.ValidMove(bgwCol) ? ExternalAI.State.OK : ExternalAI.State.Invalid_Output;
         }
     }
 }