You are on page 1of 63

Problem Resolution

Artificial Intelligence

Lecture 3
Karim Bouzoubaa
Introduction
¢  A problem is most often posed in the form of an informal statement, in the
natural language form. Before solving it, it is necessary then, at least for a
resolution by the machine, to carry out a first step of specifying the
problem

¢  To solve pbs, AI proposes a different approach from the classical


approach proposed by computer science

¢  Classically: the computer manipulates digital information


executes statements

¢  pb à alg (statements) à solution


Human being machine
analyzes executes (fast and accurate)

Karim Bouzoubaa Artificial Intelligence 2


Introduction
¢  In an AI vision:
l  The computer manipulates symbolic information (K)
l  Reasons on K (resolves ; builds the sol)

¢  Pb statement + reasoning possibility à sol


K elts resolution strategy computer solves

¢  Summary:
l  No statements: say what (declarative reasoning) and not how
l  Bug of K

Karim Bouzoubaa Artificial Intelligence 3


Space and Memory Problem

¢  Chess game


¢  Formal description of the pb:
l  Initial config.: matrix 8 x 8 positions, each position indicates a symbol
l  Goal: king fails
l  Legal movements: set of rules
à
l  10120 rules: space and memory pb

Karim Bouzoubaa Artificial Intelligence 4


Example: cans

4L 3L
2L

problem
Its representation
Two cans: can4 and can3, of
respective capacity of 4 and 3 l  Possible states (V4, V3) such that
•  V4= 0, 1, 2, 3 or 4
liters . None of them is •  V3 = 0, 1, 2 or 3
graduated. A pump is available to
fill the cans. How can you get l  initial state (0,0)
exactly 2 liters in can4?
l  final state (2,n)

Karim Bouzoubaa Artificial Intelligence 5


Example: cans – operators
K elements
N° operator explanation Condition
1 (V4,V3)→(4,V3) Fill can4 If V4 < 4

2 (V4,V3)→(V4,3) Fill can3 If V3 < 3

3 (V4,V3)→(V4-q,V3) Withdraw quantity q from can4 If V4 > 0

4 (V4,V3)→(V4,V3-q) Withdraw quantity q from can3 If V3 > 0

5 (V4,V3)→(0,V3) Empty can4 If V4 > 0

6 (V4,V3)→(V4,0) Empty can3 If V3 > 0

Empty water from can4 in can3 till can3 is full


7 (V4,V3)→(4,V3-(4-V4) ) If V4+V3 ≥ 4 and V3 > 0

Empty water from can3 in can4 till can3 is full


8 (V4,V3)→(V4-(3-V3), 3) If V4+V3 ≥ 3 and V4 > 0

9 (V4,V3)→(V4+V3,0) Empty all the water of can4 in can3 If V4+V3≤4 and V3 > 0

10 (V4,V3)→(0,V4+V3) Empty all the water of can3 in can4 If V4+V3≤3 and V4 > 0

11 (V4,V3)→(2,0) Empty 2 water liters from can3 in can4


12 (V4,V3)→(0,V3) Empty 2 water liters from can4 in can3

Karim Bouzoubaa Artificial Intelligence 6


Example: cans – One solution

L can4 L can3 N° Rule Rule Remark

0 0 2 (V4,V3)→(V4,3) Initial state

0 3 9 (V4,V3)→(V4+V3,0)

3 0 2 (V4,V3)→(V4,3)

3 3 7 (V4,V3)→(4,V3-(4-V4) )

4 2 5 (V4,V3)→(0,V3)

0 2 11 (V4,V3)→(2,0)

2 0 Final state

K elements are enough à implement a implémenter a resolution strategy

Karim Bouzoubaa Artificial Intelligence 7


Problem resolution

¢  Algorithmic Approach


l  Execution system of the solution
l  Deterministic machine with finite states
l  At every time during execution, the next
statement to execute is known

¢  Production system approach (PS)


