Artificial Intelligence
toolbar-separator.png This article is currently in development. You can help TI-Basic Developer by expanding it.
neural network


Artificial intelligence, often abbreviated AI, is a branch of computer science concerning the intelligence of machines. More specifically, artificial intelligence is the ability of inorganic automaton to perceive their environment and make rational decisions based on data acquired. Used in applications with dynamic environments, as opposed to static, AI attempts to provide solutions to problems without the need of human interaction. The entire purpose behind utilizing AI is to allow automata to make decisions as if it were human. In essence, AI is an effort to emulate the human mind in settings where a real human would be impossible or impracticable to use.

Characteristics of AI

In the game industry, AI allows a CPU to compete against a human player (or another CPU) under the rules governing the game. For example, a chess AI will analyze the game and attempt to make moves which will maximize its success. Other examples of AI include speech recognition used in cell phones, automatic thermostat controls, and the navigation system used in autonomous robotic vacuum cleaners. In each of these applications, AI combines multiple elements together to complete a task based on the data presented. Breaking the AI into individual qualities allows these elements to be characterized.

In order for a system to be considered artificially intelligent, it must exhibit at least three established characteristics. These characteristics are referred to as the “three A’s”; acquire, analyze, action.


An AI system has the ability to make observations about its environment.
Whether the observations are physical or purely numerical, they represent data acquired by the AI.


An AI system has the ability to evaluate the data acquired and arrive at a conclusion. A chess AI will analyze board piece locations to determine a set of possible actions which will maximize its probability of winning the game.


An AI system has the ability to make rational choices based on the conclusion of the analysis. This characteristic is especially important as it represents the AI’s function as an agent. In other words, the AI has the ability to choose its course of action, doing so in a rational manner.

The three A’s were specifically chosen in order to differentiate true AI from what is otherwise an automated entity performing a predetermined set of tasks. Industrial robots may appear to have AI; however, they are simply machines following programmed instructions. They do not have the ability to acquire nor analyze environmental data. Another misleading use of the word AI is toward game opponents. Often, game opponents that give the impression of being artificially intelligent are nothing more than controlled systems abiding by a set of rules according to the current situation. An example would include Goombas and Koopa Troopas commonly found throughout many Mario series. They do not have AI since they do not possess the defining characteristic of action. In other words, they do not have the ability to make choices. Although Goombas and industrial robots do not have AI, this doesn’t mean that they could not utilize AI.

For example, the industrial robot could be equipped with a humidistat and sound level meter in order to collect data about environmental humidity and decibel levels respectively. The robot could then analyze the information and make decisions based on the results of the analysis. A possible action may be to activate evaporation fans if the humidity rises above a certain level or to reduce operation speed if the environment decibel levels exceed regulation. While less independent, as may be associated with AI, the industrial robot in this proposed setting abides by the rules established for characterizing artificial intelligence. The robot has the ability to acquire, analyze, and take action based on environmental data, making rational decisions towards achieving a goal.

Understanding AI

Developing artificial intelligence involves critical thinking and requires an interrogative approach towards its application. It is often necessary to analyze human thought patterns when designing an AI. The process through which an individual arrives at a conclusion in a game of checkers is likely similar to the sequence of steps an AI should take to maximize competency. Thus to better understand artificial intelligence, it is worthwhile to consider the entity from which it is being modeled, the human brain.

With estimated 50-100 billon neurons and approximately 100 trillion synaptic connections linking the neurons, the human brain is arguably the most powerful computer in existence.



In order to take action based on what it analyzes, an AI must use logical and conditional statements pertaining to the operation it has been programmed to do. For example, in a game of Tic-Tac-Toe, the AI must be able to use logic statements to determine where to place the next 'X' or 'O' in order to either block its opponent or complete a 3-in-a-row for itself. Logic statements can also be used to put certain actions at a higher priority than others. For example, a Tic-Tac-Toe AI will attempt to complete its own 3-in-a-row before blocking the opponent, because if it has already won, then the game is over and there is no chance of the opponent winning.

Procedural Programming

Control Flow

Data Structures


Code Structure

Gather Variables


Thinking like AI

To program an AI you must think like one. You must not think like you would because if you were making the move in tic-tac-toe, you would reason on which move would be better, but the Calculator can't do this. all it can do is execute your code and make choices depending on whats true at the time and what your code tells it to do.





Decision Tree


First of all, letting a calculator learn is not really possible, however it is possible to let it remember and compare, thus creating the illusion it has learned. Let's see an example, Tic tac toe, in this game it could be possible for the program to store all the games it played in lists, whenever the program can't figure a good move using the normal routine it can refer back to the lists and compare the list with the actual situation, now if the situation mathces it could give a good move based on what it did good or bad in the list it is comparing to. This way of learning would prevent the human player from applying the same tactic over and over again, ergo, the machine seems to have learned what to do when this "tactic" appears. A good example of Self learning is deep blue, this was a machine developed by IBM that won a deciding chess game against the best human chess player at that time.


First, artificial intelligence is one of the largest obstacles needed overcoming in the TI Basic world. I will attempt to outline the basics of programming a game's artificial intelligence. Second, from my point of view, there are 3 types of artificial intelligence. Always dumb, always smart, and random.
And featuring a somewhat complex AI in a BASIC program costs many space and time. And to a gamer waiting a long time in a turn-based game or playing an action game slowly is very unpleasant. So always be sure that AI code is highly optimized. And sometimes you may reduce the AI in intelligence to make a game more enjoyable.


This type of intelligence is quite simple; all you have to do is program the computer to always make a useless move (or allow the opponent to win). What you can do is run an equation to find all "bad outcome" moves, and then execute one of them at random.
Take the game "Tic Tac Toe" for example. You can run an equation to check for two naughts in-a-row, and place a cross elsewhere (not blocking). If it is the first turn of the game, program the computer to place a cross in the middle of an edge.

If one is closed, take and random integer between 1 and 3 and assign them to the X's left, right, and across of the used X. Then play the spot chosen.
If none were used, take an integer between 1 and 4, and play the chosen spot.
If it is the second turn, figure out how to check for adjacent pairs of the opponent's mark. Then pick a random spot that isn't blocking the opponent and play that move.


Also a sort of simple route, the computer is all powerful; it can't lose. You must have the computer programmed to always block the opponent, and win for itself.

With "Tic Tac Toe", you have pretty much the opposite of the first one — First have the computer try to get the center, then the corners, then block the adjacent squares.

Random Intelligence

For "Random Intelligence", it is recommended to have three levels of difficulty (Easy, Medium and Hard). You may set a fixed level of difficulty; however, it is better gameplay if you let the user choose.

The three modes determine how good the computer's chances of choosing the correct route. All you need to do is put a quick random line determining whether the computer will make an intelligent or unintelligent move. Then you take one of the preceding routes for the computers move. I suggest 50% for easy 75% for medium, and 90% for hard.


There is however, a third way of "intelligence", this is built upon a processors best capability, trial and error. As deep blue has proven brute force of processing all the options + self learning result as a merely invincible AI. It is not wise to pre-program every try, this would take little processors like the calculators Z80 way to long, also the size of a program like that would not fit unto the RAM. If you can succeed in teaching your program the rules of the game and teach it to obey them it will automatically result in a so called weak AI. A method of teaching is to let it compare the situation with possible options + what it is allowed to do.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License