YesNoOk
avatar

AI Activation Code (Read 57528 times)

Started by Winane, April 24, 2004, 03:20:04 am
Share this topic:
Re: AI Activation Code
#41  February 01, 2006, 04:19:47 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Blargity blargh.  In Mugen 04.14.2001, commands entered during a hitpause persist for one tick beyond the end of the hitpause.  But I've just discovered that in Mugen 11.01.2001+, commands entered during a hitpause persist for one plus the command's buffer.time beyond the end of the hitpause.  My apologies, I have no idea how I could have overlooked that.  >_<  Thanks to Sepp for help identifying that issue!

I don't have time to fix the helper method accordingly right away, but I've gone ahead and fixed the XOR method.  Both archives updated.

For the 2 variable/2 helper version:
Code:
[State 9743, HitPauseTime]
type = VarSet
trigger1 = !(Parent,HitPauseTime)
trigger2 = GameTime > Parent,var(57)
var(1) = Parent,HitPauseTime
changed to
Code:
[State 9743, fiXOR]
type = VarAdd
trigger1 = !(Parent,HitPauseTime)
trigger1 = var(1) > 0
var(1) = -1

[State 9743, fuXOR]
type = VarSet
trigger1 = Parent,HitPauseTime
trigger1 = Parent,var(57) < GameTime-1
var(1) = 2; Set this to your maximum command buffer.time + 1.  If you haven't
; set command.buffer.time nor buffer.time for any commands, then set this to 2.
IgnoreHitPause = 1


For the 3 variable/1 helper version:
Code:
; This controller must be placed here, after the above XOR VarSet
; controller and before the below GameTime VarSet controller.
[State -3, fiXOR]
type = VarSet
trigger1 = !HitPauseTime
trigger2 = var(57) < GameTime-1
var(56) = HitPauseTime
IgnoreHitPause = 1
changed to
Code:
; These next two controllers must be placed here, after the above XOR
; VarSet controller and before the below GameTime VarSet controller.
[State -3, fiXOR]
type = VarAdd
trigger1 = var(56) > 0
var(56) = -1

[State -3, fuXOR]
type = VarSet
trigger1 = HitPauseTime
trigger1 = var(57) < GameTime-1
var(56) = 2; Set this to your maximum command buffer.time + 1.  If you haven't
; set command.buffer.time nor buffer.time for any commands, then set this to 2.
IgnoreHitPause = 1

I haven't technically tested the update yet, but it ought to work properly.
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Last Edit: February 01, 2006, 04:32:43 pm by :nink:
Re: Yes, I know I could have just edited the previous post. :P
#42  February 01, 2006, 05:51:56 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Little tweak:

Instead of setting var(56)/helper(9743),var(1) to each specific character's maximum command buffer time + 1, I decided to just set it to the maximum possible buffer time + 1.  That way, there's no need to worry about people like Sepp going and altering the buffer settings to their liking.  And while a half-second might seem like a bit much of a delay, that delay should rarely be incurred.

So now the relevant controllers look like this (for 2 var version):
Code:
[State 9743, fuXOR]
type = VarSet
trigger1 = Parent,HitPauseTime
trigger1 = Parent,var(57) < GameTime-1
var(1) = 31
IgnoreHitPause = 1
and this (for 3 var version):
Code:
[State -3, fuXOR]
type = VarSet
trigger1 = HitPauseTime
trigger1 = var(57) < GameTime-1
var(56) = 31
IgnoreHitPause = 1

Both archives updated again.


Edit:  Whoops, yep, thanks Kung Fu Man!  Link fixed.
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Last Edit: February 01, 2006, 06:03:56 pm by :nink:
Re: AI Activation Code
#43  February 03, 2006, 01:54:27 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Whoops yet again; in my haste, I overlooked a couple mistakes in that code.  So, archives updated:

In the 2 var version, changed this:
Code:
[State 9743, fuXOR]
type = VarSet
trigger1 = Parent,HitPauseTime
trigger1 = Parent,var(57) < GameTime-1
var(1) = 31
IgnoreHitPause = 1
to this:
Code:
[State 9743, fuXOR]
type = VarSet
trigger1 = Parent,var(57) < GameTime
var(1) = 31
IgnoreHitPause = 1


In the 3 var version, changed this:
Code:
[State -3, fuXOR]
type = VarSet
trigger1 = HitPauseTime
trigger1 = var(57) < GameTime-1
var(56) = 31
IgnoreHitPause = 1
to this:
Code:
[State -3, fuXOR]
type = VarSet
trigger1 = var(57) < GameTime-1
var(56) = 31
IgnoreHitPause = 1