l  Resolution system of problems
l  Search space (state space, goals ..)
l  Search strategy ; space exploration

Karim Bouzoubaa Artificial Intelligence 8


Production system components

¢  A search space


l  Space of possible states
l  Representation of every state (couple, plan, matrix, etc.)

¢  A set of production rules state1 → state2


l  A rule is a behaviour unit
l  It allows to transform the state of the space to advance in the
searching process

¢  A control mechanism that selects the rule to trigger among the
applicable rules
l  A rule is applicable if its head unifies with the current state
l  Many rules may be applicable at a given time

l  The control mechanism corresponds to the search strategy

Karim Bouzoubaa Artificial Intelligence 9


Example: cans
1 (V4,V3)→(4,V3) If V4 < 4
2 (V4,V3)→(V4,3) If V3 < 3
3 (V4,V3)→(V4-q,V3) If V4 > 0
4 (V4,V3)→(V4,V3-q) If V3 > 0
5 (V4,V3)→(0,V3) If V4 > 0
6 (V4,V3)→(V4,0) If V3 > 0

7 (V4,V3)→(4,V3-(4-V4) ) If V4+V3 ≥ 4 et V3 > 0

8 (V4,V3)→(V4-(3-V3), 3) If V4+V3 ≥ 3 et V4 > 0

9 (V4,V3)→(V4+V3,0) If V4+V3≤4 et V3 > 0


(0,0)
10 (V4,V3)→(0,V4+V3) If V4+V3≤3 et V4 > 0
1 2
11 (V4,V3)→(2,0)
12 (V4,V3)→(0,V3)

(4,0) (0,3)

2 3 5 8 12 1 4 6 9

(4,3) (4-q,0) (0,0) (1,3) (0,0) (4,3) (0,3-q) (0,0) (3,0)

(2,X)
Karim Bouzoubaa Artificial Intelligence 10
Prolog Program

¢  A space search


l  Every state: cans(V4, V3)
l  Possible states: cans(V4, V3) such that V4= 0, 1, 2, 3 or 4 and V3 = 0, 1, 2 or 3

¢  Initial state : cans(0,0)

¢  Final state : cans(2,n)

¢  A set of production rules state1 à state2


update(_state1, _Mvt, _state2)

update(cans(_V4,_V3), empty(can4), cans(0,_V3)).

update(cans(_V4,_V3), fill(can3), cans(_V4,_C3)) :-


capacity(can3,_C3).

¢  A control mechanism selects a rule to trigger among the appliable rules

Karim Bouzoubaa Artificial Intelligence 11


Control Mechanism

inDepth_resolution(_State, _History, [_Mvt | _Mvts]) :-


apply_operator(_State,_Mvt),
update(_State, _Mvt, _State1),
legal_state(_State1),
not(member(_State1,_History)),
inDepth_resolution(_State1, [_State1|_History], _Mvts).

Karim Bouzoubaa Artificial Intelligence 12


