[英]StockFish Chess Engine won't work on Android Device but, works on Standalone Build and Unity editor perfectly
[英]Using Stockfish Chess AI in Unity
早上好。 我正在嘗試將 Stockfish 實施到 Unity 國際象棋游戲中,有人告訴我最好的方法是使用 Spawn.Process 有誰知道我可以查看並作為參考的現有代碼?
不同的游戲狀態是與 AI 交流的最佳方式嗎?
謝謝!
如果您可以用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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.