示例#1
0
        protected int maxValue(GameState state, AlphaBeta ab)
        {
            int v = int.MinValue;

            if (terminalTest(state))
            {
                return(computeUtility(state));
            }
            else
            {
                ArrayList successorList = getSuccessorStates(state);
                for (int i = 0; i < successorList.Count; i++)
                {
                    GameState successor = (GameState)successorList[i];
                    int       minimumValueOfSuccessor = minValue(successor, ab.copy());
                    if (minimumValueOfSuccessor > v)
                    {
                        v = minimumValueOfSuccessor;
                        state.put("next", successor);
                    }
                    if (v >= ab.beta())
                    {
                        //System.out.println("pruning from max");
                        return(v);
                    }
                    //ab.setAlpha(Util.max(ab.alpha(), v));
                    ab.setAlpha(System.Math.Max(ab.alpha(), v));
                }
                return(v);
            }
        }
示例#2
0
 public override int getAlphaBetaValue(GameState state)
 {
     if (getPlayerToMove(state).ToUpper().Equals("X"))
     {
         AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue);
         int       max     = maxValue(state, initial);
         return(max);
     }
     else
     {
         //invert?
         AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue);
         return(minValue(state, initial));
     }
 }
示例#3
0
文件: TicTacToe.cs 项目: langeds/aima
		public override int getAlphaBetaValue(GameState state) 
		{
		
			if (getPlayerToMove(state).ToUpper().Equals("X")) 
			{
				AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue);
				int max = maxValue(state, initial);
				return max;

			} 
			else 
			{
				//invert?
				AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue);
				return minValue(state, initial);
			}
		}
示例#4
0
文件: Game.cs 项目: langeds/aima
		protected int maxValue(GameState state, AlphaBeta ab) 
		{
			int v = int.MinValue;
			if (terminalTest(state)) 
			{
				return computeUtility(state);
			} 
			else 
			{
				ArrayList successorList = getSuccessorStates(state);
				for (int i = 0; i < successorList.Count; i++) 
				{
					GameState successor = (GameState) successorList[i];
					int minimumValueOfSuccessor = minValue(successor, ab.copy());
					if (minimumValueOfSuccessor > v) 
					{
						v = minimumValueOfSuccessor;
						state.put("next", successor);
					}
					if (v >= ab.beta()) 
					{
						//System.out.println("pruning from max");
						return v;
					}
					//ab.setAlpha(Util.max(ab.alpha(), v));
					ab.setAlpha(System.Math.Max(ab.alpha(),v));
				}
				return v;
			}

		}
示例#5
0
文件: Decapawn.cs 项目: langeds/aima
		public override int getAlphaBetaValue(GameState state) 
		{
			this.computeUtilityCallsThisMove = 0;
			if (getPlayerToMove(state).ToUpper().Equals("W")) 
			{
				AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue);
				int max = maxValue(state, initial);
				return max;

			} 
			else 
			{
				//invert?
				AlphaBeta initial = new AlphaBeta(int.MinValue, int.MaxValue);
				return minValue(state, initial);
			}
		}