Table of Contents
TL;DR: git clone https://github.com/mmiermans/solver2048.git && cd solver2048/Solver2048 && make && ./Debug/Solver2048
That was the short version! What follows are more detailed instructions for building the solver on Windows or Linux. A 64-bit system is required in both cases. The Linux instructions are targeted towards Ubuntu -- because that's what I use -- so substitute apt-get with your favorite package manager if you use something else.
Open the .sln
solution file with Visual Studio. Build in release mode to get the best performance. I have only tested it with VS2013 and modifications might be necessary if you use an earlier version.
git clone https://github.com/mmiermans/solver2048.git
This will create a directory called solver2048
. Now you have the choice to use the command line or Eclipse to build the application.
Compiling the application on the command line requires the following package:
sudo apt-get install build-essential
Navigate to the project directory with cd solver2048/Solver2048
. Simply run make
or make release
to generate an executable. The release
target compiles with the -O3
optimization option enabled, resulting in significantly better performance. Start the solver with ./Debug/Solver2048
or ./Release/Solver2048
.
If your preference is to use Eclipse, then open Eclipse and import the project from solver2048/Solver2048
. There are two possible Build Configurations: Debug_Solver2048
and Release_Solver2048
. The former can be debugged more easily and the latter is optimized for performance.
The solver's progress can be streamed live over the internet, and the following steps tell you how to accomplish this:
- Refresh your package index:
sudo apt-get update
- Install LAMP server:
sudo apt-get install lamp-server^
- Test that your server works: http://localhost
- Also install the native MySQL driver for PHP
sudo apt-get install php5-mysqlnd
- Install phpMyAdmin (select Apache2 during install):
sudo apt-get install phpmyadmin
- Configure the database
- Go to http://localhost/phpmyadmin
- Import
solver2048/sql/solver2048.sql
- Create a user (e.g.
solver2048_user
) with select, insert, update and execute privilege to the databasesolver2048
- Adjust the database login info for PHP:
cd ~/solver2048/webclient/resources
- Create a config file:
cp config-sample.php config.php
- Edit
config.php
to match the login data for your database - Bring the webclient online:
- Remove the example html directory:
sudo rm -r /var/www/html
- Create symlink:
sudo ln -s ~/solver2048/webclient/public /var/www/html
- Test this by visiting http://localhost, where you should see an empty 2048 board
- Install the MySQL C development libraries:
sudo apt-get install libmysqlclient-dev
- Build the solver using the make command listed below, with the following adjustments:
- Substitute username and password
- If necessary add
-DMYSQL_HOSTNAME="foo"
,-DMYSQL_DATABASE="bar"
and/or-DMYSQL_PORT=123
toDEFS
. The defaults are "localhost", "solver2048" and 0, respectively.
cd ~/solver2048/Solver2048
make release ENABLE_MYSQL=1 DEFS='-DMYSQL_USERNAME="solver2048_user" -DMYSQL_PASSWORD="abc123"'
- Let Apache compress its output:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
- Run
~/solver2048/Solver2048/Release/Solver2048
, go to http://localhost, sit back, and relax!