• Log InLog In
  • Register
  • Shop
Liquid`
TeamLiquid Liquipedia TLnet LiquidLegends
  • Home
  • Forum
  • Live Streams
  • Calendar
  • Liquipedia
  • Store
  • Heroes
  • Items
  • Store
  • Players
  • Teams
  • Recent Results
Forum Sidebar
Events/Features
News
Featured News
OG - Greatness Defined0OMEGA League Playoffs0OMEGA League: EU Preview0Improving Efficiently - A Guide to Getting Good17Is Passion Contagious? Dota's Online Rebirth9
Community News
Valve Announces 2021 DPC Details19Patch 7.28 + The Mistwoods Update30[Translation] Interview with DM after Epic League0BoraNija out of mudgolems3B8 announce roster changes2
Dota 2 General
General
A question from a new player Valve Announces 2021 DPC Details Just Error: SumaiL + former VP stack Arteezy: "Sometimes at school they call me A-God" Patch 7.28 + The Mistwoods Update BoraNija out of mudgolems
The Tavern
Official Off-Topic General Discussion
Tournaments
[DPC 2021 S1] South America Upper Division [DPC 2021 S1] South America Lower Division [DPC 2021 S1] North America Lower Division [DPC 2021 S1] North America Upper Division [DPC 2021 S1] Southeast Asia Upper Division
Players & Teams
OG Discussion Na`Vi Discussion Evil Geniuses Discussion Nigma Discussion
Strategy
TIPS: How to play safe lane carry properly
Community
General
US Politics Mega-thread NASA and the Private Sector Trading/Investing Thread Coronavirus and You The Chess Thread
Other Games
FF7 remake for PS4 announced Final Fantasy XIV Fortnite Battle Royale
Heroes of the Storm
HotS: WP and Funny Moments [HotS] NA Stands Supreme
Sports
2020 NFL and College Football Corona Season 2020 - 2021 Football Thread NHL 19-20: Hop Off my Kakko
Media & Entertainment
Korean Music Discussion [SCIFI Series] The Expanse [Manga] One Piece
TL Mafia
[M][T] Personality Mafia: Mini Edition TL Mafia Plays: Diplomacy Personality Mini Mafia: Vote Thread
Blogs
2020 personal review
Julmust
girl blog #2: common…
SpiritoftheTunA

Website Feedback

Closed Threads

Discord Server


Active: 349 users

Dota 2 Bot API #6: apache/php framework POC

Blogs > LetaBot
Post a Reply
LetaBot
Profile Joined June 2014
Netherlands21 Posts
Last Edited: 2016-08-05 16:41:30
August 05 2016 00:54 GMT
#1
Dota 2 Bot API #6: apache/php framework proof of concept

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]


3. Start an Apache server

[image loading]

[image loading]

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]


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]

6. Go to the htdocs folder of the zip you unpacked and select/copy the "test.php" file

[image loading]

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]

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]

9. Now go to

http://localhost/test.php?hpvalue=300

If your apache is running, it should only display the word "RETREAT"

[image loading]


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]

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]


12. Click on it. Then click on "create custom lobby" (the blue button).

In the map option, select "Dota"

[image loading]

set a password for the lobby (to allow cheats ) and then enabled cheats ( to allow the host to add bots )

[image loading]

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]

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.


*****
If you cannot win with 100 apm, win with 100 cpm.
LetaBot
Profile Joined June 2014
Netherlands21 Posts
August 05 2016 00:57 GMT
#2
I am considering crowdfunding to add the missing features from Tobias Mahlmann's LUA code and allow that code to connect to an apache server with the above framework instead of a Tomcat server. The php code would ofc also have to be created.

A draft of this crowdfunding page can be found at:

https://www.indiegogo.com/project/preview/f607f206#/


I am open for suggestions for perks and other feature you might want to see in a Dota 2 Bot API.
If you cannot win with 100 apm, win with 100 cpm.
TheVideoGameGuy
Profile Joined May 2015
India209 Posts
August 05 2016 15:51 GMT
#3
Cool stuff!
Thy dendemic fools completing thy generic life processes
Piledriver
Profile Joined August 2010
United States760 Posts
Last Edited: 2016-08-05 18:32:01
August 05 2016 18:08 GMT
#4
Is there a reason why you are running a web based application and the poor performance and latencies that accompany it? Isn't it always better to run a locally compiled C++ or windows based application that has far better performance?

