コード例 #1
0
		public MoveCandidate(byte move, ISearchTreeNode node)
		{
			this.Move = move;
			this.Node = node;
		}
コード例 #2
0
		public bool Equals(ISearchTreeNode other) { return false; }
コード例 #3
0
		public byte GetMove(Field field, TimeSpan min, TimeSpan max)
		{
			byte ply = (byte)(field.Count + 1);
			if (depth <= ply) { depth = (byte)(ply + 1); }
			var redToMove = (ply & 1) == 1;

			if (depth > MaximumDepth) { depth = MaximumDepth; }

			Sw.Restart();
			Logger.Clear();
			Max = max;

			var candidates = new MoveCandidates(redToMove);
			candidates.Add(field, ply, this);
			var move = candidates.GetMove();
			
			Root = GetNode(field, ply);
			Root.Add(candidates);

			for (/**/; depth <= MaximumDepth; depth++)
			{
				Root.Apply(depth, this, Scores.InitialAlpha, Scores.InitialBeta);

				move = candidates.GetMove();

				var log = new PlyLog(ply, move, Root.Score, depth, Sw.Elapsed);
				Logger.Append(log).AppendLine();

				// Don't spoil time.
				if (Sw.Elapsed > min || !TimeLeft) { break; }
			}
			return move;
		}