So, that might sometimes significantly decrease the effectiveness of the code, but it's unfortunately necessary in Mugen 11.01.2001+.  Note that when characters receive the opponent's command array in custom hit states, that includes the opponent's buffer.time settings.  So even if your character doesn't use any buffer.time settings greater than 1, var(56) still needs to be set to 31 after custom states in case the opponent does.
(Now, I can't remember offhand whether there's any need to disable the XOR method after pauses/super pauses.  If not, I might make it disabled only after custom states, though I suspect that would require yet another variable slot.  Too lazy to research and think about it right now, though.)
Anyway, the XOR method is probably all done with now.  Expect updates for the helper method soon.

And if anyone out there still only cares about DOS Mugen, you might want to take note that the 2006/1/30 versions of my code are as ideal as my code is going to get for Mugen 04.14.2001.  All subsequent versions will slightly reduce the average quickness of AI activation for the sake of avoiding false positives in Mugen 11.01.2001+, at the expense of maximal speed in 04.14.2001.  If anyone out there wants me to send them the 2006/1/30 code, just send me a PM or something.  Edit:  Partially nevermind, this paragraph only applies to the XOR method (and the humanly-impossible commands method), not the rest of the code.
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Last Edit: February 07, 2006, 04:12:03 am by :nink:
Re: AI Activation Code
#44  February 03, 2006, 09:51:05 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Since the old humanly-impossible commands AI activation method is a bit more convenient (and still more popular) than the XORed commands method, I figured I ought to write up a safe version of it, since all prior versions I've seen occasionally allow false positives (especially in post-DOS Mugen versions).  I've added it to ye old AIcomponents.rar, in the file "CPU-only commands method.txt".  The explanatory text is currently a bit lacking, as I mainly just wanted to get the code out there for now.  I'll tidy up the text later (well, perhaps).
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Re: AI Activation Code
#45  February 07, 2006, 05:43:57 am
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Okay, I believe I've fixed up the helper method.  (Of course, I've thought that about 50 times before...)  Buffer.time issues should be handled properly, now.  It turned out there were actually still a couple flaws in the code with DOS Mugen too, now fixed.  And I added a note about dealing with the button jam issue in training mode, thanks to P.o.t.S.  I've barely tested the updated code outside of the Mugen emulator in my head, but I think it should work.  Both archives have been updated.  Too many little tweaks to list here, so, I trust everyone already using my code has a good text file comparison utility?


