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

#1 2010-04-28 12:43:13

Ziggy215
Scratcher
Registered: 2010-04-28
Posts: 9

How do I make A.I. Opponents in a fighting game?

I need the answer as I am making a sereies of games called Stick Fighter, and I am stuck on Stick Fighter Acadamey trying to figure out how to make A.I. opponents.

Offline

 

#2 2010-04-28 15:02:27

AmoebaMan
Scratcher
Registered: 2009-01-26
Posts: 500+

Re: How do I make A.I. Opponents in a fighting game?

hmmmmm, well, first of all, don't call them A.I.s.  not unless you want to get ridiculed by hardcore programmers.  an aritficial intelligence is impossible to create because you would need an infinate number of "if" clauses to denote all the possible actions.

but beyond that, the best (and only) way is to make a series of extremely specific "if" statements that define what the CPU player should do in every possible scenario.  For instance, you could make it distance based.  If the sprite is far away, program it to walk closer.  if it is within a certain range, you could make it use a certain attack.  the more of these statements you have, the more advanced your CPU will be.

and dont worry if you get stuck.  these things are so difficult to make that I usually just don't even bother.  usually the result is not worth the work.  but dont' let that discourage you from trying.


http://i942.photobucket.com/albums/ad269/RyanScathe/AmoebaMan.png

Offline

 

#3 2010-04-28 15:07:30

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How do I make A.I. Opponents in a fighting game?

AmoebaMan wrote:

hmmmmm, well, first of all, don't call them A.I.s.  not unless you want to get ridiculed by hardcore programmers.  an aritficial intelligence is impossible to create because you would need an infinate number of "if" clauses to denote all the possible actions..

Not infinite, in a simple game there'd only be around 50 possible scenarios (unless you're going with pixel-perfect AI).

Well, if you want them to be like the player, make them do the same things, but instead of if a key is pressed, make it an if (something), for example if the distance to player is less than 30 attack.


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#4 2010-04-28 15:11:13

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: How do I make A.I. Opponents in a fighting game?

AmoebaMan wrote:

hmmmmm, well, first of all, don't call them A.I.s.  not unless you want to get ridiculed by hardcore programmers.  an aritficial intelligence is impossible to create because you would need an infinate number of "if" clauses to denote all the possible actions.

but beyond that, the best (and only) way is to make a series of extremely specific "if" statements that define what the CPU player should do in every possible scenario.  For instance, you could make it distance based.  If the sprite is far away, program it to walk closer.  if it is within a certain range, you could make it use a certain attack.  the more of these statements you have, the more advanced your CPU will be.

and dont worry if you get stuck.  these things are so difficult to make that I usually just don't even bother.  usually the result is not worth the work.  but dont' let that discourage you from trying.

All AI means is artificial intelligence. That doesn't mean it has to be very intelligent at all, it just has to react to the situation
(At least to my understanding of it)


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#5 2010-04-28 15:21:08

AmoebaMan
Scratcher
Registered: 2009-01-26
Posts: 500+

Re: How do I make A.I. Opponents in a fighting game?

juststickman wrote:

AmoebaMan wrote:

hmmmmm, well, first of all, don't call them A.I.s.  not unless you want to get ridiculed by hardcore programmers.  an aritficial intelligence is impossible to create because you would need an infinate number of "if" clauses to denote all the possible actions..

Not infinite, in a simple game there'd only be around 50 possible scenarios (unless you're going with pixel-perfect AI).

Well, if you want them to be like the player, make them do the same things, but instead of if a key is pressed, make it an if (something), for example if the distance to player is less than 30 attack.

an AI means an aritficial intelligence.  that means a computer that can think like a human.  bottom line: impossible

demosthenes wrote:

All AI means is artificial intelligence. That doesn't mean it has to be very intelligent at all, it just has to react to the situation
(At least to my understanding of it)

as above: the concept of artificial intelligence refers to a computer with the capabilities of a human.  and also, why call it an intelligence if it isn't intelligent?  the proper term is CPU (central processing unit) behavioral replicant.

Last edited by AmoebaMan (2010-04-28 15:23:29)


http://i942.photobucket.com/albums/ad269/RyanScathe/AmoebaMan.png

Offline

 

#6 2010-04-28 15:27:01

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: How do I make A.I. Opponents in a fighting game?

AmoebaMan wrote:

