Make your own free website on Tripod.com
Understanding Variables

There are 3 kinds of Variables in Roboforge : Text, Integer, and Boolean. Each type shares the same trait of being able to store information within them, but each is also unique in what kind of data it can store and how it can be used.

AI Node for a Text Variable Here is the node for a Text variable. Text variables can store any alpha-numeric combination (letters or numerals) but cannot be used for math functions such as add, multiply, subtract, and divide. Text variables are case sensitive so if you set a text variable equal to "Run" and then later in your AI look for "run" you will never get a match.
AI Node for a Text Variable Here is a node for an Integer variable. Integer variables can only store numerals, both positive and negative. They can only be used in math functions or comparison.
AI Node for a Text Variable Here is the node for a Boolean variable. Boolean variables can only store a value of Y for Yes or N for No. They are simply used to determine if something is True or False. You cannot use math functions with Booleans.

Creating a variable can be somewhat tricky at first because you cannot simply create one. You first must create a query or AI statement that contains one first. While in your AI panel of Roboforge grab a Query Node (the one with a Question mark) and drag/drop it under your START node on the left. Now grab the Text Node (the one with the big letter A) and drag/drop that onto the "Y" of your previously dropped Query node. Now when you click on the Text Node you will see a folder selection "Update Memory". Clicking on this will allow you to Create, Delete, Select, and set initial Variable values.

Variables can be crucial to the operation of your bot. They are a way for you to store information your bot has gained during a fight and to try and logically react against that information. They can also be used as markers when specific events occur to allow normally dormant sections of your AI to activate. They can even be used in complex mannors that allow your bot to perform complex actions.

One method of using Text variables is to assign different "moods" to a text variable that occur dependant upon your own bot's status. Name a variable "Mood" and then set up instances where your bots mood is determined and acts according to the "mood" its in.

Example of Text Variable  AI As you can see in this example, we have a Text variable labeled "mood". If we are close to the arena wall it becomes set to "claustraphobic". If we are not close to the wall and we detect the enemy then it becomes "aggressive". If we are not close to the wall and we dont detect the enemy then the mood changes to "lost". In this mannor we can then have sections of our AI set up to perform the specific actions needed for the mood our bot is in. If mood is set to "claustraphobic" we could then begin a wall evasion routine. If it is "aggressive" then our bot fights normally. "lost" could mean we begin an arena search pattern.
Integer variables are a great method for storing digital information, such as the maximum reach of your opponent, the health of components, time values, the numbers contrived from calculations to pass on to other AI functions, or even a simple counter. In the example below we see an AI code that continually updates the detected length of the enemy. If they have an arm that extends then this block of code will update E_Reach to match so that we can keep a record of our enemy's maximum reach and react accordingly to that.
Finaly, here is an example, below, of a Boolean variable. This block of code monitors our bot's energy levels and turns the Boolean variable "Recharge" to True when the energy levels are below 25%. When the energy level recharges above 25% the variable "Recharge" is left as True until energy is over 60%. Another section of code would be monitoring if the variable "Recharge" was True or False. While "Recharge" was False your bot would fight as normal, and while "Recharge" was True your bot would go into some form of lower power use until its energy levels recovered.

Variables are an important aspect of Roboforge AI. If you have any further questions about Variables please send me an E-Mail and I will attempt to answer your questions.