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

#1 2009-08-13 14:17:29

riccomario96
Scratcher
Registered: 2009-08-13
Posts: 2

Help

I am creating a recreation pong but I don't know how to make a computer player while i play. I know how to make the ball bounce off the paddles but i want to know how to tell the right paddle it is a computer player.

Offline

 

#2 2009-08-13 15:37:17

GrammaticlyCorrect
Scratcher
Registered: 2008-11-18
Posts: 42

Re: Help

You can't just tell the right paddle it's a computer player - you have to program the artificial intelligence.  There are many different types of AI you could make for it - I could make a demo, if you want, but I'm not sure what kind you would want.

Offline

 

#3 2009-08-15 17:11:24

Louis2018
Scratcher
Registered: 2008-06-13
Posts: 1000+

Re: Help

riccomario96 wrote:

I am creating a recreation pong but I don't know how to make a computer player while i play. I know how to make the ball bounce off the paddles but i want to know how to tell the right paddle it is a computer player.

In motion click if on edge bounce


http://img707.imageshack.us/img707/4547/louis2018.gif

Offline

 

#4 2009-08-16 15:30:13

riccomario96
Scratcher
Registered: 2009-08-13
Posts: 2

Re: Help

GrammaticlyCorrect wrote:

You can't just tell the right paddle it's a computer player - you have to program the artificial intelligence.  There are many different types of AI you could make for it - I could make a demo, if you want, but I'm not sure what kind you would want.

Just a simple pong playing field. Thats all. How do you program the artificial intelligence?

<when[  ]key pressed><forever><go to[ <move(  )steps> ?

Offline

 

#5 2010-05-21 21:22:38

jackfitz
Scratcher
Registered: 2010-05-20
Posts: 5

Re: Help

Try this formula. Add it to the new sprite.

When [green flag] clicked
Set CPU Level (you must make a variable) to 3
Forever
Repeat until x-position of (Paddle 2 [you must make a sprite in any case], CPU, etc.)= x-position of ball
If x-position of (Paddle 2, CPU, etc.)< x-position of ball
Change x by CPU Level
If x-position of (Paddle 2, CPU, etc.)> x-position of ball
Change x by CPU Level *-1

Offline

 

Board footer