Posts

Showing posts from January, 2016

Using OpenGL in Microsoft Visual Studio

Image
Getting started with using OpenGL / freeglut in a Microsoft Visual Studio environment for 32 bit versions. 1. Obtain freeglut Go to the freeglut site to obtain the MSVC package: http://www.transmissionzero.co.uk/software/freeglut-devel/ At the time of writing this demonstration we obtain version 3.0.0 in zip file format: http://files.transmissionzero.co.uk/software/development/GLUT/freeglut-MSVC.zip 2. Obtain glew http://sourceforge.net/projects/glew/files/glew/ At the time of writing this demonstration we obtain version 1.13.10 in zip file format: http://sourceforge.net/projects/glew/files/latest/download?source=files 3. Place freeglut and glew in the location of your choice: 4. Create a new empty project in Visual Studio Add your main.cpp source code file. Don't have to put anything in it for the time being: 5. Set the Additional Include Directories Select project properties > C/C++ > General tab > Additional Include Directories. Do thi...

Using a genetic algorithm to solve the n-Queens problem in C++

Image
A post showing how a genetic algorithm when used appropriately can be used as a powerful means to solve the n-Queens problem of increasing sizes. A downloadable Visual Studio 2010 C++ project implementing the genetic algorithm is available. Problem Description The N-Queens problem is the placement of queens on a chess board so that none are threatened - no single queen share a common row, column, or diagonal. The difficulty of the problem explodes with the number of queens involved and is known to be computation expensive. For example, there are 4,426,165,368 possible arrangements of eight queens on an 8×8 board, but only 92 solutions (source: Wikipedia ). Applying the genetic operators An outline of the genetic algorithm that was applied to this problem and implemented in C++ is as follows: Generate a population of solutions representing the positions of the N number of queens on the chessboard. Solutions ("chromosomes") are represented using integer arra...