Edit: Just saw that the LUA allows only http requests. But I still think you should be able to write some kind of app that is able to intercept http requests and send back appropriate responses without having to locally host a xampp server and all the overhead of a client-server architecture. Something like Node.js maybe a better solution.
Envy fan since NTH.
LetaBot
Profile Joined June 2014
Netherlands21 Posts
Last Edited: 2016-08-05 18:38:59
August 05 2016 18:33 GMT
#5
On August 06 2016 03:08 Piledriver wrote:
Is there a reason why you are running a web based application and the poor performance and latencies that accompany it? Isn't it always better to run a locally compiled C++ or windows based application that has far better performance?

Edit: Just saw that the LUA allows only http requests. But I still think you should be able to write some kind of app that is able to intercept http requests and send back appropriate responses without having to locally host a xampp server. It may be crucial for the bots to make split second decisions in real time.



Well, this is just a proof of concept of course. Since XAMPP automatically installs and enables php and other CGI interfaces, it is the easiest method for the average user to install.

With an apache webserver you can ofc use the CGI to run C++ directly, as well as just about any other programming language.


When bots are complex enough in their decision making, it would indeed be a good idea to reduce overhead (to reduce latency), but for now I deliberately decided to keep things simple to setup.
If you cannot win with 100 apm, win with 100 cpm.
Please log in (you can use your steam or reddit account!) or register to reply.
Live Events Refresh
Next event in 1d 4h
[ Submit Event ]
Live Streams
Refresh
Players
masondota28689
BananaSlamJamma2013
PurgeGamers1416
monkeys_forever408
1437366
MooDota2227
XaKoH 0
Organizations
BeyondTheSummit355
[ Show 66 non-featured ]
Dota 2
• ALOHADANCETV4849
• lelisdota1534
• EskobarTv1136
• seucreysonreborn 1089
• streampromotiontv564
• SammyboyGG422
• SpeedManq418
• henry390
• ericking315
• DotaTV247305
• getlowdota263
• MoUraDota260
• A1taOda 187
• LoremCDMX144
• 100poison144
• terokvll141
• jubeigaaaa131
• KVYZEE 130
• solotic119
• PIOSz 90
• BTSBrasilTV 87
• nongrataqq85
• yalolz84
• miladrvn80
• windkush79
• koh0l67
• youtsuya55
• ru_mawi55
• SequinoxTV55
• ExcaliRevolution52
• m3traNeo51
• Lil_Juzu48
• Broxy_TV44
• Buzzkin44
• ReshyD41
• colddoll37
• dead7k1d36
• laska_laska36
• mladshiytv33
• Dr_spite31
• wander_err29
• meowxisde29
• ggbet_dota27
• Sh1zzyDota26
• laroucoulade 23
• RepublicaOldGamer23
• HarryPotterClan23
• FroggedTV 21
• bongeR_19
• shokoochi19
• gemma9017
• srtadestiny16
• quledota16
• SoothsDotA15
• sad_ins1de15
• TheeHowlPendragon15
• baLonesBR14
• explosiv_fury13
• Monthlygift13
• Tedykyn12
• meowsonic12
• Vash111611
• gruccv11
• taniabelka11
• Treebearddoto10
• high_shaggy10
Upcoming Events
DPC 2021
VG vs LBZS1d 4h
EHOME vs MagMa1d 7h
DreamLeague
Liquid vs Vikin.gg1d 13h
mudgolems vs Secret1d 16h
DPC 2021
EG vs 4Z1d 19h
DPC 2021
Fnatic vs T12 days
BOOM vs Neon2 days
DreamLeague
Alliance vs Nigma2 days
[ Show More ]
DPC 2021
bc vs EGB2 days
OmG vs SGE2 days
DPC 2021
496 vs Vice3 days
ESL One
MU vs TSpirit3 days
DPC 2021
Undying vs A-Team3 days
BNY vs 5MM3 days
DPC 2021
PSG.LGD vs LBZS4 days
Liquipedia Results

Completed

ESL One Germany 2020
Perfect World League S3 Div. A

Ongoing

DPC 2021 S1: CN Lower Div.
DPC 2021 S1: NA Lower Div.
DPC 2021 S1: SEA Lower Div.
ESL One CIS S1: Lower Div.
OGA DPC SA S1: Lower Div.
DreamLeague S14 EU Lower Div.
Snow Sweet Snow #1
ESL Meisterschaft S2

Upcoming

DPC 2021 S1: SEA Upper Div.
OGA DPC SA S1: Upper Div.
DreamLeague S14 EU Upper Div.
DPC 2021 S1: CN Upper Div.
DPC 2021 S1: NA Upper Div.
ESL One CIS S1: Upper Div.

Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Lip Comarella / SalonAlpin.
The contents of this webpage are copyright © 2021 LiquidDota.com. All Rights Reserved.