(I would no longer call the helper code entirely optimized, but that's really not a significant issue.  I might eventually tweak it just for fun and for the sake of tidiness.  But proper functionality is the highest priority, needless to say, and I was afraid I might accidentally break something in the process of optimizing, and/or might make it more difficult to deal with any more problems, should they ever arise.)


Note that there is another way to deal with the buffer.time + XOR method problem, that would shorten post-custom-state/pause delays.  But, it would be a bit messier, requiring extra processing in a negative state, and requiring more explanation ergo more opportunity for implementation error.  If anyone's interested, let me know, and I'll try to whip up what I had in mind.


Additional note to people who like to oversimplify their code, in case I haven't already mentioned it:
It should be safe to use only the 9741 version or only the 9742 version of the helper state, if, for whatever reason, you'd prefer.  But using only the 9741 version would greatly increase the probability of a false negative in simul team modes when partnered with a character with a compatible CMD, thus requiring the XOR method to provide backup.  And using only the 9742 version would require extra processing for naught (when not partnered with a compatible-CMD character), and would sometimes unnecessarily delay AI activation (when partnered with a non-compatible-CMD character).



Now, to summarize, these are the issues my code tries to deal with properly:
-enemy command array inheritance in custom states
-hitpause command persistency
-pause/superpause command buffering
-command.buffer.time command persistency (11.01.2001+ Mugen only)
-autoturn back/forward reversal
-detection of partner input by KeyCtrl helpers
-various differences between hold commands and non-hold commands
-multiple definitions for command names
-destruction of helpers upon intro interruption
-the fact that DestroySelfs don't terminate processing of the current tick
-optional: training mode dummy button jam etc. issue
-all play modes
-etc?
-interactions between all of the above

So, did I succeed?  That is, are there any flaws in the code that don't deal with the listed issues properly?  And are there any issues that need to be dealt with which I haven't identified yet?
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Last Edit: February 08, 2006, 12:16:36 pm by :nink:
Re: AI Activation Code
#46  March 29, 2006, 10:12:13 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Another update uploaded, in light of the new behavior of player-type helpers.  All I did was add a "!IsHelper" triggerall to all the controllers in States -2 and -3.

Edit:
Ah, I forgot to mention, it is possible (albeit generally a bad idea) for opponents to make your character spawn a player-type helper while in a custom hit state, so I'd suggest leaving the !IsHelper triggers in even if your character doesn't use any player-type helpers.
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Last Edit: April 09, 2006, 02:42:47 pm by Winane
Re: AI Activation Code
#47  December 01, 2006, 02:23:54 am
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Extremely minor update uploaded:
http://www.mugenguild.net/~winane/tutorial/index.html
All I did was change the "Safety" SelfState controller's value from 0 to 5050, in both helper states.  No need to update all your old characters for just that.


By the way, might as well mention that another advantage to using the "Simplifier" controller is that it ought to allow for more convenient adaptation of characters to InfinityCat.  All that should be needed would be to change this:
Quote
[State -2, Simplifier]
type = VarSet
triggerall = !IsHelper
trigger1 = var(58) = 1
trigger2 = var(0):=0
var(0) = 1   ; Another option is to replace 1 with something like MatchNo, if
      ; you want to design your AI to have varying levels of difficulty.
IgnoreHitPause = 1
to something like this:
Quote
[State -2, Simplifier]
type = VarSet
triggerall = !IsHelper
trigger1 = IsAI
trigger2 = var(0):=0
var(0) = 1   ; Another option is to replace 1 with something like MatchNo, if
      ; you want to design your AI to have varying levels of difficulty.
IgnoreHitPause = 1
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Re: AI Activation Code
#48  December 01, 2006, 05:04:03 pm
  • ******
  • [E]
    • Mexico
why would you use the ai code with infinity cat  ???
Re: AI Activation Code
#49  December 01, 2006, 05:30:09 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
more convenient adaptation of characters to InfinityCat.
In other words:  You could just delete my entire code, and do a find/replace all to replace every instance of "var(58)>0"/"var(0)" with "IsAI" (or "IsAI*MatchNo", or whatever), which is what I would recommend doing for any of your own InfCat-only character releases.  But if you happen to have a large collection of other people's Mugen character releases that use my code, and want to quickly update them for use with InfCat, the single-line fix I posted above would be more convenient.  And it's also easier to explain to your users, if you release any characters primarily for Mugen, but decide to include InfCat updating instructions in the readme, or something like that.
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Last Edit: December 01, 2006, 05:33:43 pm by Winane
Re: AI Activation Code
#50  December 02, 2006, 11:55:31 am
  • ******
  • In after lock
    • mugenguild.com/~messatsu/index.html
Quote
Submit your M.U.G.E.N tutorials, tips and tricks, FAQs and so on.
Please post in the InfCat Tips and Tutorials section. ::)


Many people risk their lives everyday by having Mugen.
Re: AI Activation Code
#51  December 14, 2006, 12:32:07 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Would anyone be willing to give this code a try?:
http://www.mugenguild.net/~winane/tutorial/kfm-xor.rar
Just report whether or not you can get it to misbehave in any way.  As usual, this KFM doesn't have any AI, but his AI flag vars are displayed to the clipboard (var(58) and var(0)).  If you know what you're doing, feel free to copy the code over to another character, to make testing more fun.

I made two changes to the XORed commands method, one of which I mentioned above, the other of which I should have thought of years ago but didn't.  The former helps shorten activation delays after custom states.  The latter should prevent activation delays caused by pauses and superpauses.  (The fact that I apparently didn't think of it years ago makes me a little suspicious, which is why I haven't yet added it to the main archive.  So, test plz.)
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Re: AI Activation Code
#52  May 21, 2007, 03:33:12 pm
  • *****
  • Tends to lose track of things a lot. :/
    • www.mugenguild.com/~winane/
Major update uploaded.

1.  Corrected a major error in the simul version of the helper method.  Due to a missing line of code, all that was needed to trigger a false positive was to hold any direction at the very start of RoundState 2.  :sweatdrop:  Many thanks to YO MOMS KNOW ME for finally bringing that to my attention.
2.  Modified a few comments, most significantly the bit about adding additional definitions for the 18 basic command names.  In short:  please don't do it.

Spanish translation coming soon, from LotF.
Still quite busy.

(Yes, I intend to deal with that stuff eventually, but kinda can't just yet, sorry. :/ )
Re: AI Activation Code
#53  May 21, 2007, 07:10:04 pm
  • ****
  • Am I evil?

Sig made by TempesT :)
Re: AI Activation Code
#54  June 11, 2007, 04:22:34 am
  • **
