本文整理汇总了C#中Search.MinimaxDecision方法的典型用法代码示例。如果您正苦于以下问题:C# Search.MinimaxDecision方法的具体用法?C# Search.MinimaxDecision怎么用?C# Search.MinimaxDecision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search.MinimaxDecision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
// TODO allow this to be configured as command line options
// TODO put new commands in to change these settings during play
// TODO allow player to choose which player he/she is
var state = new AmazonState();
var search = new Search<AmazonState, AmazonAction, int, byte, AmazonPlayer>(1000000);
search.Builder = new AmazonBuilder();
search.Cutoff = new AmazonCutoffTest(30 * 1000);
search.EvalFunc = new AmazonEvaluationFunction();
search.SuccessorFunc = new AmazonSuccessorFunction();
search.MaxExplorations = 100;
Console.WriteLine("Welcome to the Game of the Amazons!");
Console.WriteLine("Program by Paul Moore: github.com/paulmoore/SimpleAI");
Console.WriteLine("If you are stuck, try 'help'");
Console.WriteLine(state);
Console.WriteLine("You are player WHITE");
Console.WriteLine("Your turn");
while (true) {
Console.Write("amazons> ");
string input = Console.ReadLine();
if (input == null) {
break;
}
input = input.Trim().ToLower();
string[] cmd = input.Split(new string[]{" ", " \t"}, StringSplitOptions.RemoveEmptyEntries);
if (cmd.Length == 0) {
continue;
}
if (cmd[0] == "quit") {
break;
} else if (cmd[0] == "help") {
Console.WriteLine("Help menu:");
Console.WriteLine(" help");
Console.WriteLine();
Console.WriteLine("Quitting:");
Console.WriteLine(" quit");
Console.WriteLine();
Console.WriteLine("Making a move (ith row, jth column):");
Console.WriteLine(" move i1 j1 i2 j2 ar ac");
} else if (cmd[0] == "move") {
try {
int i1 = int.Parse(cmd[1]);
int j1 = char.Parse(cmd[2]) - 'a';
int i2 = int.Parse(cmd[3]);
int j2 = char.Parse(cmd[4]) - 'a';
int ar = int.Parse(cmd[5]);
int ac = char.Parse(cmd[6]) - 'a';
AmazonAction move = new AmazonAction();
move.role = AmazonPlayer.WHITE;
move.qr = (sbyte)(i1 - 1);
move.qc = (sbyte)j1;
move.qfr = (sbyte)(i2 - 1);
move.qfc = (sbyte)j2;
move.ar = (sbyte)(ar - 1);
move.ac = (sbyte)ac;
Console.WriteLine("You want to make this move: {0}", move);
string errmsg = AmazonMoveValidator.Validate(state, move);
if (errmsg == null) {
state.ApplyAction(move);
Console.WriteLine(state);
} else {
Console.WriteLine("That move is invalid: {0}", errmsg);
continue;
}
} catch {
Console.WriteLine("Usage: move i1 j1 i2 j2 ar ac");
continue;
}
try {
Console.WriteLine("My turn");
Console.WriteLine("I am thinking...");
AmazonAction decision = search.MinimaxDecision(state, AmazonPlayer.BLACK, AmazonPlayer.WHITE);
Console.WriteLine(string.Format("I made this decision: {0}", decision));
state.ApplyAction(decision);
Console.WriteLine(state);
Console.WriteLine("Your turn");
} catch (Exception e) {
Console.WriteLine("The AI encountered an exception, the program will now close");
Console.WriteLine(e);
Console.WriteLine(e.StackTrace);
break;
}
GC.Collect();
GC.WaitForPendingFinalizers();
} else {
Console.WriteLine("Unknown command: {0}", cmd[0]);
}
}
Console.WriteLine("Bye!");
}