Simple Maze game coded in Go with genetic algorithms option to search for the best solutions.
Cross the screen and reach the empty space on last column at the right.
Human | Genetic Algorithms |
---|---|
- After the first execution, the program will create an ini file named '.maze.ini' into user home folder
- To execute the game, set the value 'Automation' to false, otherwise, it will start in simulation mode
- Select the map from 0 to 3
- Define the genetic altorithm configuration:
- Number of generations (Generations)
- Population size (Population_size)
- Number of genes (Gene_number)
- Number of participants of tournament for parents selection (K)
- Crossover rate (Crossover_rate)
- Mutation rate (Mutation_rate)
- Elitism percentual (Elitism_percentual)
- Run the program
- Improve score considering the individual that got the best result in less movements.
- After finish, show the path of winner
- Key to reset
- Clean code
- Show the time spent after the execution
- Translate the individual into arrows
- Reactivate the background drawing (game.go) it efficiently
- Put the debug into the down side of screen
- Add the spritemap inside the binary
env GOOS="darwin" GOARCH="amd64" go build -ldflags="-s -w"
https://github.com/kindlychung/genicon
brew install imagemagick
./genicon icon.png tmp_folder
iconutil -c icns -o icon.icns AppIcon.iconset
GO allows to create a Windows executable file using a MacOS:
brew install mingw-w64
go install github.com/tc-hib/go-winres@latest
sudo go-winres init
sudo chown -R $(id -un) winres && chmod 755 winres
- Edit and replace the APP section of the file "winres/winres.json":
"APP": {
"0000": [
"../Images/AppIcon.iconset/icon_128x128.png",
"../Images/AppIcon.iconset/icon_64x64.png",
"../Images/AppIcon.iconset/icon_32x32.png",
"../Images/AppIcon.iconset/icon_16x16.png"
]
}
go-winres make
- 32 bits:
env GOOS="windows" GOARCH="386" CGO_ENABLED="1" CC="i686-w64-mingw32-gcc" go build -ldflags="-s -w"
- 64 bits:
env GOOS="windows" GOARCH="amd64" CGO_ENABLED="1" CC="x86_64-w64-mingw32-gcc" go build -ldflags="-s -w"
-
If you receive the message when running the executable, you need to ensure that the video drivers supports OpenGL (or the virtual driver in the case of virtualization).
-
If you receive this message : "APIUnavailable: WGL: The driver does not appear to support OpenGL", please update your graphics driver os just copy the Mesa3D library from https://fdossena.com/?p=mesa/index.frag (opengl32.dll) to the executable folder.
brew install upx
upx <binary_file>
Instructions to build using Ubuntu.
sudo apt install pkg-config libgl1-mesa-dev licxi-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev mesa-utils build-essential xorg-dev upx
- 32 bits:
env GOOS="linux" GOARCH="386" CGO_ENABLED="1" go build -ldflags="-s -w"
- 64 bits:
env GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" go build -ldflags="-s -w"
upx <binary_file>
- Pixel:
https://github.com/faiface/pixel/wiki
- Game programing:
https://www.codingdream.com/index.php/simple-pacman-in-using-go-and-pixelgl-part-1
- Mac APPs
https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
- Go Windows Binary Icon:
https://stackoverflow.com/questions/25602600/how-do-you-set-the-application-icon-in-golang