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

#1 2011-07-17 16:45:16

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

AI Scripting?

AI scripting is basically scripting a computer programmed engine right? Like a computer programmed player? So I am just wondering for future reference, how do you do that?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#2 2011-07-17 16:57:06

Flait7
Scratcher
Registered: 2008-04-14
Posts: 100+

Re: AI Scripting?

To script an AI, you'd have to script the sprite to be aware of its surroundings, and make it respond to the changes around it.  AI's tend to mimic actual players, by attempting to imitate what a player might do in the same situation they're in.


http://scratch.mit.edu/static/projects/Flait7/2248016_sm.pnghttp://scratch.mit.edu/static/projects/Flait7/1827934_sm.png

Offline

 

#3 2011-07-17 17:00:23

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: AI Scripting?

That'll probably be hard. Yea so I will definitely push my Super Smash Brawl game aside for a while until I unload other EASY Scratch game ideas.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#4 2011-07-17 17:09:50

Flait7
Scratcher
Registered: 2008-04-14
Posts: 100+

Re: AI Scripting?

Well, you can also have it wander aimlessly and randomly click attack buttons. I think people tend to do that while playing brawl anyway.


http://scratch.mit.edu/static/projects/Flait7/2248016_sm.pnghttp://scratch.mit.edu/static/projects/Flait7/1827934_sm.png

Offline

 

#5 2011-07-17 17:16:42

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: AI Scripting?

Well still I will put it aside. I was making a game a while ago and it is up now and had ideas but couldn't figure it out. Now I know how to so that is why.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#6 2011-07-19 21:32:02

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: AI Scripting?

Any more answers?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#7 2011-07-19 21:48:25

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

Re: AI Scripting?

An AI opponent is a pretty tough thing to do. Even in the professional world, an intelligent AI is not easy. However, there are some basic things that you should remember when creating one:

-In its simplest sense, an AI is something that reacts based on the situation, just like a person does. Try having some conditionals that tell it what to do in certain situations. For example, you might have it punch when the player is in front of it, but try to move away or dodge if they're attacking.
-Once you've got the basic AI working, you may want to introduce some randomness. People are fallible and don't always react the same way, so neither should your AI. Maybe have it pick a random number and do various different things that someone might do in that situation depending on the number chosen.

That's all I can think of right now. If I come up with anything else, I'll edit this post and add it.


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

 

#8 2011-07-19 23:19:23

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: AI Scripting?

Harakou wrote:

An AI opponent is a pretty tough thing to do. Even in the professional world, an intelligent AI is not easy. However, there are some basic things that you should remember when creating one:

-In its simplest sense, an AI is something that reacts based on the situation, just like a person does. Try having some conditionals that tell it what to do in certain situations. For example, you might have it punch when the player is in front of it, but try to move away or dodge if they're attacking.
-Once you've got the basic AI working, you may want to introduce some randomness. People are fallible and don't always react the same way, so neither should your AI. Maybe have it pick a random number and do various different things that someone might do in that situation depending on the number chosen.

That's all I can think of right now. If I come up with anything else, I'll edit this post and add it.

Thanks again Harakou!  big_smile . (Good luck on getting the Moderator job!)


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#9 2011-07-20 00:16:21

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: AI Scripting?

An AI is usually a very complicated script made of ifs and elses but it really depends what you need it for... my police car AI has a very simple and short script  wink


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#10 2011-07-20 01:26:57

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: AI Scripting?

jji7skyline wrote:

An AI is usually a very complicated script made of ifs and elses but it really depends what you need it for... my police car AI has a very simple and short script  wink

Thanks  smile


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#11 2011-08-16 15:13:09

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: AI Scripting?

Pa Bump.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#12 2011-08-16 23:51:16

murphofly
New Scratcher
Registered: 2011-08-12
Posts: 25

Re: AI Scripting?

i can so make you an ai sample for your game! the ai has to reconize what level it is, where everything is in the level, and then you just add it to do different attacks. simpler than it sounds, possible? heck yes. have 2 variables one is player x and the other player y, apply basic gravity and platformer principles have the ai take the position of the player and reconize what path to take by having it reconize the objects around it. it then checks how to get to the player by setting way point variables. these way points will be like a jump way point, forward waypoint and backwards waypoint. if its flat terrain forget the jump way point for now. the way points will be dots that are completely ghosted. once it reaches the way points it will do a command. i can make you a projrct of this and add notes to explain it. its hard to do with just text

Offline

 

#13 2011-08-17 00:00:34

murphofly
New Scratcher
Registered: 2011-08-12
Posts: 25

Re: AI Scripting?

AI scripting is literally the hardest thing to learn but once you learn it you can create amazing things, people have made 3d fps before, no one has made a perfect AI and mine won't be perfect but i promise ill get it close

Offline

 

#14 2011-08-17 11:06:08

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: AI Scripting?

Thanks for trying to help murphofly, but it is okay, I got the AI scripting down.


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#15 2011-08-27 18:49:16

a1130
Scratcher
Registered: 2009-08-27
Posts: 500+

Re: AI Scripting?

Let's see, AI's are different in different games. But even the least intelligent AIs have the same needs as more intelligent and complicated ones:
1. It has to react to certain things that happen in the game, similar to what Harakou pointed out.
2. A good AI is not unbeatable. For example, if you made an AI in a Pong game, you would NOT do:

Code:

{when flag clicked}
[forever]
[go to [[(y position) of (Ball)]]
[end]

but rather have it be inaccurate by doing something like:

Code:

[go to [[((y position) of (Ball))] + (pick random (-2) to (2)]

to make it more realistic.

AIs in different games are all a little different. If you're making a Super Smash Bros game, try to set a few scripts that make it, let's say, attack (but pick a random move each time) when the human is in front of it or move (randomly) when someone tries to attack it. (This was said by Harakou too, I believe.) And, you could add a script that could make it try to regain it's "balance" when it falls off the platform. Good luck  smile

Last edited by a1130 (2011-08-27 18:50:00)

Offline

 

Board footer