This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-21 10:19:27

Aris54
New Scratcher
Registered: 2011-01-29
Posts: 2

cpu behaviour

It's a pain in the neck to get these cpu's to work.Especially Pac Man ghost's!

Offline

 

#2 2011-04-21 18:22:07

owetre18
Scratcher
Registered: 2009-07-01
Posts: 1000+

Re: cpu behaviour

Try to explain your problem better, and I will try to help.

Offline

 

#3 2011-04-21 20:14:04

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: cpu behaviour

Could you tell us a little more about your problem, so we can have a better idea of what you need?


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#4 2011-04-21 20:48:43

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: cpu behaviour

If you are trying to make the AIs ( Computer Players, Artificial Intelligence ) to wander around, I would suggest using "Hand-Made" sensors, each a different colored dot for each direction. So when < not [< color [ Sensor Color ] is touching [ Wall Color ] > ] > You will want to keep a record of which direction the Ghost is going and which directions it can go, so make Variables "for this sprite only" named something like "CanGoNorth?" and if it's "1" that means it can, and if it's zero that means it can't. Make a script that detects each direction and sets the variables. If it runs into a wall, then it will choose a random direction it can go in, so a list of directions it can go in ( 1 - North, 2 - South, etc ) and it will pick a random one from the list and it will go that way.

To make it more interesting you can make it so it can't go backward when turning, making it look more like Pac-Man.  smile

Offline

 

#5 2011-04-26 16:39:34

wallfish
Scratcher
Registered: 2010-11-14
Posts: 58

Re: cpu behaviour

I need to learn  how to program a cpu also. If i find out how i will tell you how.  smile

Offline

 

#6 2011-04-26 17:06:00

Hadlab
Scratcher
Registered: 2011-03-18
Posts: 100+

Re: cpu behaviour

Give it an almost set random path- something like this:

[blocks]
<when green flag clicked>
<forever>
<if><touching[ 'left border']>
<set{ 0 }to( 0)
<set{180  }to( 180)
<point in direction( <<  <{ 0 }><or> <{ 180 }> >>)
<move( 5 )steps>
[/blocks]

I am guessing that doesn't look great, but you get the idea


Need a hand? Look no further! Just drop me a comment and I'll be delighted to help!   smile

Offline

 

Board footer