Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 AI for pac man
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
praveen15




PostPosted: Fri Nov 05, 2004 11:59 pm   Post subject: AI for pac man

hi friends...
this is a pac man game...everything is done, expect an AI to chace the pac man......has anyone here got the knowledge to make an AI for this??
plzzzz
it will be great..if you do so...thx a lot...

i'm making something similar to this...so i dunno how to make an ai for this.....i tried some ways...it doesnt work though

so plzzz u guys have to help me out...



Pac Man.t
 Description:

Download
 Filename:  Pac Man.t
 Filesize:  14.77 KB
 Downloaded:  258 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sat Nov 06, 2004 11:50 am   Post subject: (No subject)

AI eh? Well, if you want it, make it yourself. Judging from your code, that could take awhile.

First off, you need to tighten your code. What you have right now works, but barely. The whole thing is hardcoded, which is very bad. The problem with hardcoding is (apart from exsessive amounts of code) that one mistake can cause a bug that becomes practically untracable.
Case in point: In the top right hand corner, you have a horzontal line, a bracket, then a square. When PacMan moves across the bracket from the left, part of it is 'eaten'. How long is it going to take you to fix that?

Next. You have a bunch of ovals as your food. Good stuff. The next step is to progress from having simple ovals to having objects with properties. By this I mean you can create a type (perhaps called pacDot, or something like that) that will hold info about the specific dot's location (x, y), status (eaten or not) and whatever else you want. This way you won't get bits and pieces of the dots lying around later, since you will have then created a routine to check for PacMan eating the dot.
The other advantage here is that you can modify that array you have to be smaller and more inclusive.

As for the AI, you need to work on the basis of relative positions. Say you have a ghost at the bottom left corner, and PacMan at the top right. What the ghost (running of a very basic AI) will want to do is to try and match its x- and y- values with those of PacMan's (in effect moving until it is upon PacMan). This shouldn't be too difficult to do: if PacMan is to the left, try and move to the left etc etc. Of course you'll have to take into account collision detections with the wall.

Collision detection: I'm sorry to say but your method is superfluous. Though I'm not the biggest fan of it, in this case whatdotcolour() detection will be the way to go.

(BTW, why is it that when I press a key other than the arrow keys PacMan disappears?)

Go forth and improve...
cool dude




PostPosted: Sat Nov 06, 2004 12:19 pm   Post subject: (No subject)

it's a good start to your pacman game. some suggestions i would give you are: 1)you should change the coulour of your background by putting a colorback and in brackets the coulour you want. preferably black. 2)you should slow down the speed of the pacman because on my computer the pacman is going superspeed. 3)you could make a highscore list that will show the fastest time and the highest score. 4)you should put in other objects not only ovals, which will give you more score.

other than that it is a very good start to your game and good luck!

P.S. post your game in the submissions after your done
cool dude




PostPosted: Sat Nov 06, 2004 12:48 pm   Post subject: (No subject)

i don't really have time, because i am working on a battleship game in school right now so i can't sit there and write out the code for you, and i doubt someone else has time to do that.
some pointers on doing that is by making some monster (AI) and making the AI move by animating it. if you don't know how to animate it then look at some turorials in the tutorial section. then after you make it move set some boundaries so the monster can't move through the wall. after that just make the monster move in random directions by using randint on the animating object. if you don't know how to do that reply and i will post a ball that i made moving that moves in random directions and random speed. i hope you figure it out. if not reply and i'll see if i'll have time to help you a bit more.
praveen15




PostPosted: Tue Nov 09, 2004 6:00 am   Post subject: (No subject)

uumm....thx for the advice guys....but i'm just in grade 10 and thing i dont to make is the ai to chace the pac man

i dont know how to make the ai move a different directions when it hetts a wall....and also it sudnt erase the dots....

so there are my problems....if someone cud make a small sample porgra...it wud be great...or make the solutions wud be way beter....thx for all ya help

bye
cool dude




PostPosted: Tue Nov 09, 2004 1:36 pm   Post subject: (No subject)

i can't really do the thing for u but here is some advice. there might be a better way of doing it but the way i would do it is something like this.
you draw your AI. then set up dx and dy variables like this

code:

dx:=+1
dy:=-1


dont forget to declare these variables as int
then in your loop start off writting

code:

loop
x := x + dx
y := y + dy


then draw your monster and for the x and y coordinates write x,y and the rest of your coordinates. dont forget offscreenonly in your setscreen and then the View.Update in your loop, because that will prevent your AI from flickering. then do your if statements that say that if y gets to some point then dy:=+1 for your AI to change direction and the same for dy:=-1 for it to move down. then do the exact same for dx. so now you have all your boundaries so if the AI is going to hit the wall it will turn its direction the other way so it doesn't hit the wall. and all theres left is to put a randint and make the AI move in random direction. i'm preety sure u know how to do that, if not look up some tutorials u will learn a lot. good luck!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: