【问题标题】:Using Stockfish Chess AI in Unity在 Unity 中使用 Stockfish 国际象棋 AI
【发布时间】:2018-10-17 10:35:12
【问题描述】:

早上好。我正在尝试将 Stockfish 实施到 Unity 国际象棋游戏中,我被告知最好的方法是使用 Spawn.Process 有谁知道我可以查看并作为参考的现有代码?

不同的游戏状态是与 AI 交流的最佳方式吗?

谢谢!

【问题讨论】:

    标签: c# unity3d artificial-intelligence uci


    【解决方案1】:

    如果您可以在Forsyth-Edwards Notation 中表示您的游戏状态并阅读Algebraic Notation 以提升您的棋盘状态,这应该可以:

    string GetBestMove(string forsythEdwardsNotationString){
        var p = new System.Diagnostics.Process();
        p.StartInfo.FileName = "stockfishExecutable";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardInput = true;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();  
        string setupString = "position fen "+forsythEdwardsNotationString;
        p.StandardInput.WriteLine(setupString);
        
        // Process for 5 seconds
        string processString = "go movetime 5000";
        
        // Process 20 deep
        // string processString = "go depth 20";
    
        p.StandardInput.WriteLine(processString);
        
        string bestMoveInAlgebraicNotation = p.StandardOutput.ReadLine();
    
        p.Close();
    
        return bestMoveInAlgebraicNotation;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 2022-06-17
      • 1970-01-01
      相关资源
      最近更新 更多