apply_operator(cans(_V4,_V3), fill(can4)) :-
less(_V4, 4, true). //_V4 < 4.
apply_operator(cans(_V4,_V3), fill(can3)) :-
Production rules less(_V3,3, true). //_V3 < 3.
apply_operator(cans(_V4,_V3), empty(can4)) :-
greater(_V4,0,true). //_V4 > 0.
1 (V4,V3)→(4,V3) Si V4 < 4 apply_operator(cans(_V4,_V3), empty(can3)) :-
2 (V4,V3)→(V4,3) Si V3 < 3
greater(_V3,0,true). //_V3 > 0.
apply_operator(cans(_V4,_V3), transfill(can3,can4)) :-
3 (V4,V3)→(V4-q,V3) Si V4 > 0
greater(_V3, 0, true), //_V3 > 0,
4 (V4,V3)→(V4,V3-q) Si V3 > 0
_V5 is _V4 + _V3,
5 (V4,V3)→(0,V3) Si V4 > 0
greater_equal(_V5, 4, true). //_V4 + _V3 >= 4.
6 (V4,V3)→(V4,0) Si V3 > 0
apply_operator(cans(_V4,_V3), transfill(can4,can3)) :-
7 (V4,V3)→(4,V3-(4-V4) ) Si V4+V3 ≥ 4 et V3 > 0 greater(_V4, 0, true), //_V4 > 0,
_V5 is _V4 + _V3,
8 (V4,V3)→(V4-(3-V3), 3) Si V4+V3 ≥ 3 et V4 > 0
greater_equal(_V5, 3, true). //_V4 + _V3 >= 3.
9 (V4,V3)→(V4+V3,0) Si V4+V3≤4 et V3 > 0 apply_operator(cans(_V4,_V3),
10 (V4,V3)→(0,V4+V3) Si V4+V3≤3 et V4 > 0
transfill_all(can3,can4)) :-
greater(_V3, 0, true), //_V3 > 0,
11 (V4,V3)→(2,0)
_V5 is _V4 + _V3,
12 (V4,V3)→(0,V3)
less_equal(_V5, 4, true). //_V4 + _V3 <= 4.
apply_operator(cans(_V4,_V3),
transfill_all(can4,can3)) :-
greater(_V4, 0, true), //_V4 > 0,
_V5 is _V4 + _V3,
less_equal(_V5, 3, true). //_V4 + _V3 <= 3.

Karim Bouzoubaa Artificial Intelligence 13


update(cans(_V4,_V3), empty(can4), cans(0,_V3)).
update(cans(_V4,_V3), empty(can3), cans(_V4,0)).
update(cans(_V4,_V3), fill(can4),
cans(_C4,_V3)) :-
capacity(can4,_C4).
Production rules update(cans(_V4,_V3), fill(can3),
cans(_V4,_C3)) :-
capacity(can3,_C3).
1 (V4,V3)→(4,V3) Si V4 < 4
update(cans(_V4,_V3), transfill_all(can3,can4),
2 (V4,V3)→(V4,3) Si V3 < 3 cans(_W4,_W3)) :-
3 (V4,V3)→(V4-q,V3) Si V4 > 0 capacity(can4,_C4),
4 (V4,V3)→(V4,V3-q) Si V3 > 0 _Liquid_quantity is _V4 + _V3,
5 (V4,V3)→(0,V3) Si V4 > 0 _Extra_Liquid is _Liquid_quantity - _C4,
6 (V4,V3)→(V4,0) Si V3 > 0 adjust(_Liquid_Quantity, _Extra_Liquid, _W4,
_W3).
7 (V4,V3)→(4,V3-(4-V4) ) Si V4+V3 ≥ 4 et V3 > 0
update(cans(_V4,_V3), transfill(can3,can4),
8 (V4,V3)→(V4-(3-V3), 3) Si V4+V3 ≥ 3 et V4 > 0 cans(_W4,_W3)) :-
capacity(can4, _C4),
9 (V4,V3)→(V4+V3,0) Si V4+V3≤4 et V3 > 0
_Liquid_quantity is _V4 + _V3,
10 (V4,V3)→(0,V4+V3) Si V4+V3≤3 et V4 > 0
11 (V4,V3)→(2,0)
_Extra_Liquid is _Liquid_quantity - _C4,
12 (V4,V3)→(0,V3)
adjust(_Liquid_Quantity, _Extra_Liquid, _W4,
_W3).
update(cans(_V4,_V3), transfill(can4,can3),
cans(_W4,_W3)) :-
capacity(can3,_C3),
_Liquid_quantity is _V4 + _V3,
_Extra_Liquid is _Liquid_quantity - _C3,
adjust(_Liquid_Quantity, _Extra_Liquid, _W3,
_W4).

Karim Bouzoubaa Artificial Intelligence 14


Solution

Karim Bouzoubaa Artificial Intelligence 15


Another example: The tease
3 5 8
1 • 6
2 4 7

