• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Juegos minimax AlfaBeta
 

Juegos minimax AlfaBeta

on

  • 2,684 views

Descripcion minimax alfabeta .

Descripcion minimax alfabeta .

Statistics

Views

Total Views
2,684
Views on SlideShare
2,667
Embed Views
17

Actions

Likes
0
Downloads
47
Comments
0

1 Embed 17

http://www.slideshare.net 17

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez

Juegos minimax AlfaBeta Juegos minimax AlfaBeta Presentation Transcript

  • Juegos Nelson Becerra Correa Fundación FABBECOR-ONG
  •  
  • Bibliografía
    • Conferencia : Miguel Illescas, Gran Maestro Internacional. Kasparov, Deep Blue y la mente del ajedrecista.
    • http://www.ocf.berkeley.edu/~yosenl/extras/alphabeta/alphabeta
    • Jorge Egger M. Desarrollo de la maestría ajedrecística computacional. Utilizando recursos restringidos. Universidad de chile. Facultad de ciencias físicas y matemáticas. Departamento de ciencias de la computación, Santiago de chile, Julio 2003.
    • Técnicas de inteligencia artificial en Juego. Nelson Becerra Correa, Fondo de publicaciones Universidad Distrital (FJC), Año 2003.
    • w.acm.uiuc.edu/sigart/docs/MinimaxPresentation.ppt
  •  
  • TEORIA DE JUEGOS
    • Fué creada para solucionar problemas económicos. Los pioneros de esta teoría son John Von Newman y Oskar Morgestern.
    • En la actualidad se aplica a la Psicología, la administarción , las ciencias políticas etc.
  • Cl asificación de los juegos NUMERO PARTICIPANTES
    • Unipersonales
    • Bipersonales
    • N-personas N>2
    NUMERO ESTRATEGIAS
    • Finito (estrategias finitas) ‏
    • Infinitas
    DE ACUERDO A LA INFORMACION
    • Información perfecta (Secuenciales)
    • Información Imperfecta (Yan ken Po) (Dilema pri)
    DE ACUERDO A LA SUMA
    • Juegos de suma cero (ajedrez, oso, go,mankala)
    • Juegos de suma distinta de cero (F)
  •  
  •  
  • Como juegan las maquinas
  • Como juegan las maquinas
  • Como juegan las maquinas
  • Como juegan las maquinas
  • Como juegan las maquinas
  • DEEP-BLUE potencia de calculo
  • Función de evaluación
  • Función de evaluación
  • Posición que un programa sin Tablas de Transposición no puede solucionar. Las Blancas ganan mediante 1.Rb1!! Rb7 2.Rc1!!
    • 30 movimientos sería necesaria, y eso tomaría miles de horas de tiempo de CPU.
    • Con tablas Hash 6 movimientos, puesto que existen 130 diferentes tipos de posiciones obtenibles desde la inicial.
  •  
  •  
  • Basic Idea
    • Search problem
      • Searching a tree of the possible moves in order to find the move that produces the best result
      • Depth First Search algorithm
    • Assume the opponent is also playing optimally
      • Try to guarantee a win anyway!
  • Árbol de variantes
    • En los inicios de 1970 la búsqueda en árboles de variantes alcanzaba la cantidad aproximada de 200 posiciones por segundo.
    • En año 2003, DEEP BLUE busca en 2.000.000 de posiciones por segundo.
    • Los mejores programas logran examinar todas las secuencias de movimientos con una profundidad de 8 a 10 movidas en el árbol (4 a 5 jugadas por bando).
  •  
  • Required Pieces for Minimax
    • An initial state
      • The positions of all the pieces
      • Whose turn it is
    • Operators
      • Legal moves the player can make
    • Terminal Test
      • Determines if a state is a final state
    • Utility Function
  • Utility Function
    • Gives the utility of a game state
      • utility(State)
    • Examples
      • -1, 0, and +1, for Player 1 loses, draw, Player 1 wins, respectively
      • Difference between the point totals for the two players
      • Weighted sum of factors (e.g. Chess)
        • utility(S) = w 1 f 1 (S) + w 2 f 2 (S) + ... + w n f n (S)
          • f 1 (S) = (Number of white queens) – (Number of black queens), w 1 = 9
          • f 2 (S) = (Number of white rooks) – (Number of black rooks), w 2 = 5
          • ...
  • Two Agents
    • MAX
      • Wants to maximize the result of the utility function
    • MIN
      • Wants to minimize the result of the evaluation function
  •  
  • … MINIMAX
    • Ejemplo de definición de función evaluadora:
    • Si p no es posición ganadora para ningún ganado, entonces:
      • e(p)= (el nº de filas, columnas y diagonales completas que todavía estan libres para MAX) – (nº de filas, columnas, diagonales completas que todavía estan libres para MIN)
    • Si p es una posición ganadora para MAX, entonces
      • e(p)= ∞ (donde ∞ indica un número positivo muy grande)
    • Si p es una posición ganadora para MIN, entonces
      • e(p)= - ∞
  • … MINIMAX Se tiene que e(p)=6 – 4 = 2 http://www.ocf.berkeley.edu/~yosenl/extras/alphabeta/alphabeta.html
  • Basic Algorithm
  • ALGORITMOS DE JUEGOS
    • Algoritmos de primera generación
      • se caracterizan por confiar en la capacidad bruta de las maquinas
    • Algoritmos de segunda generación:
      • Surge la inquietud de que mientras la maquina examina miles de posiciones su oponente humano solo examina algunas de ellas
  • ALGORITMOS DE PRIMERA GENERACION
    • MINIMAX
    • NEGAMAX
    • ALFA/BETA
    • FALFA/BETA
    • LALFA/BETA
    • PALFA/BETA
    • SCOUT
  • MINIMAX NEGAMAX ALFA/BETA FALFA/BETA
  • LALFA/BETA PALFA/BETA SCOUT
  • Max Min Max Min Starting node and labels MiniMax Search
  • Max Min Max Min Continue expand the search space
  • Max Min Max Min Continue expand the search space
  • Max Min Max Min 2 3 5 0 9 7 4 Expand the search space down 3-ply
  • Max Min Max Min 2 3 5 0 9 7 4 Propagate the leaf values backward Pick Max values at Max Level 9 0 3 7 7
  • Max Min Max Min 2 3 5 0 9 7 4 Continue propagate the values backward Pick Min values at Min Level 9 0 3 7 7 3 0
  • Max Min Max Min 2 3 5 0 9 7 4 Continue propagate the values backward Pick Max values at Max Level 9 0 3 7 7 3 0 3
  • Max Min Max Min 2 3 5 0 9 7 4 The move picked by Max 9 0 3 7 7 3 0 3
  • Example MINIMAX
    • Coins game
      • There is a stack of N coins
      • In turn, players take 1, 2, or 3 coins from the stack
      • The player who takes the last coin loses
  • Coins Game: Formal Definition
    • Initial State :
    • The number of coins in the stack
    • Operators :
      • 1. Remove one coin
      • 2. Remove two coins
      • 3. Remove three coins
    • Terminal Test:
    • There are no coins left on the stack
    • Utility Function: F(S)
      • F(S) = 1 if MAX wins, 0 if MIN wins
  • N = 4 K = N = 3 K = N = 2 K = N = 1 K = N = 0 K = N = 1 K = N = 2 K = N = 0 K = N = 0 K = N = 1 K = N = 0 K = N = 1 K = N = 0 K = N = 0 K = 1 2 3 3 2 1 2 1 1 1 2 1 1 N = 0 K = 1 F(S)= 0 F(S)= 0 F(S)= 0 F(S)= 1 F(S)= 1 F(S)=1 F(S)= 1 MAX MIN
  • N = 4 K = 1 N = 3 K = 0 N = 2 K = 0 N = 1 K = 1 N = 0 K = 1 N = 1 K = 0 N = 2 K = 1 N = 0 K = 1 N = 0 K = 1 N = 1 K = 0 N = 0 K = 0 N = 1 K = 1 N = 0 K = 0 N = 0 K = 0 1 2 3 3 2 1 2 1 1 1 2 1 1 N = 0 K = 1 1 F(S)=0 F(S)=0 F(S)=0 F(S)=1 F(S)=1 FFS(51791527S)=1 F(S)=1 MAX MIN Solution F(S)=1
  • Analysis
    • Max Depth: 5
    • Branch factor: 3
    • Number of nodes: 15
    • Even with this trivial example, you can see that these trees can get very big
      • Generally, there are O(b d ) nodes to search for
        • Branch factor b: maximum number of moves from each node
        • Depth d: maximum depth of the tree
      • Exponential time to run the algorithm!
      • How can we make it faster?
  •  
  • Alpha-Beta Pruning
    • Main idea: Avoid processing subtrees that have no effect on the result
    • Two new parameters
      • α: The best value for MAX seen so far
      • β: The best value for MIN seen so far
    • α is used in MIN nodes, and is assigned in MAX nodes
    • β is used in MAX nodes, and is assigned in MIN nodes
  • Alpha-Beta Pruning
    • MAX (Not at level 0)
      • If a subtree is found with a value k greater than the value of β, then we do not need to continue searching subtrees
        • MAX can do at least as good as k in this node, so MIN would never choose to go here!
    • MIN
      • If a subtree is found with a value k less than the value of α, then we do not need to continue searching subtrees
        • MIN can do at least as good as k in this node, so MAX would never choose to go here!
  • Max Min Max Min Starting node and labels Alpha-Beta Prune
  • Max Min Max Min Perform a DFS
  • Max Min Max Min Continue the DFS
  • Max Min Max Min 2 3 Until reach the depth we want, i.e., 3-ply in this case
  • Max Min Max Min 2 3 3 Propagate leaf values backward
  • Max Min Max Min 2 3 3 3
  • Max Min Max Min 2 3 3 3 3
  • Max Min Max Min 2 3 3 3 3 Alpha Node Beta Node
  • Max Min Max Min 2 3 3 3 3 Alpha Beta 5 New DFS path Ended with 5
  • Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 Propagate backward
  • Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 Because 3 < 5 The branch is pruned. Beta-Prune
  • Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 New 3-ply DFS Ended with 0 0
  • Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 0 0 Propagate backward
  • Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 0 0 Propagate backward 0
  • Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 0 0 The branch is cut off Because 3 > 0 Alpha Prune 0
  • Algorithm
  • N = 4 K = N = 3 K = N = 2 K = N = 1 K = N = 0 K = N = 1 K = N = 2 K = N = 0 K = N = 0 K = N = 1 K = N = 3 K = N = 1 K = N = 0 K = N = 0 K = 1 2 3 3 2 1 2 1 1 1 2 1 1 N = 0 K = 1 F(S)=0 F(S)=0 F(S)=0 F(S)=1 F(S)=1 F(S)=1 F(S)=1 MAX MIN α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β =
  • N = 4 K = 0 1 N = 3 K = 1 0 N = 2 K = 1 0 N = 1 K = 1 N = 0 K = 1 N = 1 K = 0 N = 2 K = 1 N = 0 K = 1 N = 0 K = 1 N = 1 K = N = 3 K = 0 N = 1 K = 1 N = 0 K = N = 0 K = 0 1 2 3 3 2 1 2 1 1 1 2 1 1 N = 0 K = 1 1 F(S)=0 F(S)=0 F(S)=0 F(S)=1 F(S)=1 F(S)=1 F(S)=1 MAX MIN α = β = 1 0 α = 0 β = α = 0 β = 1 0 α = β = 0 α = 1 β = α = 0 β = 0 α = 0 β = 0 α = 0 β = 1 α = 0 β = α = 0 β = 0 α = 0 β = α = 1 β = 0 α = β = α = 1 β = 0 α = 0 β = 1
  •  
  • Conclusion
    • Minimax finds optimal play for deterministic, fully observable, two-player games
    • Alpha-Beta reduction makes it faster