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

#1 2010-01-09 07:01:19

Some_Guy
Scratcher
Registered: 2010-01-09
Posts: 5

Ai-ing?

Right, first post etc...

Basically I'm making a bird's eye view robot wars game and I'm trying to get the opponent to attack the player. So far, I've tried 2 AI-ing tutorials - None of them worked. Advice and ideas would be a big help...

Offline

 

#2 2010-01-09 09:30:09

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Ai-ing?

Well, it really depends on what you're trying to do. So I will help you further if you tell me that.

Offline

 

#3 2010-01-11 01:45:42

Some_Guy
Scratcher
Registered: 2010-01-09
Posts: 5

Re: Ai-ing?

Ok, well, I want the AI to follow your robot and when it touches it, it will change costume. When it changes costume, your robot will move around 30 steps away from it. But I can't get the opposing robot to turn.

Offline

 

#4 2010-01-12 06:38:31

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Ai-ing?

That was just someone spamming.

um, get it so when the AI touches the other one, MR. AI broadcasts something that makes the other one go farther away.

for instance:

Code:

if(AI)touching(Other 1)
switch to costume "bla"
broadcast "move away"


(other sprite)
when I recieve(move away)
point in (direction - direction * 2)
move 30 steps

is that what you are looking for?


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#5 2010-01-12 17:13:32

scratch_yoshi
Scratcher
Registered: 2009-06-12
Posts: 1000+

Re: Ai-ing?

SeanProductions wrote:

<when green flag clicked><say[ Hello!  ]for(  2)secs>

Please don't spam SeanProductions. We want to keep the Scratch community spam-free and just posting in blocks is spamming.


Retired from Scratch, but just the language itself. Not the forums.

Offline

 

#6 2010-01-16 03:49:31

Some_Guy
Scratcher
Registered: 2010-01-09
Posts: 5

Re: Ai-ing?

Ok, well, that works now, but the AI still doesn't move. All I need is a simple script where the AI follows the player around, but slightly slower.

Offline

 

#7 2010-01-16 08:01:14

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Ai-ing?

okay,

here:

Code:

forever:
point towards player
move (playermovevariable - 1)

or just make him move however many steps you want.


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#8 2010-01-30 15:20:21

Some_Guy
Scratcher
Registered: 2010-01-09
Posts: 5

Re: Ai-ing?

How would I make it so then I can get round the side of the AI (aka make the Ai a bit slower at turning)

Offline

 

#9 2010-01-31 08:19:20

hidas
Scratcher
Registered: 2009-09-27
Posts: 76

Re: Ai-ing?

here's some code that may work:

[blocks] When Green Flag Clicked: Forever: Point Towards Player, wait playerspeed/2, repeat 10: move enemyspeed steps, if touching player: switch to costume "killed player", broadcast "player died"

PLAYER:
When I receive "player died", switch to costume 'die', point in direction: direction of enemy * 180: repeat 6: move 5 steps [/blocks]

Last edited by hidas (2010-01-31 08:20:27)


TBOS (Toxic Blobs Of Slime) will get you someday. Better buy a slime suit. Too late. Here they come...

Offline

 

#10 2010-02-01 12:30:49

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

Re: Ai-ing?

Slower turning is quite complicated, it takes two sprites or so to make, there is a "missile" project somewhere that followed the mouse and turns slowly like what you want.

Ahh found it: http://scratch.mit.edu/projects/bhz/394380

Hope that helps!  big_smile

Offline

 

#11 2010-02-01 13:17:22

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Ai-ing?

Magnie wrote:

Slower turning is quite complicated, it takes two sprites or so to make, there is a "missile" project somewhere that followed the mouse and turns slowly like what you want.

Ahh found it: http://scratch.mit.edu/projects/bhz/394380

Hope that helps!  big_smile

Actually - if you're good enough you can do it with the mouse X and Y and Trig.

Offline

 

#12 2010-02-02 15:16:05

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

Re: Ai-ing?

True.  smile

Offline

 

#13 2010-02-03 14:33:44

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Ai-ing?

yeah, you can do it with trig, but we're not all math whizs yet.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#14 2010-03-03 16:26:23

trekkie2000
Scratcher
Registered: 2009-02-15
Posts: 100+

Re: Ai-ing?

Some_Guy wrote:

How would I make it so then I can get round the side of the AI (aka make the Ai a bit slower at turning)

Create a "Line of sight" that is, a line that stretches out of the enemy
4 eva
go 2 (enemy)
Point in direction if Enemy
__________________________
Set the rotation point to the far left corner of the line
If NOT Touching (Player)
Brodcast "turn"
Have two dishes, sort of like the LOS bar, exept they are on the sides of the robot, and circle it, like 2 halves.
Use this scripting 4 the one on the right
When I recieve "Turn"
If touching (Player)
Brodcast "Turn Right" (Which unbelievably, you will connect 2 a brodcast block on the robot, which makes him turn right. OMG! who woulda guessed!)
Do the same 4 the one on the left, except with a "Turn Left command"
If u don't get it, tell me and I will create a tutorial 4 it.


"If life gives you lemons, sell lemonade for $.25...
...Sell antidote to poison in lemonade for $250" -Me

Offline

 

#15 2010-03-04 11:06:48

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Ai-ing?

trekkie2000 wrote:

Some_Guy wrote:

How would I make it so then I can get round the side of the AI (aka make the Ai a bit slower at turning)

Create a "Line of sight" that is, a line that stretches out of the enemy
4 eva
go 2 (enemy)
Point in direction if Enemy
__________________________
Set the rotation point to the far left corner of the line
If NOT Touching (Player)
Brodcast "turn"
Have two dishes, sort of like the LOS bar, exept they are on the sides of the robot, and circle it, like 2 halves.
Use this scripting 4 the one on the right
When I recieve "Turn"
If touching (Player)
Brodcast "Turn Right" (Which unbelievably, you will connect 2 a brodcast block on the robot, which makes him turn right. OMG! who woulda guessed!)
Do the same 4 the one on the left, except with a "Turn Left command"
If u don't get it, tell me and I will create a tutorial 4 it.

Maybe make it a script and save the picture of the script to show what you mean?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

Board footer