Hello everyone,
As you all might know, the built-in Dota 2 bots are easy to defeat. As written in my previous blog posts, the LUA scripting engine has some limitations which prevent it from being used to create a top level bot. So instead I decided to create my own Dota 2 bot API framework such that programmers can write bots for Dota 2, and your average Joe Dota 2 player can easily install these bots and play against them.
Tobias Mahlmann already created a beginning for a Dota 2 bot API framework (see also my blog #5).
But as mentioned on the github page, the framework isn't finished. Tobias Mahlmann also mentioned the following on how to run the example bot: "you need to be familiar with Java programming and building an application using maven".
So I decided to create a different approach which won't require any programming knowledge. For this I use an apache/php server. The added benefit to this is that it is easier to program a Bot in many different programming languages as opposed to a TomCat server which is mainly for the Java programming language.
Anyway, in this blog entry I will show you how to install and run the proof of concept that I have created. This POC is intentionally kept simple, so don't expect much from the bots. This is mainly to demonstrate the install and run process. When actual bots are made with this framework, the install process won't change much.
The end result should looks something like this, but less laggy (unless your PC is somehow even worse than mine

There are quite some steps involved, but they are all straightforward.
1. Install XAMPP. This tool will install apache and php for you, so you won't have to spend some time configuring it. Make sure that you don't install it to "Program files" because on most windows computers apache won't have write permission there.
2. Start up XAMPP.
![[image loading]](http://i.imgur.com/xjtk0vF.png)
3. Start an Apache server
![[image loading]](http://i.imgur.com/mj3ICDe.png)
![[image loading]](http://i.imgur.com/xotwUbp.png)
4. Go to your browser and type in the adress bar "localhost/" and press enter. This should bring you to "http://localhost/dashboard/" if your apache started correctly.
![[image loading]](http://i.imgur.com/FDOpUeB.png)
5. Download the necessary files from:
https://github.com/MartinRooijackers/Dota2AIframeworkProofOfConcept
There is an option to download everything as a zip, so you won't have to install any git software.
Download the zip and unpack it.
![[image loading]](http://i.imgur.com/rJP5mtr.png)
6. Go to the htdocs folder of the zip you unpacked and select/copy the "test.php" file
![[image loading]](http://i.imgur.com/P4l7TQs.png)
7. paste this file into the htdocs folder of your XAMPPS folder. In my case that would be "C:\xampp\htdocs\test.php"
Don't worry about the Dota2AI.exe , that is optional for now and only for those who want to test the C++ and php inter-process communication.
![[image loading]](http://i.imgur.com/HIE2nPp.png)
8. In your browser go to:
http://localhost/test.php?hpvalue=500
If your apache is running, it should only display the word "ATTACK"
![[image loading]](http://i.imgur.com/fH8y2mn.png)
9. Now go to
http://localhost/test.php?hpvalue=300
If your apache is running, it should only display the word "RETREAT"
![[image loading]](http://i.imgur.com/nnGy2of.png)
10. Now install the dota 2 mod itself. There are two ways of getting it to run.
The first option is to copy the dota2aiframe folder to your dota_addons folder. But this is only useful when you have the dota 2 workshop tools installed. In case you do, you probably already know how to run a dota 2 mod.
Instead we are going to use the mod I put on the workshop.
Go to the following link:
http://steamcommunity.com/sharedfiles/filedetails/?id=737176343
click on the green subscribe button to install the mod
![[image loading]](http://i.imgur.com/YNOJ1wk.png)
11.
Make sure that your apache server is running ( repeat steps 8 and 9 to be sure )
Also make sure that in the launch options of Dota 2, the console is enabled ( add "-console" to the launch options )
Now start up dota 2, go to the arcade, and look for "Dota2AIframeworktest" in the library
![[image loading]](http://i.imgur.com/UVWpKPH.png)
12. Click on it. Then click on "create custom lobby" (the blue button).
In the map option, select "Dota"
![[image loading]](http://i.imgur.com/p0QbSNa.png)
set a password for the lobby (to allow cheats ) and then enabled cheats ( to allow the host to add bots )
![[image loading]](http://i.imgur.com/bkic4OD.png)
You can play with up to 5 people. Just remember to all go radiant, because for now all heroes on the Dire side are considered bots (if you join Dire as a human player then the LUA code will start controlling your hero).
13.
Open up the console with the \ key
You should see a lot of "test1".
If not, then the mod is not running properly
![[image loading]](http://i.imgur.com/uit4Cbk.png)
When you are in the console, type the following two commands:
sv_cheats 1
dota_bot_populate
(optional) to ensure that the command worked, you can type the vision cheat in chat:
-allvision
Once the Dire bots are spawned they should attack move towards the Radiant fountain, and retreat when their HP falls below 400 hp (it is checked once per second, so there might be a slight delay).
14. In case you don't have vision around the T1 and T2 tower, ping around them. This will ofc not be an issue in the final product.
----------------------------------------------------------------------------------------------------------
With this setup you could use the apache/php to use File I/O for machine learning and technically even multi-threading (two things that are disabled in the Dota 2 LUA). But the main reason for this type of framework is that you can use just about any programming language to program your bot.
For those who want to try it out, you can put the Dota2AI.exe in the htdocs folder and run it. Then open the test.php and change the line
$usePHPonly = true;
into
$usePHPonly = false;
Make sure that Dota2AI.exe is running and go through steps 11-14 again. If done correctly, you should have the same functionality in the sense that the bots retreat at 400 hp, but now the decision is made inside C++ code.
Anyway this is just a proof of concept to show how the apache/php architecture allows for many different programming languages to be used in order to create a Dota 2 Bot. As you might be able to see from the steps 1-14, there is no programming or compiling needed to run this framework.