Skip to content

Latest commit

 

History

History
87 lines (67 loc) · 4.25 KB

building_solver2048.md

File metadata and controls

87 lines (67 loc) · 4.25 KB

Building Solver2048

Table of Contents

Solver

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.

Windows 64-bit

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.

Linux 64-bit

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.

Command line

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.

Eclipse

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.

Streaming server

The solver's progress can be streamed live over the internet, and the following steps tell you how to accomplish this:

  1. Refresh your package index: sudo apt-get update
  2. Install LAMP server: sudo apt-get install lamp-server^
  3. Test that your server works: http://localhost
  4. Also install the native MySQL driver for PHP sudo apt-get install php5-mysqlnd
  5. Install phpMyAdmin (select Apache2 during install): sudo apt-get install phpmyadmin
  6. Configure the database
  7. Go to http://localhost/phpmyadmin
  8. Import solver2048/sql/solver2048.sql
  9. Create a user (e.g. solver2048_user) with select, insert, update and execute privilege to the database solver2048
  10. Adjust the database login info for PHP:
  11. cd ~/solver2048/webclient/resources
  12. Create a config file: cp config-sample.php config.php
  13. Edit config.php to match the login data for your database
  14. Bring the webclient online:
  15. Remove the example html directory: sudo rm -r /var/www/html
  16. Create symlink: sudo ln -s ~/solver2048/webclient/public /var/www/html
  17. Test this by visiting http://localhost, where you should see an empty 2048 board
  18. Install the MySQL C development libraries: sudo apt-get install libmysqlclient-dev
  19. Build the solver using the make command listed below, with the following adjustments:
  20. Substitute username and password
  21. If necessary add -DMYSQL_HOSTNAME="foo", -DMYSQL_DATABASE="bar" and/or -DMYSQL_PORT=123 to DEFS. The defaults are "localhost", "solver2048" and 0, respectively.
cd ~/solver2048/Solver2048
make release ENABLE_MYSQL=1 DEFS='-DMYSQL_USERNAME="solver2048_user" -DMYSQL_PASSWORD="abc123"'
  1. 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>
  1. Run ~/solver2048/Solver2048/Release/Solver2048, go to http://localhost, sit back, and relax!