本文整理汇总了C#中Position.fen方法的典型用法代码示例。如果您正苦于以下问题:C# Position.fen方法的具体用法?C# Position.fen怎么用?C# Position.fen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position.fen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fenTest
public void fenTest()
{
Bitboards.init();
Position.init();
var fen1 = "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 10";
var pos1 = new Position(fen1, false, null);
Assert.AreEqual(fen1, pos1.fen());
Assert.AreEqual(0x81598B11829602DD, pos1.st.key);
var fen2 = "2r3k1/1q1nbppp/r3p3/3pP3/pPpP4/P1Q2N2/2RN1PPP/2R4K b - b3 0 23";
var pos2 = new Position(fen2, false, null);
Assert.AreEqual(fen2, pos2.fen());
Assert.AreEqual(0xD76B6F24873CAD66, pos2.st.key);
var fen3 = "rnb1kbnr/pp1ppppp/2p5/q7/4P3/3P4/PPP2PPP/RNBQKBNR w KQkq - 1 3";
var pos3 = new Position(fen3, false, null);
Assert.AreEqual(fen3, pos3.fen());
Assert.AreEqual(0x139B22CF5565D5CEul, pos3.st.key);
var b = pos3.checkers();
Assert.AreEqual("a5", UCI.square(Utils.pop_lsb(ref b)));
}
示例2: flipTest
public void flipTest()
{
Bitboards.init();
Position.init();
var fen1 = "r1bbk1nr/pp3p1p/2n5/1N4p1/2Np1B2/8/PPP2PPP/2KR1B1R w kq - 0 13";
var pos1 = new Position(fen1, false, null);
pos1.flip();
Assert.AreEqual("2kr1b1r/ppp2ppp/8/2nP1b2/1n4P1/2N5/PP3P1P/R1BBK1NR b KQ - 0 13", pos1.fen());
pos1.flip();
Assert.AreEqual(fen1, pos1.fen());
var fen2 = "2r3k1/1q1nbppp/r3p3/3pP3/pPpP4/P1Q2N2/2RN1PPP/2R4K b - b3 0 23";
var pos2 = new Position(fen2, false, null);
pos2.flip();
Assert.AreEqual("2r4k/2rn1ppp/p1q2n2/PpPp4/3Pp3/R3P3/1Q1NBPPP/2R3K1 w - b6 0 23", pos2.fen());
pos2.flip();
Assert.AreEqual(fen2, pos2.fen());
}
示例3: 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 13), 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 millisecs or number of nodes.
internal static void benchmark(Position current, Stack<string> stack)
{
var fens = new List<string>();
var limits = new LimitsType();
long nodes = 0;
// Assign default values to missing arguments
var ttSize = (stack.Count > 0) ? (stack.Pop()) : "16";
var threads = (stack.Count > 0) ? (stack.Pop()) : "1";
#if DEBUG
var limit = (stack.Count > 0) ? (stack.Pop()) : "7";
#else
var limit = (stack.Count > 0) ? (stack.Pop()) : "13";
#endif
var fenFile = (stack.Count > 0) ? (stack.Pop()) : "default";
var limitType = (stack.Count > 0) ? (stack.Pop()) : "depth";
OptionMap.Instance["Hash"].v = ttSize;
OptionMap.Instance["Threads"].v = threads;
Search.reset();
if (limitType == "time")
{
limits.movetime = int.Parse(limit); // movetime is in ms
}
else if (limitType == "nodes")
{
limits.nodes = ulong.Parse(limit);
}
else if (limitType == "mate")
{
limits.mate = int.Parse(limit);
}
else
{
limits.depth = int.Parse(limit);
}
if (fenFile == "default")
{
fens.AddRange(Defaults);
}
else if (fenFile == "current")
{
fens.Add(current.fen());
}
else
{
var sr = new StreamReader(fenFile, true);
var fensFromFile = sr.ReadToEnd();
sr.Close();
sr.Dispose();
var split = fensFromFile.Replace("\r", "").Split('\n');
fens.AddRange(from fen in split where fen.Trim().Length > 0 select fen.Trim());
}
var time = Stopwatch.StartNew();
for (var i = 0; i < fens.Count; ++i)
{
var pos = new Position(fens[i], bool.Parse(OptionMap.Instance["UCI_Chess960"].v), ThreadPool.main());
Output.WriteLine($"\nPosition: {i + 1} / {fens.Count}");
if (limitType == "perft")
{
nodes += Search.perft(true, pos, limits.depth*Depth.ONE_PLY);
}
else
{
var st = new StateInfoWrapper();
ThreadPool.start_thinking(pos, limits, st);
ThreadPool.main().join();
nodes += Search.RootPos.nodes_searched();
}
}
var elapsed = time.ElapsedMilliseconds; // Ensure positivity to avoid a 'divide by zero'
Output.Write("\n===========================");
Output.Write($"\nTotal time (ms) : {elapsed}");
Output.Write($"\nNodes searched : {nodes}");
Output.WriteLine($"\nNodes/second : {1000*nodes/elapsed}");
}