juststickman wrote:

AmoebaMan wrote:

hmmmmm, well, first of all, don't call them A.I.s.  not unless you want to get ridiculed by hardcore programmers.  an aritficial intelligence is impossible to create because you would need an infinate number of "if" clauses to denote all the possible actions..

Not infinite, in a simple game there'd only be around 50 possible scenarios (unless you're going with pixel-perfect AI).

Well, if you want them to be like the player, make them do the same things, but instead of if a key is pressed, make it an if (something), for example if the distance to player is less than 30 attack.

an AI means an aritficial intelligence.  that means a computer that can think like a human.  bottom line: impossible

demosthenes wrote:

All AI means is artificial intelligence. That doesn't mean it has to be very intelligent at all, it just has to react to the situation
(At least to my understanding of it)

as above: the concept of artificial intelligence refers to a computer with the capabilities of a human.  and also, why call it an intelligence if it isn't intelligent?  the proper term is CPU (central processing unit) behavioral replicant.

Ais don't have to duplicate the intelligence of a human. All they have to do is to react  to some to some degree to situations. Even if they're really dumb they fall under the umbrella of AI.


And to respond to your comment about human-like AI being "impossible" I disagree. It is certainly possible. How hard can it be to duplicate a human brain, or even exceed it?

Last edited by demosthenes (2010-04-28 15:27:08)


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#7 2010-04-28 15:35:23

Ziggy215
Scratcher
Registered: 2010-04-28
Posts: 9

Re: How do I make A.I. Opponents in a fighting game?

Thanks you guys, but I was kinda looking for the basis of programming it, I've already made the attack routine and possible decisions, But I haven't figured out how to get the "life" sytem working. Any Help?

Offline

 

#8 2010-04-28 15:35:59

midnightleopard
Scratcher
Registered: 2007-09-13
Posts: 1000+

Re: How do I make A.I. Opponents in a fighting game?

make a variable that changes to random stuff and everytime it get's to a certain number have it do something


http://pwp.wizards.com/5103673563/Scorecards/Landscape.png

Offline

 

#9 2010-04-28 15:38:50

AmoebaMan
Scratcher
Registered: 2009-01-26
Posts: 500+

Re: How do I make A.I. Opponents in a fighting game?

midnightleopard wrote:

make a variable that changes to random stuff and everytime it get's to a certain number have it do something

ummmmmmmmm...

that would never give you even halfway decent results.  you'd just have your CPU spazzing out in the middle of the arena while you sit back and watch.


http://i942.photobucket.com/albums/ad269/RyanScathe/AmoebaMan.png

Offline

 

#10 2010-04-28 15:39:17

Ziggy215
Scratcher
Registered: 2010-04-28
Posts: 9

Re: How do I make A.I. Opponents in a fighting game?

But I've already set up the life system, but when I attack it just takes away my life not the opponents.

Offline

 

#11 2010-04-29 12:02:32

Seefat
Scratcher
Registered: 2009-11-19
Posts: 18

Re: How do I make A.I. Opponents in a fighting game?

You can also make it variable based. Let us name it 'Movement' Just program it to do things like if Movement is 1 then go closer. If movement is 2 then meve further. If movement is 3 then attack etc. The movement is the most sensitive in this case. You have no room for Bugs. I have experience in this types of games. One bug can destroy the whole project. The enemy's scripts can be like this: If distance to Player is less than 20, then set movement to 3. If the distance is more than 100 than set movement to 1. The most and greatest advantage in scratch in creating these types of games is that many types of game engine depend on collision boxes which are set far apart from the players but in scratch, if the fist or ankle doesn't touch the other player than there will be no damage. In other game engines, there is no necessary to touch each other. Just touch the collision boxes. The second problem you say it takes your HP not your Opponents. Believe me; i Encountered the same problem. I also have a solution. Let us consider: C=Costume
C 1 is the stance of the player and C2 is the punching costume of the sprite
then program like this
Forever if [(C=2) and pressing 'Key' and touching enemy ]
Then Change Enemy HP by -5
Tell me if you need any more help.

Offline

 

#12 2010-04-29 12:13:03

Seefat
Scratcher
Registered: 2009-11-19
Posts: 18

Re: How do I make A.I. Opponents in a fighting game?

