Genetic algorithm to create amoeba game

  • Thread starter Thread starter Tusike
  • Start date Start date
  • Tags Tags
    Algorithm Game
Click For Summary
SUMMARY

The discussion centers on the implementation of a genetic algorithm to optimize an AI for an amoeba game created using FreeBASIC. The AI evaluates 28 patterns for winning configurations, but the user, Tusike, struggles with determining the optimal values for these patterns. Suggestions include defining a fitness function based on game performance, creating an initial population of pattern values, and employing selection, crossover, and mutation processes to evolve the AI's capabilities over generations.

PREREQUISITES
  • Understanding of genetic algorithms and their components
  • Familiarity with FreeBASIC programming language
  • Knowledge of AI pattern recognition techniques
  • Experience with game design principles
NEXT STEPS
  • Define a fitness function for AI performance evaluation
  • Research tournament selection methods for genetic algorithms
  • Learn about crossover techniques in genetic algorithms
  • Explore mutation strategies to introduce variability in pattern values
USEFUL FOR

Game developers, AI researchers, and programmers interested in enhancing AI performance through genetic algorithms will benefit from this discussion.

Tusike
Messages
137
Reaction score
0
Hi!
I created an amoeba game where you can play against the computer. The AI searches for patterns such as "xxxxx", "oxxxxo", (as in 5-in-a-row, and 4 in a row with both sides open), and the rest (a total of 28 patterns) I could think of that lead the way to putting 5 marks in a row. Each pattern has a value, and the AI scores each possible square based on the patterns that meet there.
The problem of course is what should the value of each pattern be?
I tried to create a genetic algorithm to help me get the best values, but I don't think I quite succeeded... What I am doing is having two versions run against each other 2 times, each starting once; and if one wins both, it's the "main" version that get's mutated. Then I repeat.

I'm not sure about my mutations process. Right now I'm just adding random numbers up to 100 to certain pattern values. I also tried having random values get multiplied by a random number from 0.5 to 1.5.

Any suggestions on how to implement the genetic algorithm or how to make this work would be very much appreciated:)

-Tusike

PS: the program is written in freebasic: http://www.mediafire.com/?mpk4vsxyekby7g6"
"Amoeba" folder contains a playable version, while "genetic amoeba" folder is the one that searches for the best combination of pattern values. In both folder "amoeba.bas" is the main file.
 
Last edited by a moderator:
Technology news on Phys.org


Hello Tusike,

Thank you for sharing your amoeba game and your efforts to implement a genetic algorithm to improve its performance. It is always exciting to see the intersection of science and technology in creating new and innovative games.

In terms of your question about implementing a genetic algorithm, here are some suggestions:

1. Define the fitness function: In order for a genetic algorithm to work effectively, you need to have a clear understanding of what you are trying to optimize or improve. In this case, it could be the performance of the AI in winning games against the computer. You could define a fitness function that takes into account factors such as the number of games won, the number of moves taken, and perhaps even the difficulty level of the opponent.

2. Create a population of individuals: This can be done by randomly generating a set of initial pattern values for the AI. These will serve as the starting point for your genetic algorithm to improve upon.

3. Implement selection: In order for the genetic algorithm to work, you need to have a way to select the best individuals from the population to continue to the next generation. This can be done by using a tournament selection process where individuals are randomly chosen and compete against each other, with the winners being selected for the next generation.

4. Implement crossover: This involves taking two selected individuals and combining their pattern values to create a new individual. This can be done by randomly selecting a crossover point and swapping the pattern values between the two individuals.

5. Implement mutation: Mutation is a crucial aspect of genetic algorithms as it introduces new genetic information into the population. In your case, it could involve randomly changing the pattern values of an individual by a small amount.

6. Repeat the process: The above steps should be repeated for a certain number of generations or until a desired level of performance is achieved.

I hope these suggestions are helpful in guiding your implementation of the genetic algorithm. It may also be helpful to do some further research on genetic algorithms and how they have been applied in other games and simulations.

Best of luck with your project!
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 30 ·
2
Replies
30
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
10K
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K