项目作者: martindzejky

项目描述 :
Genetic algorithms! Python!
高级语言: Python
项目地址: git://github.com/martindzejky/genetic-treasures.git
创建时间: 2016-04-19T21:39:12Z
项目社区:https://github.com/martindzejky/genetic-treasures

开源协议:MIT License

下载


Genetic Treasures

This python program uses genetic algorithm to evolve an instruction set for a virtual machine that
executes them and creates a set of movement instructions for a guy that collects treasures on a
map. Get it? Okay, again.

Task

We use genetic algorithm to evolve a set of instructions – 64 bytes. 1 instruction is one byte. The
first 2 bits determine the type of instruction:

  • 0 = increment
  • 1 = decrement
  • 2 = jump
  • 3 = print

The remaining 6 bits point to an instruction in the set that is to be affected. This means that the
program is self-modifying.

A virtual machine takes these instructions, evaluates them, and generates a set of movements – up,
right, down, left. This movements are generated using the print instruction.

Then there’s a map with treasures and a greedy guy that wants to collect them. He takes the
generated set of movements and moves around the level. He collects a treasure when they are on the
same tile. The number of treasures collected is the fitness function for the evolution algorithm.