Oh and remember, I have a ton of different punching and kicking costumes each roughly 2 and 3 KB but a lot can cause a lot. A muted project without any sound can still be over 2MB. Dont cross the uploading limit.

Offline

 

#13 2010-04-29 12:18:05

AmoebaMan
Scratcher
Registered: 2009-01-26
Posts: 500+

Re: How do I make A.I. Opponents in a fighting game?

Ziggy215 wrote:

But I've already set up the life system, but when I attack it just takes away my life not the opponents.

well, then you need a variable to determine who is currently attacking.

if you make two basic variables, you could fix this.

<{ player attacking? }>
<{ cpu attacking? }>

then what you do is insert these commands before and after the attack scripts:

<set{ cpu attacking? }to( true )>

and after,

<set{ cpu attacking? }to( false )>

then for your damage detector, you will get

<if  <<touching[ cpu ]><  <and>  ><( <{ cpu attacking? }><=>true )>> >
<change{ health }by( -1 )>
<end>


http://i942.photobucket.com/albums/ad269/RyanScathe/AmoebaMan.png

Offline

 

#14 2010-04-29 12:20:55

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: How do I make A.I. Opponents in a fighting game?

http://scratch.mit.edu/forums/viewtopic.php?pid=15790#p15790


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#15 2010-05-01 06:08:45

Seefat
Scratcher
Registered: 2009-11-19
Posts: 18

Re: How do I make A.I. Opponents in a fighting game?

Just create two individual variables namely player hp and enemy hp

Offline

 

#16 2010-05-01 16:09:17

Ziggy215
Scratcher
Registered: 2010-04-28
Posts: 9

Re: How do I make A.I. Opponents in a fighting game?

thanks a lot you guys

Offline

 

#17 2010-05-01 16:30:19

Ziggy215
Scratcher
Registered: 2010-04-28
Posts: 9

Re: How do I make A.I. Opponents in a fighting game?

where true????!!!

Offline

 

#18 2010-05-02 06:48:33

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: How do I make A.I. Opponents in a fighting game?

AmoebaMan wrote:

hmmmmm, well, first of all, don't call them A.I.s.  not unless you want to get ridiculed by hardcore programmers.  an aritficial intelligence is impossible to create because you would need an infinate number of "if" clauses to denote all the possible actions.

but beyond that, the best (and only) way is to make a series of extremely specific "if" statements that define what the CPU player should do in every possible scenario.  For instance, you could make it distance based.  If the sprite is far away, program it to walk closer.  if it is within a certain range, you could make it use a certain attack.  the more of these statements you have, the more advanced your CPU will be.

and dont worry if you get stuck.  these things are so difficult to make that I usually just don't even bother.  usually the result is not worth the work.  but dont' let that discourage you from trying.

Actually, because atoms can be in superposition states (all possible states at once) a quantum computer can make true AI.  But you are right.  Do not say AI because it will get you into a conversation with all those hardcore gamers who make games for a living with flash and java etc.

Offline

 

#19 2010-05-12 14:59:17

AmoebaMan
Scratcher
Registered: 2009-01-26
Posts: 500+

Re: How do I make A.I. Opponents in a fighting game?

maxskywalker wrote:

AmoebaMan wrote:

hmmmmm, well, first of all, don't call them A.I.s.  not unless you want to get ridiculed by hardcore programmers.  an aritficial intelligence is impossible to create because you would need an infinate number of "if" clauses to denote all the possible actions.

but beyond that, the best (and only) way is to make a series of extremely specific "if" statements that define what the CPU player should do in every possible scenario.  For instance, you could make it distance based.  If the sprite is far away, program it to walk closer.  if it is within a certain range, you could make it use a certain attack.  the more of these statements you have, the more advanced your CPU will be.

and dont worry if you get stuck.  these things are so difficult to make that I usually just don't even bother.  usually the result is not worth the work.  but dont' let that discourage you from trying.

Actually, because atoms can be in superposition states (all possible states at once) a quantum computer can make true AI.  But you are right.  Do not say AI because it will get you into a conversation with all those hardcore gamers who make games for a living with flash and java etc.

that's not hardcore gaming.  that's just a fact.  and i'm not sure what a quantum computer is, so I guess I can't pass judgement on it.


http://i942.photobucket.com/albums/ad269/RyanScathe/AmoebaMan.png

Offline

 

#20 2010-05-25 16:04:35

