YesNoOk
avatar

Easy, Quick A.I. Codings (Read 7426 times)

Started by GoldingCircle, October 11, 2011, 10:11:36 pm
Share this topic:
Easy, Quick A.I. Codings
#1  October 11, 2011, 10:11:36 pm
  • **
  • "GrayCircle will once be the greatest warrior"
    • i.imgur.com/MdGQY.gif
Some people want to put simple A.I codes for normal, running and special states, etc. So instead of typing this:
Code:
;light punch
[State -1, AI light punch]
type = ChangeState
triggerall = var(25) = 1
triggerall = random <= 400
triggerall = StateType != A
triggerall = Movetype != H
triggerall = p2bodydist x <= 30
trigger1 = ctrl = 1
value = 200
You could just place it right next to the command:
Code:
; Stand Light Punch
[State -1, Stand Light Punch]
type = ChangeState
value = 200
triggerall = command = "a"|(var(25)= 1 && random <= 400 && p2bodydist x <= 30)
triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl
More easier and simpler, eh. Have fun!  :sugoi:
"GrayCircle will surpass ever hero one day!"

My Local Name: Fighting Toys Freak.
Re: Easy, Quick A.I. Codings
#2  October 12, 2011, 12:27:38 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Not really valid due to the fact that decent AI uses a lot more than what you have there. You have a string limit of 256 characters and allowing for power, p2dist, various levels of combo functionality and all sorts of other things make this a non-viable solution.

Might work for 1-2 things. Go and look at some AI for a super, this won't work.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Easy, Quick A.I. Codings
#3  October 12, 2011, 02:32:01 am
  • **
  • "GrayCircle will once be the greatest warrior"
    • i.imgur.com/MdGQY.gif
You want to fix your reply, I said this before on top of the page:
Quote
Some people want to put simple A.I codes for normal, running and special states
I know that already, Cyanide! This tutorial is only for establishing simple codes for simple moves.
"GrayCircle will surpass ever hero one day!"

My Local Name: Fighting Toys Freak.
Re: Easy, Quick A.I. Codings
#4  October 21, 2011, 01:28:58 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
The idea is good, the execution not that much.

In the example you posted, I'd go with this :

Code:
[State -1, AI light punch]
type = ChangeState
triggerall = statetype = S
triggerall = ctrl
trigger1 = var(25)=0
trigger1 = command = "a"
trigger1 = command != "holddown"
trigger2 = var(25) = 1
trigger2 = random <= 400
trigger2 = Movetype != H
trigger2 = p2bodydist x <= 30
value = 200
If the move can be used in combos, edit the triggerall line for ctrl like this :
Triggerall=ctrl || (Stateno=x && movecontact>0) || (...)

In general, put the conditions when the move can be used in the triggerall lines, add when you want the player to use it in trigger1 (usually commands and the AI variable being on 0), and when you want the AI to use it as trigger2 lines.
Also, random<400 is far too high number and also ignores the difficulty level setting, but that is not the point of this thread.

In your version, the move will be used when the AI conditions are all false, but the inbuilt AI happens to press the a button, which is wrong. It will also be unable to use the attack when it should, if the inbuilt AI pressed the down button.

In my experience, this kind of coding works for most attacks, with the only exception being if there are too many combo triggers to conveniently list on the ctrl line, but that's rare because you can use an interval reference in those cases by setting up your state numbers well. (for example, you can use (Stateno=[200,230] && movecontact) if you put all moves that can be comboed from into the 200-230 interval.)

Last Edit: October 21, 2011, 01:32:40 am by Seravy
Re: Easy, Quick A.I. Codings
#5  October 21, 2011, 05:03:34 am
  • ******
  • [E]
    • Mexico
I would not code the ai like that at all.

first

Code:
[State -1, AI light punch]
type = ChangeState
triggerall = statetype = S
triggerall = ctrl
trigger1 = var(25)=0
trigger1 = command = "a"
trigger1 = command != "holddown"
trigger2 = var(25) = 1
trigger2 = random <= 400
trigger2 = Movetype != H
trigger2 = p2bodydist x <= 30
value = 200

changed to :
Code:
[State -1, AI light punch]
type = ChangeState
triggerall = var(25)=0
triggerall = command = "a"
triggerall = command != "holddown"

trigger1 = statetype = S
trigger1 = ctrl
value = 200

[State -1, AI light punch]
type = ChangeState
triggerall = var(25) = 1
triggerall = random <= 400
triggerall = Movetype != H
triggerall = p2bodydist x <= 30

trigger1 = statetype = S
trigger1 = ctrl
value = 200

yeah, I split it in two, one for the ai and one for the player; teh palyer's code comes firt then I just add the few ai states; code footprint is a small prize to pay to hvae higher control over it.

note that I use a helper/variable for the stuff in the triggerall for the ai as I can have much more complex code in the helper than I would ever bother putting in the cmd.
Re: Easy, Quick A.I. Codings
#6  October 27, 2011, 02:52:11 am
  • **
  • "GrayCircle will once be the greatest warrior"
    • i.imgur.com/MdGQY.gif
 o_O Huh, it works perfectly though for me! o_O  You can just edit the p2bodydist or add more features the way you want. Its easier and you can put for basic attacks and easy coding moves, just if you have to add like running and jumping, etc. Just letting you know.  ;)
"GrayCircle will surpass ever hero one day!"

My Local Name: Fighting Toys Freak.