AI
New(mob/M)
owner=M
if(ismob(owner))
spawn() Loop()
..()
var
list
targets=list()
mob
owner
target
proc
Loop()
while(ismob(src.owner))
// world<<output("Loop()","battle")
spawn() Identify_Action()
sleep(1)
del(src)
Locate_Targets()
if(ismob(src.owner))
for(var/mob/M in oview(world.view,owner))
targets+=M
for(var/mob/M in targets)
if(!target)
if(ismob(M))
target=M
if(ismob(M)&&ismob(target))
if(M.pl>target.pl)
target=M
Identify_Action()
if(ismob(target))
switch(target.icon_state)
if(FLIGHT)
if(ismob(owner))
// owner.icon_state=FLIGHT
// owner.flight=1
spawn() owner.BattleFlight()
owner.move_towards(target)
if(POWERUP)
if(ismob(owner))
// owner.icon_state=FLIGHT
spawn() owner.PowerUp()
else
spawn()
Locate_Targets()
ID:1953144
![]() Oct 1 2015, 10:58 pm
|
|
As I start working more and more on the design of my game, the battle system is the most critical part of it all. As are monsters. I'm currently in the process of adding AI to it. I'm using a "Street Fighter" as a reference to help people understand what I'm looking to accomplish here. Anyhow, I'm just starting to create the AI and need it to function and act like a human would in a battle. I kinda started with this to get it going. What are some of the ways and methods you all have come up with for making an interesting AI fight using side scroller battle?
|
I haven't spent a whole lot of time creating advanced ai, but I really like where Rushnut is going with this.
|
I usually take simpler approaches where I implement a series of options, and have them choose the best one based off the situation. I like where Rushnet went there though, because that could take what I do and potentially simplify and optimize the code while not adding much more complication.
The only thing about his is when you get into character or race specific stuff. You'll have to have some overrides in for that. I'd say make a few different enemy types, each using the same AI procs, but for the ones with more specific attacks just alter their version of the procs to have skill calls at the right points, and more skill handling for them specifically in the skill proc. |
It sounds like Rushnut may be alluding to, without even realizing, a very simple approach to Markov chains.
|
Markov Chains:
a stochastic model describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event. |
To make it simpler, a Markov chain is a system that is a discrete function of some variable t (e.g., t can only take the values 1, 2, 3, ...) whose future state is dependent only on the current state. For example, consider the following.
MarkovChain At each point, the MarkovChain object will depend only on its current state, with its past states having no effect. Here is a Javascript implementation of the above. |
So... What's the difference between a state machine and a Markov Chain? Typically, when talking about AI we tend to describe behavior in state machines because that tends to be what works best for building modular, dynamic behavior for entities that have to adapt their behavior over time. Each state is a discrete set of rules which determine conditions for moving between substate nodes and determining the outcome for behaviors when within each node.
|
One way of describing a Markov chain is a state machine whose inputs are random variables drawn from some probability distribution. In other words, you can model them both very similarly.
|
Hmm...I like this thought, I shall try this MARKOV Chain and see what's up. Thanks gentlemen.
|
For example, in your snippet there's an if(POWERUP). I assume this is a state where the player isn't moving, this would be an ideal situation to smack them with something, wouldn't it? So I'd add 3 to the weight "attack_heavy".
I'd continue this theme throughout the entire system of your AI and at the end, roll a series of picks/rands based off the weights (Narrow it down more based off difficulty to best case scenario) and then execute whatever comes out on top. So an example of weights would be
weights = list("attack_heavy" = 2.5, "attack_light" = 5.5, "retreat" = 1.2, "powerup" = 0.8)
Turn those numbers into a percentage out of 100 and run a quick check, pick the best choice and have your AI execute. Simple and effective in my experiments!