Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 3
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);
			}
		}
Ejemplo n.º 4
0
Archivo: Game.cs Proyecto: 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;
			}

		}
Ejemplo n.º 5
0
		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);
			}
		}