Niewiem33
Scratcher
Registered: 2010-05-08
Posts: 2

Re: How do I make A.I. Opponents in a fighting game?

Ok, noaw im really confused about how to make a stick fighting game. I tried something on the lines of  <if><touching[ ssprite 2
                      <change{ enemy hp }by( -1

but that kinda didnt work cuz it was too easy so how do you make it that when punched it takes away all teh health??

Last edited by Niewiem33 (2010-05-25 16:05:32)

Offline

 

#21 2010-05-25 16:18:52

TheGameMaster1231
Scratcher
Registered: 2009-07-24
Posts: 1000+

Re: How do I make A.I. Opponents in a fighting game?

Niewiem33 wrote:

Ok, noaw im really confused about how to make a stick fighting game. I tried something on the lines of  <if><touching[ ssprite 2
                      <change{ enemy hp }by( -1

but that kinda didnt work cuz it was too easy so how do you make it that when punched it takes away all teh health??

You Use:
[blocks]<if><touching[ ssprite 2
<set{ enemy hp  }to( 0
<end>[/blocks]

And It Should Take Away All The HP.  smile

Last edited by TheGameMaster1231 (2010-05-25 16:19:26)

Offline

 

#22 2010-05-25 16:31:24

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

Re: How do I make A.I. Opponents in a fighting game?

I tend to use a seperate variable which reports wheather the player is attacking, or the ennemy is attacking, thus if if you set attacking to true, and he touches the enemy, it lowers the enemys health, and vice versa for the enemy.


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

 

#23 2010-06-13 21:55:43

testrgoogillion
Scratcher
Registered: 2010-05-07
Posts: 8

Re: How do I make A.I. Opponents in a fighting game?

LISTEN!! Advanced programmers use a tool called a "finite state machine". It basically decides what the opponent does at what time. I recommend using the block "broadcast ____ and wait" for this, and have if blocks around those. Like, if enemy is close enough to player and enemy's health is below half, use a strong attack. (of course, you can randomize attacks with a probability variable.)

Offline

 

#24 2010-06-14 02:00:25

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: How do I make A.I. Opponents in a fighting game?

demosthenes wrote:

AmoebaMan wrote:

juststickman wrote:


Not infinite, in a simple game there'd only be around 50 possible scenarios (unless you're going with pixel-perfect AI).

Well, if you want them to be like the player, make them do the same things, but instead of if a key is pressed, make it an if (something), for example if the distance to player is less than 30 attack.

an AI means an aritficial intelligence.  that means a computer that can think like a human.  bottom line: impossible

demosthenes wrote:

All AI means is artificial intelligence. That doesn't mean it has to be very intelligent at all, it just has to react to the situation
(At least to my understanding of it)

as above: the concept of artificial intelligence refers to a computer with the capabilities of a human.  and also, why call it an intelligence if it isn't intelligent?  the proper term is CPU (central processing unit) behavioral replicant.

Ais don't have to duplicate the intelligence of a human. All they have to do is to react  to some to some degree to situations. Even if they're really dumb they fall under the umbrella of AI.


And to respond to your comment about human-like AI being "impossible" I disagree. It is certainly possible. How hard can it be to duplicate a human brain, or even exceed it?

Not sure if this is necessary or not, but humans learn based on trial and error, and from what they're told. If you were to make a list of, say "BAD" and "GOOD" to where the A.I. would go towards the GOOD and avoid the BAD. Once they come in contact with an object, they would make a judgement, and it may take a longer or shorter time for the judgement to be made based on the effect of it. Say you learn to ride a bike. You have fun, right? But you fall off one day. Oh noes. But you're still gonna do it, right? The fun overrides the pain, therefore a Bike would be on your "GOOD" list.

Therefore, I'd have to say an A.I. is very, very possible. You could even apply this in your game, although giving it further knowledge already. If it's barely damaged by the attack, add to low caution. It would just move further away. A high caution attack would be straight up Jumping for your life. ...Maybe a bit of an over-exaggeration, but you get my point. That's how the human mind works, in my opinion.

Offline

 

#25 2010-08-11 21:30:32

Flublusken3416
Scratcher
Registered: 2010-04-25
Posts: 3

Re: How do I make A.I. Opponents in a fighting game?

<set{Epic Fail}to(1

That Was An Epic Fail

Offline

 

Board footer