3 5 8 3 5 8 3 • 8 3 5 8
• 1 6 1 6 • 1 5 6 1 4 6
2 4 7 2 4 7 2 4 7 2 • 7

• 3 8 3 8 •
1 5 6 1 5 6
2 4 7 2 4 7
1 2 3
8 • 4
7 6 5
Karim Bouzoubaa Artificial Intelligence 16
Basic Algorithm

¢  Initialization (current state = initial state)


¢  While (current state ≠ final state)
l  Step 1: Find a rule R that can be applied to a
current state
l  Step 2: new current state = application of R to
current state

¢  Search strategy (Step 1):


l  Search a rule among the possible ones
l  Keep track of sequences of rules already tried

Karim Bouzoubaa Artificial Intelligence 17


Search Strategies

¢  Systematic Non-informed search: Find a path, when


exploring space, that leads from the initial state to the final
state.
l  In-depth and breadthwise

¢  Search with information about node


l  Hill-Climbing, Best-First and Beam

¢  Search with information about nodes and edges


l  A*

Karim Bouzoubaa Artificial Intelligence 18


Depth Systematic Search
(depth-first strategy)

E1

E2 E3 E4

E5 E6

Memory is
E7 E8 E9 managed as a stack

Karim Bouzoubaa Artificial Intelligence 19


Depth search avoiding cycles

E1

E2 E3 E4

E5 E6 E5 E10

E7 E8 E9

¢  Add a mechanism to detect cycles

à A node already present in the path from initial to current node


cannot be considered a second time

Karim Bouzoubaa Artificial Intelligence 20


Limited depth search

¢  Pb : The program can be lost in an infinite depth


search à infinite state space

¢  Solution : To avoid infinite and non-cyclical


branches, we limit the depth of the search:
l  depthfirst2(Node, Solution, Maxdepth).
à The search can not go beyond the depth limit = Decrease
Maxdepth during each recursive call

Karim Bouzoubaa Artificial Intelligence 21


Breadth Systematic Search
(breath-first strategy)

E1

E2 E3 E4

E5 E6

Memory is
E7 E8 E9 managed as a list

Karim Bouzoubaa Artificial Intelligence 22


Comparison of the two systematic
methods

¢  Complexity
¢  B : average number of branches en moyenne per node
¢  n : the depth of the tree
Time Space
Depth O(Bn) O(B*n)

Breath O(Bn) O(Bn)

¢  Problems
¢  Depth-first: pay attention to endless depth
¢  Breath-first: pay attention to space

Karim Bouzoubaa Artificial Intelligence 23


Heuristic method

¢  Systematic search


l  Explore all paths
l  Eventually find a solution
l  Eventually may take a long time

¢  Heuristic search


l  Use of heuristics: choose paths to explore in priority
l  Heuristic criterion: associate with each state a certain estimated value (its
approximation of the goal)
•  Ex: h(n) = the distance between city n and destination city
l  For each problem, different estimate
l  Heuristic search: first explore the successor state representing the lowest
cost
l  Efficiency of heuristic research depends on how the knowledge of the field is
exploited

Karim Bouzoubaa Artificial Intelligence 24


Hill climbing

¢  Hill climbing Alg


1.  Departure state = current state
2.  If current state = final state, stop
3.  Generate children of current state
4.  Evaluate children and select the best one
5.  If the best is better than current state, advance
to that child that becomes the current state, go
to step 2
6.  Else stop

Karim Bouzoubaa Artificial Intelligence 25


Hill Climbing
6
2 8 3
1 6 4
7 • 5

6 3 6
2 8 3 2 8 3 2 8 3
1 6 4 1 • 4 1 6 4
• 7 5 7 6 5 7 5 •

0
1 2 3
8 • 4
7 6 5
Karim Bouzoubaa Artificial Intelligence 26
Hill Climbing Variants
¢  Problem with simple Hill climbing
l  The algorithm considers only one path
à  when the successors are not better than this state, the algorithm stops