I could do with as much help with AI as possible at the moment.

Chars with stupid difficult AI is ruining the balance of my Mugen.

I need to find out how to disable the AI on chars, or add a line that works withthe difficulty level set in the game.

POTS makes great chars, but they are too good to play against. Just get beaten perfect every time. cant land a light punch even. :S
Re: AI Activation Code
#55  June 11, 2007, 05:57:15 pm
  • **
Hi Winane.
You seem to be the AI man, so please help me

How can i lower a characters custom AI? Is there a tutorial anywhere?

I've searched and have found nothing but other peope asking the same thing.

And then smart arses posting irrelevant comments.

i found one tutorial http://www.mugen-infantry.net/forum/index.php?topic=61699.0

I just noticed that the AI i am trying to lower is your own AI. How can i get rid of it?

No offence, but i am looking for a balanced game. And Karen and Nash are too good. and i want everything to run off the standard AI

Please get back to me

Please help
Last Edit: June 11, 2007, 06:12:55 pm by redlad
Re: AI Activation Code
#56  November 18, 2007, 10:35:52 pm
  • avatar
  • *
I am pretty much brand new to both MUGEN and AI coding. While I think I understand the XOR method, or at least understand what code to put where, I don't understand how to make it work with speciffic moves. In other words, where/how do I get this method to recognize, say, KFM's Strong Palm Thrust?

Similarly, is there something like "A Complete Idiot's Guide to MUGEN AI" floating around out there that lists all commands and values and what they do or how they affect your character?
Re: AI Activation Code
#57  November 20, 2007, 01:03:48 am
  • ***
  • I never really was on your side.
    • www.mugenguild.com/~davidgee
Edit: What follows is a result of bad reading comprehension. --;

In other words, where/how do I get this method to recognize, say, KFM's Strong Palm Thrust?

My best guess as to what you mean is:

Quote
How does my character know that KFM is performing his Strong Palm Thrust so that it can react accordingly?

It's not practical to know what move the other player is doing. You can do this using variables and trigger direction, but your variables would be depleted quickly. What you can know is if they enemy is attacking (enemyNear, MoveType), what their velocity and acceleration components are (or, where they're going), and whatever other information can be obtained using trigger redirection and triggers.

Similarly, is there something like "A Complete Idiot's Guide to MUGEN AI" floating around out there that lists all commands and values and what they do or how they affect your character?

Probably not; maybe I should make one. It would have to include "Exploration of Mugen's Features for Those Who Don't Read the Docs and Find out How KFM Works" as preliminaries, of course. :S As for "listing all commands and values and what they do or how they affect your character," this doesn't make sense, and I have no idea what you might be talking about. The AI activation code does absolutely nothing aside from this:

  • AI activation code allows the programmer to determine whether the player is human- or computer-controlled.

The reason why the code is so convoluted is that it's a hack; Elecbyte never intended for the programmer to be able to make that determination. After that's working, you add your AI on your own using nothing from the AI activation code besides variables.
Last Edit: November 20, 2007, 03:13:35 pm by DavidGee
Re: AI Activation Code
#58  November 20, 2007, 01:41:38 pm
  • avatar
  • *
First of all, thanks for the reply.

In other words, where/how do I get this method to recognize, say, KFM's Strong Palm Thrust?

My best guess as to what you mean is:

Quote
How does my character know that KFM is performing his Strong Palm Thrust so that it can react accordingly?

It's not practical to know what move the other player is doing. You can do this using variables and trigger direction, but your variables would be depleted quickly. What you can know is if they enemy is attacking (enemyNear, MoveType), what their velocity and acceleration components are (or, where they're going), and whatever other information can be obtained using trigger redirection and triggers.
Not exactly. What I meant is that how do you make the XOR code recognize the Palm Thrust as a move it can do? I saw this example in the kfm.cmd file included with the implementation files:
Code:
; [State -1, Haha!]
; type = ChangeState
; trigger1 = var(0) ; (Or use "var(58)>0" if you've chosen not to
;                   ; use the Simplifier variable/controller.)
; trigger1 = ctrl
; trigger1 = StateType = S
; trigger1 = MoveType = I
; trigger1 = P2MoveType = H
; trigger1 = NumEnemy = 1
; trigger1 = Enemy,GetHitVar(HitTime) > 60
; trigger1 = PrevStateNo != 195
; trigger1 = Random < 99
; value = 195
Do I just add the var and random to the existing move info in State -1?

