Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualNorman Barrows

Posted 27 July 2013 - 01:00 PM


Instead, you should think about the "I" part of AI. A handy mnemonic is "What would I do?" - not just "I" in the sense of an abbreviation for "intelligence", but also "I" as in "me."
 
Think about how you would play the game you're writing an AI for.
 
As ApochPiQ says, this is all AI does, it just plays the game for you.
 
So to write AI, you pretend you're the AI, then just write code to do what you would do.
 
then you test it to see how good your strategy is.
 
and then comes the tweaking and perfecting. eliminating weaknesses in the strategy, adding more code to handle more special cases or handle common cases even better, etc.
 
the natural evolution of this process tends to lead to a hierarchy of expert systems and states. essentially a big decision tree. at each decision point, some branch is taken, defining a "state". 
 
so for example the top level expert system would select targeting planes vs supplies vs production as the overall strategy or "state". lets say it selects "production". so then the production strategy expert system takes over and makes the next lower level decision, and so on, right down to pull the stick back, kick hard left rudder, roll left, full throttle, "gunza! gunza! gunza!".
 
how an expert system at any level actually decides what to do is up to you. you can use stuff like min-max etc. but usually, just playing the game shows you what the AI ought to do, and it seldom requires weirdo complex AI algos.
 
for something like planes vs supply vs production, you might apply rules as follows:
 
1. if any of the 3 strategies can be accomplished much more easily than the others, use it. IE if their air force is almost dead, then try to finish them off. if their factories are almost gone, try to get the few remaining. if their merchant fleet is almost wiped out, go after that as the way to a quick victory.
2. else if they have a lot of planes, go after planes to establish air superiority.
3. else if merchant fleet is almost dead, go after supply.
4. else go after production. going after the enemies means of waging war is usually a very effective strategy.
 
coding up something like this would not be too difficult.
 
you might use some variables such as % left alive for air force, merchant fleet, and factories.
 
then the AI rules above reduce to simple checks like:
 
if (airforce < 10%) attack_planes_AI
else if (fleet < 10% attack_shiping_AI
else if (factories < 10%) attack_production_AI
else if (airforce > 50%) attack_planes_AI
else if (fleet < 33%) attack_shipping_AI
else attack_production_AI
 
the above is an example of what the code for the top level expert system might look like.

#1Norman Barrows

Posted 27 July 2013 - 12:34 PM


Instead, you should think about the "I" part of AI. A handy mnemonic is "What would I do?" - not just "I" in the sense of an abbreviation for "intelligence", but also "I" as in "me."
 
Think about how you would play the game you're writing an AI for.
 
As epoch says, this is all AI does, it just plays the game for you.
 
So to write AI, you pretend you're the AI, then just write code to do what you would do.
 
then you test it to see how good your strategy is.
 
and then comes the tweaking and perfecting. eliminating weaknesses in the strategy, adding more code to handle more special cases or handle common cases even better, etc.
 
the natural evolution of this process tends to lead to a hierarchy of expert systems and states. essentially a big decision tree. at each decision point, some branch is taken, defining a "state". 
 
so for example the top level expert system would select targeting planes vs supplies vs production as the overall strategy or "state". lets say it selects "production". so then the production strategy expert system takes over and makes the next lower level decision, and so on, right down to pull the stick back, kick hard left rudder, roll left, full throttle, "gunza! gunza! gunza!".
 
how an expert system at any level actually decides what to do is up to you. you can use stuff like min-max etc. but usually, just playing the game shows you what the AI ought to do, and it seldom requires weirdo complex AI algos.
 
for something like planes vs supply vs production, you might apply rules as follows:
 
1. if any of the 3 strategies can be accomplished much more easily than the others, use it. IE if their air force is almost dead, then try to finish them off. if their factories are almost gone, try to get the few remaining. if their merchant fleet is almost wiped out, go after that as the way to a quick victory.
2. else if they have a lot of planes, go after planes to establish air superiority.
3. else if merchant fleet is almost dead, go after supply.
4. else go after production. going after the enemies means of waging war is usually a very effective strategy.
 
coding up something like this would not be too difficult.
 
you might use some variables such as % left alive for air force, merchant fleet, and factories.
 
then the AI rules above reduce to simple checks like:
 
if (airforce < 10%) attack_planes_AI
else if (fleet < 10% attack_shiping_AI
else if (factories < 10%) attack_production_AI
else if (airforce > 50%) attack_planes_AI
else if (fleet < 33%) attack_shipping_AI
else attack_production_AI
 
the above is an example of what the code for the top level expert system might look like.

PARTNERS