Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Fri Sep 12, 2003 9:47 pm Post subject:
AI Explanation
Introduction:
If you played this kind of map once, you would probably ask how would an AI act during the game? Players can do a lot of stuff and usually randomly depending on the situation of the game. For instance, if the enemy is building too much attackers and you notice that you are leaking, the tendency is that you build more defenses to leak less of them. How would you do that with AI?
This question looks like to have a hard answer, isn't it? But the answer is that you don't need this. AI is dumb. It means that it plays without care to the behaviour of the enemy player... just trying to make sure that it has a reasonable defense and attack. So, differently from human players, AI tends to do one action per time. This introduction might be confusing, but you will understand what I mean during the explanation below:
AI Settings:
AI Settings is a unique trigger loaded in the initialization that selects the sides of AI players (randomly), give them basic info about the sides, like structures that it needs to build, attackers that it will build, upgrading structures and default values for variables.
AI Initialization:
The AI Player X (1-6) Initialization triggers determines the basic settings of the specific AI player like where will it start building things, and some other custom values for variables that will determine the behaviour of the AI player. This trigger also makes AI builds the basic building that determines the side it uses, and also train the builder. After it's done, it starts the cycle, which will be explained below.
AI Cycle:
In Wintermaul Wars, there are 4 things you can do: Build towers, Upgrade towers, Sell towers and Build Attackers. From these, the basic is build, attack and upgrade. So, AI works in cycles: build, attack and upgrade. Then, it builds again, attacks and upgrades. And keep doing this for the rest of the game.
AI Orders:
In Wintermaul Wars, the game is timed... in each round, the players gain their income and consequently can get more cash and do the actions like build towers, build attackers and upgrade towers. The same can be applied for AI, but since it works on only one action in each round. In this map, this action is the variable AICurrentString[]=. So, if AICurrentString= D1, for example, AI will build defense towers. If the maximum number of defensive rounds for this AI is 1, then next round, AI will build attackers (AICurrentString=A1) or gather cash until it build attackers, if the numbers of rounds per attack is higher than 1. These variables will be explained later... for now, you need to know that what determines what AI will do in the current round is the AICurrentString=.
AI Structure:
AI works in the following way: every round, a trigger mocks AI processor saying what AI should do. The processor determines how it should be done and call its agents to do it. After a tower is built or upgraded, another trigger determines what's next should be done and calls the processor again. The processor rests when all tasks are done before the round begins, because in the next round, the triggers mocks the processor again and it determines how the order from the first trigger should be done and calls it agents, bla bla bla, etc etc...
AI Behaviour Control: AI Player Round Up Triggers
The trigger which mocks the processor is called AI Player X(1 -6) Round Up. This trigger will determine if AI will build defenses, attackers or upgrade towers. It determines the next order from AI checking the following limits:
-> AIMaxDefense: AI max defense is a variable that determines the consecutive ammount of rounds per cycle where AI will build towers.
-> AIMaxOffense: AI Max Offense is the variable that determines how many rounds it takes to an AI attack. If you set it to 2 rounds for example, in the first attacking round, AI will do nothing... just collect the money. In the second round, AI will attack using the cash it collected in the first and second rounds building more attackers than in just 1 round.
-> AIConsecutiveOffense: It determines the ammount of rounds per cycle where AI really build the attackers.
-> AIMaxStructures: It determines the maximum ammount of structures AI player can have (including shrine and the base building).
Changing these values, you can easily mod AI, making it better or worse.
The Processor:
AI Player X(1-6) Processor determines what should be done with the orders that it receives from AICurrentString. The orders can be the following:
-> D1: 1st defensive round. AI will build towers. If it reachs the maximum allowed structures, it will upgrade towers.
-> D2: 2nd defensive round. AI will build towers. If it reachs the maximum allowed structures, it will upgrade towers.
-> D3: 3rd defensive round. AI will build towers. If it reachs the maximum allowed structures, it will upgrade towers.
-> D4: 4th and Final defensive round. AI will build towers. If it reachs the maximum allowed structures, it will upgrade towers.
-> A1: 1st offensive round. If AIMaxOffense is 1, AI will build attackers, else it will do nothing.
-> A2: 2nd offensive round. 1 second before AIMaxOffense becomes 2, AI will start building attackers, else it will do nothing.
-> A3: 3rd offensive round. 1 second before AIMaxOffense becomes 3, AI will start building attackers, else it will do nothing.
-> A4: 4th and Final offensive round. AI will surely build attackers one second before the round starts.
->U1: AI will upgrade the towers.
The behaviour of AI may vary a bit depending on special events caused by the position of the player. I.e.: If Player Red is alone, AI might use some of its defensive rounds to build a wall in the right side of the map.
Building Towers:
AI does what a typical not so n00b player does in a TD map: Mazes. AI mazing is a zig-zag usually determined by a minimum and maximum point. So, AI builds the most expensive tower it can build. After it's build, a trigger called AI Player (1-6) Mazing Inteligence determines the next place where AI should build and it can also determine special events caused by number of structures. Well, but it's mainly used for determine the next placement area in the variables AIBuildX= and AIBuildY=. Then, it calls the processor again to see if another building can be built. AI also changes the acquisiton range of the structures of the last queue when it is playing in the position of the blue or yellow player.
Blocking Sides:
When Red AI is playing alone, it tends to block a side after a certain number of buildings (last setting was 30). AI do this to avoid that the enemy attackers use the special path and also to separate them making it easier to stop them. The blocking event disables the AI Player X(1-6) Mazing Inteligence and enables the AI Player X(1-6) Blocking Inteligence that acts similar to the other one, except that it's just used to complete a whole line. So, it just needs an initial position to build and no limits at all. When it's over, it returns to use AI Mazing Inteligence normally.
Building Attackers:
Currently AI, builds on 0:01. It tries to build the most expensive units until the cheaper ones. It is strategically better to build on 0:01 instead of the exact beggining of the last round and rebuild the rest on 0 which would improve the income and make AI builds more units.
Upgrading Towers:
AI uses a trigger (that I forgot the name) that determines what kind of upgrade AI can do depending on AI's cash. I.e.: If AI has 30 of cash, it can upgrade a Icycle Tosser to a Snowball Launcher. This trigger gives the information of the unit that will be upgraded to the AI Player X(1-6) Upgrade Towers trigger than depending on the side, it sells them and build a new one of a better type over it or.. just upgrades it. In the end, it calls the processor again to see if another tower can be built or if the tower was not re-built yet (in case it was sold).
Final Notes:
AI still shows some flaws against dragonsand few other problems when when rebuilding dead upgraded towers. Things that can be fixed in the next beta version. QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Wed Sep 17, 2003 12:04 am Post subject:
16/09/2003: 21:10 BTZ
This document has been updated... I'm a bit lazy to talk about the new replacement trigger I made that disguises as a failured upgrade, but I'll talk about it later... I doubt someone will comment that seriously one day... QUICK_EDIT
Also Known As: banshee_revora (Steam) Joined: 15 Aug 2002 Location: Brazil
Posted: Fri Nov 28, 2003 5:20 pm Post subject:
that's why I say that ONLY RED works in the moment. So, you have to play against red. If you add another AI allied with red, then, red will go to the left side, otherwise it stays in the middle... QUICK_EDIT
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum