Ai for strategies games

Started by
14 comments, last by Sadness 24 years, 4 months ago
I believe the only time an FuSM fires a rule randomly is when two or more competing rules have equal weighting and there is no way to determine a better rule heuristically.

Take this example for determining which lane of a road for a car to be in, ripped directly from my code, so somewhat messy.

if(NAV_GetState(car->pilot,NAV_ISPERP))
{
DoubleSwitchLanesWeight = 0.0f; // The higher this is the less likely a car is to try to change two lanes at once
laneWeightThreshold = 150.0f; // The lower this is the more likely a car is to slow behind other traffic
StickToLaneWeight = 20.0f; // The higher this is the more likely a car is to choose it's current lane
SpeedWeightDivider = 1.0f; // The higher this is the less likely a pilot is to change lane for speed
FlightMultiplier = 0.0f; // The higher this is the less likely a pilot is to damage other cars/themselves to get into a lane
OppositeDirectionWeight = -200.0f; // The higher this is the less likely a car will take a lane going in the opposite direction
SideWalkWeight = -200.0f; // The higher this is the less likely a car will use a sidewalk
}
else
{
DoubleSwitchLanesWeight = 30.0f; // The higher this is the less likely a car is to try to change two lanes at once
laneWeightThreshold = 50.0f; //50 // The lower this is the more likely a car is to slow behind other traffic
StickToLaneWeight = 100.0f; //75 // The higher this is the more likely a car is to choose it's current lane
SpeedWeightDivider = 2.0f - car->pilot->agro; // The higher this is the less likely a pilot is to change lane for speed
FlightMultiplier = 1.0f; // The higher this is the less likely a pilot is to damage other cars/themselves to get into a lane
OppositeDirectionWeight = -2000.0f; // The higher this is the less likely a car will take a lane going in the opposite direction
SideWalkWeight = -2000.0f; // The higher this is the less likely a car will use a sidewalk
}

The first instance is for a getaway driver, the second is for a normal car trying to drive legally.

These values are used in a series of computations to determine the following weights

totalWeightFromLane
which is the sum of
weightFromAlreadyBeingInLane
weightFromNextCorner
weightFromLaneDistance
weightFromLaneDisappearing
weightFromForwardObstacle
weightFromRearObstacle weightFromCurveObstacle
weightFromBeingStuck
weightFromLaneBeingIllegal

Each of which represent different factors in driving.

The weights are totalled up and the car switches to the lane with the new highest value.

As the values are all floats and there are so many heuristics involved, in the unlikely event of a tie (I don't think I've ever had one) it is pretty unimportant which lane the car ends up in.

No randomness but certainly not what you would consider an FSM.

The fuzziness comes from an inability for us to see the logic, not the lack of logic itself.

MikeD

Advertisement
As I think I've mentioned, I'm not a working professional. However, what you've written is a finite state machine based on the weights of the lanes, with transitions defined entirely in terms of maximizing lane-state value, ie nextstate = max(states, params)

As I understand it, true fuzzy logic assigns truth values which lie between 1.0 and 0.0. Hence, as it becomes more appropriate for a particular state to be observed to be true, the likelihood of that state being observed to be true increases. However, the actual state is never simply one or another, but several at once. Hence, a truly fuzzy SM will fire a biased-randomly selected rule. Otherwise it would be fairly limited in one of its best game-related applications - providing different outputs to the same input.

Your code is fuzzy in terms of some variables, but it's not fuzzy in terms of lane weights (which can be internally determined). Whether fuzzy and prop logic are truly equivalent is, as far as I know, still an open question.

Anyway,
I am just a student.

signing off,
mikey

Thought I would add a bit and try clarify a few remarks:

Formally, Fuzzy Logic is an extension of Propositional Logic that allows propositions to have truth values [0..1]. It uses the min function to approximate the 'and' of propositional logic and the 'max' function to approximate the 'or' function of propositional logic ... etc. From my perspective, the FuSM seems to follow the general idea of Fuzzy Logic without any of the formal structure. This seems to be good since there are many problems with Fuzzy Logic, but also bad since there are no formal rules to follow - the structure of each FuSM test must be thought up with little reuse.

If you start talking about random FSM's, then you have an NFA (Nondeterministic Finite Automaton) where alternatives are chosen completely at random or a Markov Model where each alternative has a probability and each transition is chosen stochastically, relative to that probability. This is closest to what mikey was describing, I think.

Markov Models are commonly used for modelling animal (or human) behaviour and in the design of 'rational agent' AI, or Natural Language Processing. They may or may not be necessary for a game system, but because the probability of transitions can be easily parametized or learned from training data(Hidden Markov Models or HMM's), it could
be a valuable tool.

Rob

Just thought I'd mention this: The eval kit IS available now (http://www.array.dk)

/Niels

<b>/NJ</b>
Well... i have some problem to figured out a way for making an AI, I dont know if some peoples here know the Koei's games like Romance of the 3 kingdom. I want to make somethings like that but ... i dont really know how

my main idea is to make some rulers doing dyplomacy with some players and making war with others. Some rulers would be more warlike, other might be peacefull, but i want to make them change there "minds" because of some players actions. Like making the rulers#1 attacking a player with the rulers#2

i know this is possibly. but how

-----------------------Happiness in slavery !-----------------------
Rob, thanks for clearing thsoe precise definitions up, it's been a while since I've been a student and my AI vocabulary has gone a touch *cough* rusty.
In terms of game AI I can honestly say I've never actually used an FuSM or an NFA. The majority of the heuristics I use are comparable to each other and thusly use a -inf to +inf scaling (normally limited to the +/-10000 level).
Generally, I think reducing levels to truth values is rarely a necessity in games and normally kept for academia. I also find using bipolar systems to be a lot better than binary.

Mike

This topic is closed to new replies.

Advertisement