pac man weighted AI
Author |
Message |
viperfan7
|
Posted: Tue Mar 25, 2008 11:09 am Post subject: pac man weighted AI |
|
|
I have finaly made the AI for my pac man game, open for sugestions, the player base/ collision detection will be up shortly, but in the help section sence its so slow, open for comments/ crticizim, hope someone can use it, o also, the AI wont always move towards you, its set up so that it is more likely then not to move towards you.
Turing: |
% setscreen ("graphics:max;max,offscreenonly,nocursor")
setscreen("text")
var directionx, directiony : int
%var leftdetecty1, leftdetecty2, leftdetecty3 : int
%var rightdetecty1, rightdetecty2, rightdetecty3 : int
%var updetectx1, updetectx2, updetectx3 : int
%var downdetectx1, downdetectx2, downdetectx3 : int
var ghostx, ghosty, ghostWH : int
%var moveghost : int := 2
var comp1dirx, comp1diry : string
var pacx, pacy : int
%const wall : int := 10
%const wallcolour : int := 1
%ghostWH := 14
proc AI1
if pacx > ghostx then
directionx := Rand.Int (1, 4)
if directionx > 3 then
comp1dirx := "down"
else
comp1dirx := "up"
end if
elsif pacx < ghostx then
directionx := Rand.Int (1, 4)
if directionx > 1 then
comp1dirx := "down"
else
comp1dirx := "up"
end if
elsif pacx = ghostx then
directionx := Rand.Int (1, 4)
if directionx > 2 then
comp1dirx := "down"
else
comp1dirx := "up"
end if
end if
if pacy > ghosty then
directiony := Rand.Int (1, 4)
if directiony > 3 then
comp1diry := "left"
else
comp1diry := "right"
end if
elsif pacy < ghosty then
directiony := Rand.Int (1, 4)
if directiony > 1 then
comp1diry := "left"
else
comp1diry := "right"
end if
elsif pacy = ghosty then
directionx := Rand.Int (1, 4)
if directiony > 2 then
comp1diry := "left"
else
comp1diry := "right"
end if
end if
end AI1
for i : 0.. 5
ghostx := Rand.Int (0, maxx)
ghosty := Rand.Int (0, maxy)
pacx := Rand.Int (0, maxx)
pacy := Rand.Int (0, maxy)
put ghostx
put ghosty
put ""
put pacx
put pacy
put ""
AI1
put comp1dirx
put comp1diry
put ""
put "-----------"
put ""
end for
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
A.J
|
Posted: Tue Mar 25, 2008 3:54 pm Post subject: Re: pac man weighted AI |
|
|
It's not bad....but if you want to make your pacman AI extremely good, I suggest you look up A* pathfinding
Good Job though! |
|
|
|
|
|
viperfan7
|
Posted: Wed Mar 26, 2008 9:53 am Post subject: RE:pac man weighted AI |
|
|
I already have a colision detection system for it, but am probaly going to go with pathfinding instead, just that whatdotcolour, being used as many times as it would be, would lag |
|
|
|
|
|
|
|