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

#1 2011-06-30 10:53:05

frizzlepuss893
Scratcher
Registered: 2011-06-10
Posts: 100+

Ai programming: fight

I need a script that makes an ai run around, following you but never staying on you, he can't move too fast. He needs to be able to jump at the right time, (On the fighting platforms) and he needs to be able to switch to costume "duck" when you try to punch. He also needs to be able to punch and kick at the right time. I know he'll need variables, so i've made a list of variables I already have:

Yvelocity
Health
Opponent health
Attack(When enemy punches, it switches to 1, kicks, 2. When player does it, it's 3 and 4. I've taken care of the life losing. I just need the ai script)
Special attack(Don't worry about that)
I think theres something else but i dont know what it is....

Anyways thanks for helping (if you DO help). Bye!


"Wait, what?"-Frizzlepuss. Jumpathon 5! play now!
The scratch song! Congratulations scratch! 2 million projects!

Offline

 

#2 2011-06-30 14:52:47

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Ai programming: fight

I've never made an AI before (it's next on the list), so I can just give you some small inputs.

This seems like a single-screen platformer. Makes things easier. I would start by giving the AI equal (or inferior) chances than the player: duplicate the player's movement scripts, but trigger them with a broadcast rather than an arrow key.

Then, to the actual intelligence of the AI. For movement, try sensing where the player is relative to the AI (left-er or right-er) and broadcast that movement. For the jumping, maybe have preset jump points or something.

I don't really think that helped much  hmm

Offline

 

#3 2011-06-30 20:36:46

frizzlepuss893
Scratcher
Registered: 2011-06-10
Posts: 100+

Re: Ai programming: fight

bump...


"Wait, what?"-Frizzlepuss. Jumpathon 5! play now!
The scratch song! Congratulations scratch! 2 million projects!

Offline

 

#4 2011-07-02 13:46:34

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

Re: Ai programming: fight

You should make sensors to detect if the Player is in front of the AI, and if it is, shoot. And follow, but if it can't see the Player anymore, it'll just go around "randomly" until it finds the Player again.

Offline

 

#5 2011-07-09 18:36:21

frizzlepuss893
Scratcher
Registered: 2011-06-10
Posts: 100+

Re: Ai programming: fight

Magnie wrote:

You should make sensors to detect if the Player is in front of the AI, and if it is, shoot. And follow, but if it can't see the Player anymore, it'll just go around "randomly" until it finds the Player again.

I'm not getting what you're saying...


"Wait, what?"-Frizzlepuss. Jumpathon 5! play now!
The scratch song! Congratulations scratch! 2 million projects!

Offline

 

#6 2011-07-10 15:31:07

chipguy
Scratcher
Registered: 2009-09-09
Posts: 500+

Re: Ai programming: fight

okay, first, if the player is to your left, make his x velocity change negativly... if he's to the right, use positive. if he is above you, make him jump, and say that if the distance to the player is less than somthing, broadcast "punch" or "kick". if you think, it's pretty easy... it just takes a little bit...


http://scratch.mit.edu/static/projects/chipguy/2919121_sm.png by yours truly  big_smile

Offline

 

#7 2011-07-15 10:18:47

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

Re: Ai programming: fight

frizzlepuss893 wrote:

Magnie wrote:

You should make sensors to detect if the Player is in front of the AI, and if it is, shoot. And follow, but if it can't see the Player anymore, it'll just go around "randomly" until it finds the Player again.

I'm not getting what you're saying...

AIs are confusing and hard to make. True AIs are currently impossible.

But basically what I said was get multiple sprites or "detector sprites" and have them always go to the AI sprite. If the sensor is touching the character sprite then the AI will chase the player. Then code the moving so it moves around "trying to find" the player or just doing a sentry patrol.

Offline

 

Board footer