¢  Hill climbing v2


l  Choose the state produced by the best move as next state
l  Alg

1.  Departure State de départ = current State


2.  If current State = final State, stop
3.  Generate children of current State
4.  Evaluate childre and select the best
5.  Move to that child which becomes the current State, goto
step 2
6.  else, stop

Karim Bouzoubaa Artificial Intelligence 27


Hill Climbing v2
applied on the puzzle

¢  Discussion :
l  Depth first
l  Breadth first
l  Hill climbing
l  Hill climbing
steep

Karim Bouzoubaa Artificial Intelligence 28


Hill Climbing summary:
Principle of a local search

¢  A local search just keeps some states visited in memory:


l  The simplest case is hill-climbing which just keeps a state (the current state)
and iteratively improves it until converging to a solution

¢  In general, there is an objective function to optimize (maximize or


minimize)
l  In the case of hill-climbing, it determines the successor state

¢  In general, a local search does not guarantee an optimal solution. Its
attractiveness is above all its ability to find an acceptable solution quickly.

Karim Bouzoubaa Artificial Intelligence 29


Hill Climbing summary

¢  Hill Climbing Problem


l  Local Maximum
l  The alg can end without finding a goal state but finding a
state from which one can not generate a better state

¢  Hill Climbing


l  Local technique, i.e. considers only the immediate
consequences of a state
l  No possibility to consider other paths (illustrate on
previous image)

¢  Use of the Best First method


Karim Bouzoubaa Artificial Intelligence 30
Best First

¢  Best First


l  Combination of depth and breath search
l  Follow one path at a time but change it as soon as a more
promising path appears

¢  Method
l  select the most promising node of all generated nodes
l  Perform the expansion of the node using the applicable rules
l  Among the successors, if one of them is a solution, stop
l  Otherwise, all new nodes are added to all the nodes already
generated
l  Again the most promising node becomes the current node

Karim Bouzoubaa Artificial Intelligence 31


Best First Algorithm

¢  Open contains nodes not yet processed, ie at the boundary of the part of the
graph explored so far.
¢  Closed contains the nodes already processed, ie inside the boundary delimited
by open.

open = initial state


while open != null do
1. Pick the best node on open
2. Create open's successors
3. For each successor do:
a. If it has not been generated before: evaluate it, add it to OPEN, and record
its parent
b. Otherwise: change the parent if this new path is better than previous one.
done

Karim Bouzoubaa Artificial Intelligence 32


Example Best First

A
A A (3)
(5)
(3)
(5)
(1) B C D
B C D
(4) (6)

E F

A
(5)
A B C D
(5)
(6) (5) (6)
B C D
G H E F
(6) (5) (4) (6)

G H E F (2) (1)
I J

Karim Bouzoubaa Artificial Intelligence 33


Beam search

¢  Beam search


l  Isan optimization of best-first search
l  Reduces memory load
l  In the beam search method, only a certain
number of solutions are kept as candidates

Karim Bouzoubaa Artificial Intelligence 34


Generic definition of f

¢  In practice we do not know the distance to the goal! That's


what we're looking for
¢  On the other hand, we know the optimal distance in the
explored part between the root and a node already explored
¢  It is convenient to separate f(n) into two parts:
l  g(n): the real cost of the optimal path from the root to n in the
part already explored
l  h(n): estimated cost of the rest of the path from n to the goal.
h(n) is called the heuristic function.

Karim Bouzoubaa Artificial Intelligence 35


Generic definition of f

¢  Depending on the weight we want to give to either party, we define f as


follows:
f(n) = (1-w).g(n) + w.h(n)

where w is a real number greater than or equal to 0 and less than or equal to 1.

¢  Depending on the values given to w, one obtains classical search


algorithms:
l  Dijkstra : w = 0 (f(n) = g(n) )
l  Best-first search : w = 1 (f(n) = h(n) )

