# The mines package

[ Tags: ai, game, program ] [ Propose Tags ]

A simulation of AI controlled minesweepers using neural networks and genetic algorithms. The minesweepers learn to sweep mines themselves and their movements are recorded in an SVG file.

## Properties

Versions 0.1 base, directory (>=1.0.0.0), mtl (>=1.1.0.0), random (>=1.0.0.0) [details] OtherLicense Antti Salonen 2008 Antti Salonen ajsalonen@gmail.com Game, AI http://finder.homelinux.org/haskell/Mines Wed Aug 13 14:28:47 UTC 2008 by AnttiSalonen NixOS:0.1 mines 633 total (11 in the last 30 days) (no votes yet) [estimated by rule of succession] λ λ λ Docs not available Last success reported on 2017-01-03 Hackage Matrix CI

#### Maintainer's Corner

For package maintainers and hackage trustees

[back to package description]
Mines 0.1
---------

Building with Cabal:

$runhaskell Setup.hs configure --user --prefix=$HOME
$runhaskell Setup.hs build$ runhaskell Setup.hs install

Use:

This part isn't too difficult. Run the program (called mines) from wherever
you installed it and wait until you get some results. The output may give
some hints on how well the sweepers are doing. Every 10 generations an SVG
file is generated in ~/.mines (or Documents and Settings/user/Application
Data/mines on Windows) that shows you how a minesweeper moved in the
previous generation.

It may take a few hundred generations before they actually get smart. When
they're smart enough for you, ctrl+c will exit.

Configuration:

To configure the program, you need to tweak the values in the beginning
of Mines.hs and recompile. Changing settings like the size of the map or
number of minesweepers makes the simulation run faster or slower and also
affects the speed the minesweepers learn. The current values work pretty well,
but feel free to experiment.

Neural networks:

The minesweepers have a 4-3-3-2 neural network, where the inputs are the
direction of the minesweeper (x and y) and the vector to the nearest mine
(x and y). The outputs are the angle where to turn (relative to current
minesweeper direction) and the velocity for moving (which is not used
in the code in this release).

To use the neural networks in NN.hs, you only need the functions newNeuralNet
and updateNeuralNet. newNeuralNet takes a list of layers (such as [4,3,3,2])
as well as minimum and maximum values for weights (floats) as parameters,
updateNeuralNet takes a weighting function (such as sigmoid or (*1)), list
of weights as input and a neural net as a parameter and returns the list
of outputs.

Genetic algorithms:

To train the neural networks you need genetic algorithms that can be found
at GA.hs. You can use getWeights in NN.hs to get a list of weights that
are the genes for the genetic algorithms, functions crossOver, mutate,
mixGenes and pickRoulette for choosing the parents and creating the children
and putWeights to apply the new weights to the new networks.

Todo:

The types for weights in neural networks as well as for genes in genetic
algorithms are hard coded at the moment (Float). Making that application
dependent would be good.