• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:31
CEST 02:31
KST 09:31
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL20] Ro24 Preview Pt2: Take-Off6[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18
Community News
Weekly Cups (Aug 18-24): herO dethrones MaxPax5Maestros of The Game—$20k event w/ live finals in Paris30Weekly Cups (Aug 11-17): MaxPax triples again!13Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195
StarCraft 2
General
Weekly Cups (Aug 18-24): herO dethrones MaxPax What mix of new and old maps do you want in the next 1v1 ladder pool? (SC2) : A Eulogy for the Six Pool Geoff 'iNcontroL' Robinson has passed away 2v2 & SC: Evo Complete: Weekend Double Feature
Tourneys
WardiTV Mondays Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament Monday Nights Weeklies
Strategy
Custom Maps
External Content
Mutation # 488 What Goes Around Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below
Brood War
General
No Rain in ASL20? BW General Discussion Flash On His 2010 "God" Form, Mind Games, vs JD BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ro24 Preview Pt2: Take-Off
Tourneys
[ASL20] Ro24 Group E [Megathread] Daily Proleagues [ASL20] Ro24 Group D [ASL20] Ro24 Group B
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread General RTS Discussion Thread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The year 2050 European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
High temperatures on bridge(s) Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment"
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
Evil Gacha Games and the…
ffswowsucks
Breaking the Meta: Non-Stand…
TrAiDoS
INDEPENDIENTE LA CTM
XenOsky
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 5950 users

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

Blogs > LetaBot
Post a Reply
LetaBot
Profile Blog Joined June 2014
Netherlands557 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 Blog Joined June 2014
Netherlands557 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
India211 Posts
August 05 2016 15:51 GMT
#3
Cool stuff!
Thy dendemic fools completing thy generic life processes
Piledriver
Profile Blog Joined August 2010
United States1697 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 Blog Joined June 2014
Netherlands557 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 or register to reply.
Live Events Refresh
PiGosaur Monday
00:00
#46
PiGStarcraft236
SteadfastSC38
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft236
NeuroSwarm 147
Nina 136
ProTech85
CosmosSc2 43
Nathanias 41
SteadfastSC 38
StarCraft: Brood War
Artosis 781
Hyuk 470
NaDa 54
Sharp 36
Dota 2
monkeys_forever368
Counter-Strike
fl0m1044
taco 101
Super Smash Bros
hungrybox316
AZ_Axe83
PPMD44
Liquid`Ken8
Other Games
summit1g7182
shahzam1616
Day[9].tv847
C9.Mang0352
WinterStarcraft245
ViBE244
Maynarde150
ToD130
Organizations
Other Games
gamesdonequick833
BasetradeTV16
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• RyuSc2 43
• rockletztv 11
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota22476
League of Legends
• Stunt236
Other Games
• Day9tv847
Upcoming Events
Afreeca Starleague
9h 29m
hero vs Alone
Royal vs Barracks
Replay Cast
23h 29m
The PondCast
1d 9h
WardiTV Summer Champion…
1d 10h
Clem vs Classic
herO vs MaxPax
Replay Cast
1d 23h
LiuLi Cup
2 days
MaxPax vs TriGGeR
ByuN vs herO
Cure vs Rogue
Classic vs HeRoMaRinE
Cosmonarchy
2 days
OyAji vs Sziky
Sziky vs WolFix
WolFix vs OyAji
BSL Team Wars
2 days
Team Hawk vs Team Dewalt
BSL Team Wars
2 days
Team Hawk vs Team Bonyth
SC Evo League
3 days
TaeJa vs Cure
Rogue vs threepoint
ByuN vs Creator
MaNa vs Classic
[ Show More ]
Maestros of the Game
3 days
ShoWTimE vs Cham
GuMiho vs Ryung
Zoun vs Spirit
Rogue vs MaNa
[BSL 2025] Weekly
3 days
SC Evo League
4 days
Maestros of the Game
4 days
SHIN vs Creator
Astrea vs Lambo
Bunny vs SKillous
HeRoMaRinE vs TriGGeR
BSL Team Wars
4 days
Team Bonyth vs Team Sziky
BSL Team Wars
4 days
Team Dewalt vs Team Sziky
Monday Night Weeklies
5 days
Replay Cast
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

CSLAN 3
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
Acropolis #4 - TS1
CSL Season 18: Qualifier 2
SEL Season 2 Championship
WardiTV Summer 2025
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
Sisters' Call Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.