本文整理汇总了C#中Portfish.Position.to_fen方法的典型用法代码示例。如果您正苦于以下问题:C# Position.to_fen方法的具体用法?C# Position.to_fen怎么用?C# Position.to_fen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.to_fen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: benchmark
/// benchmark() runs a simple benchmark by letting Stockfish analyze a set
/// of positions for a given limit each. There are five parameters; the
/// transposition table size, the number of search threads that should
/// be used, the limit value spent for each position (optional, default is
/// depth 12), an optional file name where to look for positions in fen
/// format (defaults are the positions defined above) and the type of the
/// limit value: depth (default), time in secs or number of nodes.
internal static void benchmark(Position current, Stack<string> stack)
{
List<string> fens = new List<string>();
LimitsType limits = new LimitsType();
Int64 nodes = 0;
Int64 nodesAll = 0;
long e = 0;
long eAll = 0;
// Assign default values to missing arguments
string ttSize = (stack.Count > 0) ? (stack.Pop()) : "128";
string threads = (stack.Count > 0) ? (stack.Pop()) : "1";
string limit = (stack.Count > 0) ? (stack.Pop()) : "12";
string fenFile = (stack.Count > 0) ? (stack.Pop()) : "default";
string limitType = (stack.Count > 0) ? (stack.Pop()) : "depth";
OptionMap.Instance["Hash"].v = ttSize;
OptionMap.Instance["Threads"].v = threads;
TT.clear();
if (limitType == "time")
limits.movetime = 1000 * int.Parse(limit); // maxTime is in ms
else if (limitType == "nodes")
limits.nodes = int.Parse(limit);
else
limits.depth = int.Parse(limit);
if (fenFile == "default")
{
fens.AddRange(Defaults);
}
else if (fenFile == "current")
{
fens.Add(current.to_fen());
}
else
{
#if PORTABLE
throw new Exception("File cannot be read.");
#else
System.IO.StreamReader sr = new System.IO.StreamReader(fenFile, true);
string fensFromFile = sr.ReadToEnd();
sr.Close();
sr.Dispose();
string[] split = fensFromFile.Replace("\r", "").Split('\n');
foreach (string fen in split)
{
if (fen.Trim().Length > 0)
{
fens.Add(fen.Trim());
}
}
#endif
}
Stopwatch time = new Stopwatch();
long[] res = new long[fens.Count];
for (int i = 0; i < fens.Count; i++)
{
time.Reset(); time.Start();
Position pos = new Position(fens[i], bool.Parse(OptionMap.Instance["UCI_Chess960"].v), Threads.main_thread());
Plug.Write("\nPosition: ");
Plug.Write((i + 1).ToString());
Plug.Write("/");
Plug.Write(fens.Count.ToString());
Plug.Write(Constants.endl);
if (limitType == "perft")
{
Int64 cnt = Search.perft(pos, limits.depth * DepthC.ONE_PLY);
Plug.Write("\nPerft ");
Plug.Write(limits.depth.ToString());
Plug.Write(" leaf nodes: ");
Plug.Write(cnt.ToString());
Plug.Write(Constants.endl);
nodes = cnt;
}
else
{
Threads.start_searching(pos, limits, new List<Move>());
Threads.wait_for_search_finished();
nodes = Search.RootPosition.nodes;
res[i] = nodes;
}
e = time.ElapsedMilliseconds;
nodesAll += nodes;
//.........这里部分代码省略.........