Your SlideShare is downloading. ×
Juegos minimax AlfaBeta
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Juegos minimax AlfaBeta

2,201
views

Published on

Descripcion minimax alfabeta .

Descripcion minimax alfabeta .


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,201
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
51
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • INTELIGENCIA ARTIFICIAL Jorge Rodriguez
  • Transcript

    • 1. Juegos Nelson Becerra Correa Fundación FABBECOR-ONG
    • 2.  
    • 3. 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
    • 4.  
    • 5. 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.
    • 6. 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)
    • 7.  
    • 8.  
    • 9. Como juegan las maquinas
    • 10. Como juegan las maquinas
    • 11. Como juegan las maquinas
    • 12. Como juegan las maquinas
    • 13. Como juegan las maquinas
    • 14. DEEP-BLUE potencia de calculo
    • 15. Función de evaluación
    • 16. Función de evaluación
    • 17. 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.
    • 18.  
    • 19.  
    • 20. 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!
    • 21. Á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).
    • 22.  
    • 23. 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
    • 24. 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
            • ...
    • 25. Two Agents
      • MAX
        • Wants to maximize the result of the utility function
      • MIN
        • Wants to minimize the result of the evaluation function
    • 26.  
    • 27. … 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)= - ∞
    • 28. … MINIMAX Se tiene que e(p)=6 – 4 = 2 http://www.ocf.berkeley.edu/~yosenl/extras/alphabeta/alphabeta.html
    • 29. Basic Algorithm
    • 30. 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
    • 31. ALGORITMOS DE PRIMERA GENERACION
      • MINIMAX
      • NEGAMAX
      • ALFA/BETA
      • FALFA/BETA
      • LALFA/BETA
      • PALFA/BETA
      • SCOUT
    • 32. MINIMAX NEGAMAX ALFA/BETA FALFA/BETA
    • 33. LALFA/BETA PALFA/BETA SCOUT
    • 34. Max Min Max Min Starting node and labels MiniMax Search
    • 35. Max Min Max Min Continue expand the search space
    • 36. Max Min Max Min Continue expand the search space
    • 37. Max Min Max Min 2 3 5 0 9 7 4 Expand the search space down 3-ply
    • 38. 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
    • 39. 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
    • 40. 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
    • 41. Max Min Max Min 2 3 5 0 9 7 4 The move picked by Max 9 0 3 7 7 3 0 3
    • 42. 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
    • 43. 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
    • 44. 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
    • 45. 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
    • 46. 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?
    • 47.  
    • 48. 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
    • 49. 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!
    • 50. Max Min Max Min Starting node and labels Alpha-Beta Prune
    • 51. Max Min Max Min Perform a DFS
    • 52. Max Min Max Min Continue the DFS
    • 53. Max Min Max Min 2 3 Until reach the depth we want, i.e., 3-ply in this case
    • 54. Max Min Max Min 2 3 3 Propagate leaf values backward
    • 55. Max Min Max Min 2 3 3 3
    • 56. Max Min Max Min 2 3 3 3 3
    • 57. Max Min Max Min 2 3 3 3 3 Alpha Node Beta Node
    • 58. Max Min Max Min 2 3 3 3 3 Alpha Beta 5 New DFS path Ended with 5
    • 59. Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 Propagate backward
    • 60. Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 Because 3 < 5 The branch is pruned. Beta-Prune
    • 61. Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 New 3-ply DFS Ended with 0 0
    • 62. Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 0 0 Propagate backward
    • 63. Max Min Max Min 2 3 3 3 3 Alpha Beta 5 5 0 0 Propagate backward 0
    • 64. 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
    • 65. Algorithm
    • 66. 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 α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β = α = β =
    • 67. 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
    • 68.  
    • 69. Conclusion
      • Minimax finds optimal play for deterministic, fully observable, two-player games
      • Alpha-Beta reduction makes it faster

    ×