Upcoming SlideShare
×

# Pusdo Code Ai

1,140 views

Published on

This is Pusdo Code for AI logic

Published in: Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,140
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
10
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Pusdo Code Ai

1. 1. 1 INTRODUCTION 1
6. 6. 6 Chapter 3. Solving Problems by Searching function I TERATIVE -D EEPENING -S EARCH( ¤¤'¦  T ¡ quot; £ ) returns a solution, or failure inputs: §(§'¦  T ¡ quot; £ , a problem for xHa % D©  ¡ 0 to y do RtI0§2£ % © 3 ¡ D EPTH -L IMITED -S EARCH( ¤¤'¦  T ¡ quot; £ , !R'a D©  ¡ ) uv© I0¤2£ w 3¡ if cutoff then return tI0§0£ © 3 ¡ Figure 3.19 function G RAPH -S EARCH( 'I6§0H¤¤'¦  ¡ C # £ GX T ¡ quot; £ ) returns a solution, or failure 2\$@¥ % a ¡ quot; an empty set % ¡ C # £ `I'H§0G I NSERT(M AKE -N ODE(I NITIAL -S TATE[ ]), ) T ¡ quot; £ §(§'¦  ¡ C # £ 'I6§0G loop do if E MPTY ?( I'6§§G ¡ C # £ ) then return failure P')# % ¡ a quot; R EMOVE -F IRST( ) I'H§0G ¡ C # £ if G OAL -T EST[ T ¡ quot; £ ¤¤'¦  ](S TATE[ ¡ a quot; ')# ]) then return S OLUTION( ¡ a quot; ')b# ) if S TATE[ ¡ a quot; ')# ] is not in then a ¡ quot; 2\$@¥ add S TATE[ ] to )b# ¡ a quot; 2\$@¥ a ¡ quot; % ¡ C # £ `'I6§0G I NSERT-A LL(E XPAND( , ), ) T ¡ quot; £ ¡ a quot; ¤¤2R  ')# ¡ C # £ 'I6§0G Figure 3.25
11. 11. 11 function AC-3( Q¥   ) returns the CSP, possibly with reduced domains inputs:   Q¥ , a binary CSP with variables X     o X g X i   local variables: R¤R¤S ¡ 3¡ 3 , a queue of arcs, initially all the arcs in Q¥   while §RS ¡ 3¡ 3 is not empty do %  R p X o   R EMOVE -F IRST( ) ¡ 3¡ 3 R¤RS if R EMOVE -I NCONSISTENT-VALUES(   X  ) then for each in N EIGHBORS[ ] do    o add (   X  ) to R¤RS ¡ 3¡ 3 function R EMOVE -I NCONSISTENT-VALUES(   X  ) returns true iff we remove a value \$¤v2\$\$o¤2£ ¡ G % a¡ d quot; T¡ k for each in D OMAIN[ ] do   if no value in D OMAIN[ ] allows ( , ) to satisfy the constraint between    7 k   and   k then delete from D OMAIN[ ];   ¡R3§£©h%va2¡\$d\$quot;o¤2£ T¡ return 2\$\$o¤2£ a¡ d quot; T¡ Figure 5.9 function M IN -C ONFLICTS( , ¨0 ioT ¥  ¡© k   ) returns a solution or failure inputs: Q¥   , a constraint satisfaction problem ¨0 ioT  ¡© k , the number of steps allowed before giving up R¢¤2§I¥ % © #¡££ 3 an initial complete assignment for ¥   for = 1 to ¨0 ioT  ¡© k do  ¥ if is a solution for © #¡££ 3 ¢¤2§I¥ then return © #¡££ 3 R§0§I¤¥ V\$1d % £ a randomly chosen, conﬂicted variable from VARIABLES[ ]¥   £ \$1d d the value for `3 \$1d % ¡ that minimizes C ONFLICTS( , , 3, £  Q¤¥ ©R#¤¡2£§£I¥ d 1\$d ) set R§¡2£§£43¤¥ © # in Rt1\$d w 1\$d ¡ 3 £ return 2It6\$¤G ¡ £ 3 Figure 5.11