Herself’s Artificial Intelligence

Humans, meet your replacements.

Archive for the ‘game ai’ Category

Predator Prey Chases using Potential Functions

without comments

Using potential functions for predator prey movement gives a more realistic chase than using line of sight or other line algorithms.

Potential functions are well known in physics and describe attraction and repulsion due to electricity, gravity etc.

Potential_Energy = – Attraction/distance^j + Repulsion/distance^k

A strong attraction will cause the predator to chase the prey, a strong repulsion will cause the prey to flee the predator. Either of these can be set to zero. Predators may only be attracted to prey, prey may only be repulsed by predators. Various prey and predators can be given slightly different numbers for attraction, repulsion, j, k allowing them to behave differently.

To chase or run a character using potential functions use this algorithm:

Move_Predator (){

double attraction = some_constant; // experiment with these, the size of your game
double repulsion = some_constant; // area will determine good choices
double j = some_constant; // try something between 1 to 3 for these numbers
double k = some_constant; // higher number mean smaller results
double x_predator;
double y_predator;
double x_prey;
double y_prey;

//distance between predator and prey
double distance_x = x_predator – x_prey;
double distance_y = y_predator – y_prey;

double distance = sqrt ( distance_x*distance_x + distance_y*distance_y);

//normalized distance vector
distance_x = distance_x / distance;
distance_y = distance_y / distance;

//see what our attraction or repulsion is
double potential = -attraction/distance^j + repulsion/distance^k;

//now use that attraction/repulsion to see how far we move
double move_x = potential * distance_x;
double move_y = potential * distance_y;

//new location for us
double new_x = predator_x + move_x;
double new_y = predator_y + move_y;

}

More information:
The use of potential functions on modelling animal movement
Advanced Movement Model of Crowd Robots ( pdf )

Books:
AI for Game Developers

Written by Linda MacPhee-Cobb

August 13th, 2007 at 12:00 pm

Artificial intelligence solves checkers

without comments

The game of checkers has roughly 500 billion billion possible positions (5 x 1020). The task of solving the game, determining the final result in a game with no mistakes made by either player, is daunting. Since 1989, almost continuously, dozens of computers have been working on solving checkers, applying state-of-the-art artificial intelligence techniques to the proving process. This paper announces that checkers is now solved: perfect play by both sides leads to a draw. This is the most challenging popular game to be solved to date, roughly one million times more complex than Connect Four. Artificial intelligence technology has been used to generate strong heuristic-based game-playing programs, such as DEEP BLUE for chess. Solving a game takes this to the next level, by replacing the heuristics with perfection.

Test your skills at http://www.cs.ualberta.ca/~chinook/New. The user name is ‘checkers’, and the password is ‘solved2007′.

More information:
Chinook – World Man-Machine Checkers Champion
Paper at Science for a fee

Written by Linda MacPhee-Cobb

August 3rd, 2007 at 12:00 pm

Artificial brain learns to play 20 questions

without comments

. . . He went on to explain, “It was all because of the cool toy that my 17-year-old son took along with him.”

He then showed me this round-shaped blue gizmo (it also comes in a variety of other colours) the size of a tennis ball that looks like a yo-yo and explained to me how it functions.

Called the Radica 20Q, the hand-held, battery-operated toy is based on the old classic game of 20 Questions. All you have to do is think of an object like an animal, vegetable, mineral, and answer a series of 20 questions. You answer the questions by pressing one of four buttons that read “yes,” “no,” “maybe” and “unknown.” The game, which contains an advanced electronic brain, works in mysterious ways, using logic and reasoning to get the right answer. It might come up with questions like, “Is it bigger than a breadbox? Is it used mostly indoors? Is it found in warm climates?”

The odd time that it doesn’t come up with the right answer, it will ask you to indulge it and allow it five more questions before admitting defeat. My neighbour revealed, “We played with it throughout the whole trip and (no pun intended) it didn’t trip up even once. It correctly identified everything including the kitchen sink, wedding cake, criminal lawyer, microwave oven, ostrich, broccoli, air conditioner and hair conditioner. Grandma thought she had it stumped with kettle, but it came up with that answer also.” . . .

More information:
Write Where I Belong – Toy helps pass the time during trip
20Q ( has the toy for sale and an online version you can try )

Written by Linda MacPhee-Cobb

July 27th, 2007 at 12:00 pm