Quote
Similarly, is there something like "A Complete Idiot's Guide to MUGEN AI" floating around out there that lists all commands and values and what they do or how they affect your character?

Probably not; maybe I should make one. It would have to include "Exploration of Mugen's Features for Those Who Don't Read the Docs and Find out How KFM Works" as preliminaries, of course. :S
Modify that to "Those Who've Tried to Read the Docs and Had a Hard Time Understanding Them." Especially since I've found so little about AI itself.

Quote
As for "listing all commands and values and what they do or how they affect your character," this doesn't make sense, and I have no idea what you might be talking about. The AI activation code does absolutely nothing aside from this:

  • AI activation code allows the programmer to determine whether the player is human- or computer-controlled.

The reason why the code is so convoluted is that it's a hack; Elecbyte never intended for the programmer to be able to make that determination. After that's working, you add your AI on your own using nothing from the AI activation code besides variables.
I mean things like movecontact, numproj, statetype, etc. I know a lot of that info can be found in the sctrls file, but not everything has a very detailed explanation or an example of how it's implemented. I'd also like an explanation on how the different trigger numbers work. I think I get it, but I'd like to know for sure.

I guess what I'd really like is sample code on basic things. Blocking (which I've found), basic combos/chain moves (like Iori's Aoi Hana or Rolento's Pipe Twirl), Tech Rolls, etc. I know it's asking a lot, but once I figure this stuff out, I'd be more than happy to contribute to a project like that.


Also, I found the following piece of info rather confusing in the XOR - 3 var.txt file:
Code:
; Here add matching commands for any moves that must never be used randomly
; by the computer, such as suicide moves and super moves, and add the pairs
; to the XOR VarSet controller in State -3.

; If you're desperate to make sure that the AI always gets turned on as soon
; as possible, you can add more equivalents for your own commands here too,
; and add to the XOR VarSet controller's triggers accordingly.  You should
; use button-only commands before using any commands with directional
; components, as the latter apparently doesn't work in Linux Mugen 2002.04.14.
How would I write a command that I wouldn't want the CPU to do in the commands section? Also, does this mean I put all special moves I want the CPU to do here, rather than edit the entries in State -1?
Last Edit: November 20, 2007, 01:48:40 pm by Krendall
Re: AI Activation Code
#59  November 20, 2007, 04:08:10 pm
  • ***
  • I never really was on your side.
    • www.mugenguild.com/~davidgee
Well Winane's file seems pretty explanatory, but I'll try to make a helpful reply this time. :P

The XOR-ed commands method, serving as a backup in case the other methods fail... Reason why this works is that if you have duplicate commands -- two separate commands that consist of the same button press(es) -- a CPU player will execute only one of the commands instead of both simultaneously, whereas a human player would be executing both. I don't think it would make much of a difference to add more commands, but you can. All that's going to happen is that when the CPU player executes one of the commands, custom AI gets activated, provided it wasn't activated already.

1. In the CMD, define the command and its counterpart:

[Command]
name = "QCF_x"
command = ~D, DF, F, x

[Command]
name = "QCF_x2"
command = ~D, DF, F, x

2. In the XOR VarSet controller, add a new trigger for the commands:

[State -3, XOR]
type = VarSet
triggerall = var(58)!=1 && !IsHelper
triggerall = !var(56)
triggerall = var(57) = GameTime-1
;(snipped triggers 1 through 19)
;Add more as desired. (See my notes in the CMD.)
trigger20 = command = "QCF_x" ^^ command = "QCF_x2"
var(58) = 1

The only purpose this serves is to activate your custom AI. To make the AI-activated character do something, you simply use var(0) as the first trigger of a ChangeState controller in the CMD, which is what the "Haha!" example you posted is an example of. Basically, each trigger1 in that sctrl is a condition that must be met for the ChangeState to execute, and every trigger is documented in triggers.html.

I mean things like movecontact, numproj, statetype, etc. I know a lot of that info can be found in the sctrls file, but not everything has a very detailed explanation or an example of how it's implemented. I'd also like an explanation on how the different trigger numbers work. I think I get it, but I'd like to know for sure.

Those are just triggers that are fully explained in Mugen's documentation. As for trigger numbering, maybe this would be helpful, and this for more info.

Last Edit: November 21, 2007, 06:48:27 am by DavidGee
Re: AI Activation Code
#60  November 21, 2007, 04:35:59 am
  • avatar
  • *
Cool. Again, thanks for the info. Hopefully I'll get things to work this time.