在Unity中使用Stockfish Chess AI [英] Using Stockfish Chess AI in Unity
本文介绍了在Unity中使用Stockfish Chess AI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
早上好.我被告知最好的方法是使用Spawn.Process,这是我尝试将Stockfish实施为Unity棋类游戏. 有人知道我可以查看并作为参考的现有代码吗?
Good Morning. I am trying to implement Stockfish to a Unity chess game, Ive been told that the best way is using Spawn.Process Does anyone know of existing code I can look at and take as reference?
不同的游戏状态是与AI进行交流的最佳方式吗?
Are different Gamestates the best way to communicate with AI?
谢谢!
推荐答案
如果您可以用 Forsyth-Edwards表示法,然后阅读代数符号来提高您的董事会状态,这应该可以:>
If you can represent your game state in Forsyth-Edwards Notation and read Algebraic Notation to advance your board state, this should work:
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;
}
这篇关于在Unity中使用Stockfish Chess AI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文