
-----------------------------------
Montyman77
Sat Jun 13, 2009 11:47 am

Pacman AI
-----------------------------------
What is it you are trying to achieve?
An Ai system for a pacman game


What is the problem you are having?
i want them to move randomly around until they are in line with pacman then they go after him
but i can't get them to detect intersections


Describe what you have tried to solve this problem


%&& AI1
%%attempt at detecting intersections then randomly picking a path
 if whatdotcolor (badx1-20, bady1 + (Pic.Height (spiny) div 2)) = 192 or whatdotcolor (badx1-20, bady1 + (Pic.Height (spiny) div 2)) = 14 then
    decision1:=1
    end if
    

    if whatdotcolor (badx1 + Pic.Width (spiny)+20, bady1 + (Pic.Height (spiny) div 2)) = 192 or whatdotcolor (badx1 + Pic.Width (spiny)+20, bady1 + (Pic.Height (spiny) div 2)) = 14 then
       if decision1=1 then decision1:=Rand.Int(1,2)
    end if
    end if

    if whatdotcolor (badx1 + (Pic.Width (spiny) div 2), bady1 + Pic.Height (spiny)+20) = 192 or whatdotcolor (badx1 + (Pic.Width (spiny) div 2), bady1 + Pic.Height (spiny)+20) = 14 then
        if decision1=1 or decision1=2 then 
        decision1:=Rand.Int(1,3) 
        end if
      end if

    if whatdotcolor (badx1 + (Pic.Width (spiny) div 2), bady1-20) = 192 or whatdotcolor (badx1 + (Pic.Width (spiny) div 2), bady1-20) = 14 then
        if decision1=1 or decision1=2 or decision1=3 then 
        decision1:=Rand.Int(1,4) 
    end if
    end if
    %acting on the decision
    if decision1=1 then badx1+=1
    elsif decision1=2 then badx1-=1
    elsif decision1=3 then bady1+=1
    else bady1-=1
    end if



Please specify what version of Turing you are using
4.1.1

-----------------------------------
stas054
Sat Jun 13, 2009 3:17 pm

RE:Pacman AI
-----------------------------------
I think you need to paste the entire code so people can take a look at it.. you forgot variables...

-----------------------------------
Montyman77
Sat Jun 13, 2009 3:59 pm

Re: Pacman AI
-----------------------------------
ok well here is the attatchment