l  A* : w = 0.5 (f(n) = g(n) + h(n) ) à Information about nodes and edges

Karim Bouzoubaa Artificial Intelligence 36


Example : A*
Distance between cities:
v0: departure
v6: destination Exploration:
h: distance
C: actual distance
1. (v0, 9, void)
h(n0) 2. (v1,5,v0) (v2,6,v0), (v3,7,v0)
9
3. (v2,6,v0) (v3,7,v0), (v5,12,v1)
v0 c(n0,n3)
2 3
4. (v3,7,v0),(v4,9,v2),(v5,12,v1)
4 5. (v2,5,v3),(v4,6,v3),(v5,12,v1)
2
5 1 6. (v4,6,v3),(v5,12,v1)
v3 v2 2 v1
2
7. (v6,7,v4), (v5,12,v1)
1 7
8. Solution: v0,v3,v4,v6
v4 3 v5 2
Content of closed at the end:
4
4 (v4,6), (v3,7), (v2,5), (v1,5), (v0,9)
v6 0

Karim Bouzoubaa Artificial Intelligence 37


A* Algorithm : Example

¢  Illustrer the example


l  f(a) = 1.5 + 4
l  f(d) = 2 + 4.5
l  …

Karim Bouzoubaa Artificial Intelligence 38


Farmer Problem

Karim Bouzoubaa Artificial Intelligence 39


Farmer
Problem

Karim Bouzoubaa Artificial Intelligence 40


Example: Towers of Hanoi

Karim Bouzoubaa Artificial Intelligence 41


Demo about searching methods

file:///Users/karimbouzoubaa/Data/Courses/AI/demos%20for
%20AI/demos/search/search.html

http://bgrins.github.io/javascript-astar/demo/

https://qiao.github.io/PathFinding.js/visual/

Solution with netbeans (Hipster library)

Karim Bouzoubaa Artificial Intelligence 42


Hipster : Java Library
u   Java  open  source  library    

v   for  problem  resolu3on  

v   Hipster-­‐core:  implemen3ng  many  search  algorithms  

v   Hipster  examples:  illustra3ng  the  exploita3on  of  Hipster-­‐core  such  


as:   SimpleEightPuzzle,   Directedgraphsearch,   MazeShortestPath,  
EightQueensProblem,  etc.    
Hipster core
   Non  informed  search  

 Depth  First  Search    

 Breadth  First  Search    

 Bellman-­‐Ford  

 Djikstra  

   informed  search  
 A*  
 Itera3ve  deeping  A*  
 Any3me  Dynamic  A*  

   Local  search  
 Hill-­‐Climbing  
 Enforced  Hill-­‐Climbing  
Hipster-core within
NetBeans
Production rules
private static List<Integer>
applyActionToState(Action action, List<Integer> board) {

List<Integer> successor = new ArrayList<Integer>(board);

switch (action){

// fill can4
case RULE1: successor.set(0, 4); break;

}
return successor;
}
Production rules
Control machanism
Step  1:  enumerate  ac3ons  
enum Action { RULE1, RULE2, RULE3, RULE4, RULE5, RULE6, RULE7, RULE8,
RULE9, RULE10 }

Step  2:    instanciate  a  new  problem  builder:  


SearchProblem p = ProblemBuilder.create()

Step  3:  configure  ini3al  state  


.initialState(Arrays.asList(0,0))

Step  4:  declare  ac3ons  


.defineProblemWithExplicitActions()
Production rules
Control machanism
Step  5:  implement  the  interface  Ac3onFunc3on  with  two  types  
 
.useActionFunction(new ActionFunction<Action, List<Integer>>() {
public List<Action> actionsFor(List<Integer> state) {
return validMovementsFor(state); }
})

