Beispiel #1
0
		}//end of Min method

		private int Eval(List<Move> moves, bool forComputer) {
			int returnValue = 0;
			bool useTrans = false;
			long transKey = Delinquent.GetGame().GetCurrentHash();
			if(transTable.ContainsKey(transKey)) {
				Transposition trans = transTable[transKey];
				if(trans.Ply() <= currentDepth) {
					returnValue = trans.Score();
					useTrans = true;
				}
			}
			if(!useTrans) {
				Game.PLAYERS human = Delinquent.GetGame().GetHumanPlayer();
				Game.PLAYERS computer = Delinquent.GetGame().GetComputerPlayer();
				List<Move> computerMoves;
				List<Move> humanMoves;
				if(forComputer) {
					computerMoves = moves;
					humanMoves = Delinquent.GetGame().MoveGenerator(human);
				}
				else {
					humanMoves = moves;
					computerMoves = Delinquent.GetGame().MoveGenerator(computer);
				}
				//piece value + board advance + mobility + piece threat
				if(human == Game.PLAYERS.P1) {
					int p1Score = EvalP1Score(humanMoves);
					int p2Score = EvalP2Score(computerMoves);
					returnValue = p2Score - p1Score;
				}
				else {
					int p1Score = EvalP1Score(computerMoves);
					int p2Score = EvalP2Score(humanMoves);
					returnValue = p1Score - p2Score;
				}
				transTable[transKey] = new Transposition(currentDepth, returnValue);
			}
			return returnValue;
		}//end of Eval method