Step  6:    to  generate  new  states  from  current  one  


 
.useTransitionFunction(new ActionStateTransitionFunction<Action,
List<Integer>>() { public List<Integer> apply(Action action,
List<Integer> state) {
return applyActionToState(action, state); }
})  
 
   
Production rules
Control machanism
Step  7:  to  find  the  shortest  path  
.useCostFunction(new CostFunction<Action, List<Integer>,
Double>() { public Double evaluate(Transition<Action,
List<Integer>> transition) {
return 1d; }
.build();
})
Final  step:  launch  the  algorithm  to  find  the  final  state  
System.out.println(
Hipster.createDepthFirstSearch(p).search(
Arrays.asList(2,0)));
 
 
Execution
Two players games

¢  Approaches for building programs that play


two-person games
l  tic-tac-toe, chess, etc.
¢  Much of the work in this area has been
motivated by playing chess
l  Claude Shannon, the father of information
theory, originated many of the ideas in a 1949
paper
l  …
l  Deep Blue 1997

Karim Bouzoubaa Artificial Intelligence 51


Two players games

¢  Some board position


represents the initial state
¢  We generate the children
of this position by making
all of the legal moves
available to us.
¢  Then, we consider the
moves that our opponent
can make to generate the
descendants of each of
these positions, etc.
¢  Note that these trees are
enormous and cannot be
explicitly represented in
their entirety for any
complex game.

Karim Bouzoubaa Artificial Intelligence 52


Partial game tree for Tic-Tac-Toe

Karim Bouzoubaa Artificial Intelligence 53


Scoring function

¢  This function assigns a numerical


value to a board position

¢  We can think of this value as


capturing the likelihood of winning
from that position.

¢  Since in these games one person's


win is another's person loss, we will
use the same scoring function for
both players, simply negating the
values to represent the opponent's
scores.

Karim Bouzoubaa Artificial Intelligence 54


MINiMAX Strategy

¢  Key idea: limited look-ahead + Min-Max algorithm


¢  Example:
l  depth of 2
l  values at the leaves: "static evaluations“
l  What we want: compute a value for each of the nodes above this one in the
tree by "backing up" these static evaluations in the tree.
¢  The player who is building the tree : maximize the score
¢  The opponent is trying to minimize the score
à Each layer of the tree can be classified into either a maximizing layer or
a minimizing layer: MIN-MAX algorithm.
Karim Bouzoubaa Artificial Intelligence 55
Example

Karim Bouzoubaa Artificial Intelligence 56


Example

Karim Bouzoubaa Artificial Intelligence 57


MINIMAX
code

Karim Bouzoubaa Artificial Intelligence 58


A simple Tron bot
The University of Waterloo Computer Science Club runs an interesting AI challenge sponsored by
Google. The aim of the challenge is to write a computer program that plays Tron.

Karim Bouzoubaa Artificial Intelligence 59


Importance of
look-ahead

¢  The more look-ahead is (the deeper in the tree) the better
our evaluation of a position will be
¢  Deep Blue
l  256 specialized chess processors

l  32 node supercomputer


l  30 billion moves per minute
l  Search depth [13, 30]

Karim Bouzoubaa Artificial Intelligence 60


ALPHA-BETA
strategy

¢  With MINIMAX, comprehensive exploration of


the space, ... According to the needed depth
¢  The technique is called alpha-beta: It is an
optimization of Min-Max search
¢  Some values are not worth exploring given the
values we already know
Karim Bouzoubaa Artificial Intelligence 61
http://www.cs.ualberta.ca/~chinook/

The Chinook project began in 1989 with


the goal of developing a program
capable of defeating the human World
Checkers Champion. In 1990, Chinook
became the first program in any game to
win the right to play for a human World
Championship. The program lost the
Championship match in 1992, but
became Champion in 1994. By 1996, it
became clear that the program was
much stronger than any human, and
Chinook was retired.

Karim Bouzoubaa Artificial Intelligence 62


Demo

http://homepage.ufp.pt/jtorres/ensino/ia/alfabeta.html

Karim Bouzoubaa Artificial Intelligence 63

You might also like