Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Samples (http://www.wc3c.net/forumdisplay.php?f=649)
-   -   HCL - HostBot Command Library (http://www.wc3c.net/showthread.php?t=106854)

Strilanc 07-20-2009 03:45 AM

HCL - HostBot Command Library
 
1 Attachment(s)
Suppose you have a map league, where bots host your map and keep track of stats. But the map has modes and you want to force a particular mode in league games (eg. random pick or hard difficulty) without having a separate league version of the map. There is no good way to do this, so you use HCL to pass a short mode in.

This library allows the bot to communicate with your map by encoding characters into players' handicaps (idea by Varlock). Warcraft 3 normally only allows 6 possible handicaps, but bots can specify 256 different values. By encoding the original handicap inside the larger handicap, and only performing the encoding just before the map starts, players don't even realize their handicap was temporarily mutilated.

There is a limit of 1 character per player (empty slots don't count, but computers do), and the characters are limited to the set "abcdefghijklmnopqrstuvwxyz0123456789 -=,.". So don't expect someone to be entering long strings this way. Make the automated modes as short as they need to be. To read the mode entered by the bot, just call HCL_GetCommandString(). If it returns the empty string, there was no mode entered.

It's probably a good idea to include this in popular maps, even if they don't use it. If a bot tries to enter modes on a map without this library, the player handicaps will be absolutely ruined.

History
Hidden information:

v1.01
- Fixed a potential rounding issue when reading the handicap
- Fixed a floating point precision issue when assigning the handicap


Collapse JASS:
///////////////////////////////////////////
/// HostBot Command Library
/// Last Modified: September 14, 2009
/// Authors: Strilanc, 
/// v1.01
///////////////////////////////////////////
/// Reads a command string transparently encoded into player handicaps by hostbots.
/// Allows at most one character from "abcdefghijklmnopqrstuvwxyz0123456789 -=,." per player.
/// Empty slots don't count towards the player count, but computers do.
///////////////////////////////////////////
library HCL initializer init
    globals
        private string command = ""
    endglobals
    
    public function GetCommandString takes nothing returns string
        return command
    endfunction
    
    private function init takes nothing returns nothing
        local integer i
        local integer j
        local integer h
        local integer v
        local string chars = "abcdefghijklmnopqrstuvwxyz0123456789 -=,."
        local integer array map
        local boolean array blocked

        //precompute mapping [have to avoid invalid and normal handicaps]
        set blocked[0] = true
        set blocked[50] = true
        set blocked[60] = true
        set blocked[70] = true
        set blocked[80] = true
        set blocked[90] = true
        set blocked[100] = true
        set i = 0
        set j = 0
        loop
            if blocked[j] then
                set j = j + 1
            endif
            exitwhen j >= 256
            set map[j] = i
            set i = i + 1
            set j = j + 1
        endloop
        
        //Extract command string from player handicaps
        set i = 0
        loop
            exitwhen i >= 12
            set h = R2I(100*GetPlayerHandicap(Player(i)) + 0.5)
            if not blocked[h] then
                set h = map[h]
                set v = h/6
                set h = h-v*6
                call SetPlayerHandicap(Player(i), 0.5 + h/10.0)
                set command = command + SubString(chars, v, v+1)
            endif
            set i = i + 1
        endloop
    endfunction
endlibrary

Hans_Maulwurf 09-04-2009 11:47 AM

Why isn't this approved yet? Every map with different modes should support this. The next Dota version will be the first famous map to do so.

darkwulfv 09-04-2009 02:24 PM

Probably because a lot of people have no way to truly test it, eg: No bot, map doesn't have modes, etc.

Also, what if a mode is something like -emardaelbaejgfadoobedooda? (DotA, anyone?), but only one character per player? How does that work then? (Do you use multiple players to piece the string together?

Strilanc 09-04-2009 04:16 PM

It means that if your game is only going to have two players players, you can only enter an extremely small mode (2 characters). Dota will be able to put in 10 in standard games. The limitations are there because this is the only way we've managed to get any input into the game from the bot without introducing fake players or technically desyncing someone.

The shortness means you probably shouldn't just use the same long commands as inside your map. In power towers I abbreviated every command into a character and use that (there's also a way to see and use them in game instead of normal commands). eg. --nm is -noob -lastman. The HCL string doesn't even need the --.

nichts 09-05-2009 03:40 AM

well after all you don't have to use codes that make "sense" ingame (e.g. you can just give any possible gamemode combination a number encode it into that charset and pass it to the map this way there would be a limit of a wooping 41^12 (22 563 490 300 366 184 000) (for 12 players) possible gamemode combinations)

i don't think anybody will ever realy use that much (well bill gates said that too - so whatever) but for just passing gamemodes 2 players should be more than enough (41^2 => 1 681 diffrent settings)

Captain Griffen 09-05-2009 01:54 PM

This doesn't really have any usefulness on its own. It requires a bot to be useful. Therefore I think it should probably be in with the bot's thread in the tools section, maybe, rather than the scripts section? I'm not sure.

Strilanc 09-05-2009 07:42 PM

Quote:

Originally Posted by nichts
well after all you don't have to use codes that make "sense" ingame (e.g. you can just give any possible gamemode combination a number encode it into that charset and pass it to the map this way there would be a limit of a wooping 41^12 (22 563 490 300 366 184 000) (for 12 players) possible gamemode combinations)

i don't think anybody will ever realy use that much (well bill gates said that too - so whatever) but for just passing gamemodes 2 players should be more than enough (41^2 => 1 681 diffrent settings)


That sounds like a lot, except that the possible number of mode combinations is also huge. Plus there is inefficiency due to usability requirements. The player has to specify the mode, because the bot doesn't know how the map interprets modes. If you just number the possibles modes, you end up with crazy commands like " f-e=,," that players can't remember.

Quote:

Originally Posted by Captain Griffen
This doesn't really have any usefulness on its own. It requires a bot to be useful. Therefore I think it should probably be in with the bot's thread in the tools section, maybe, rather than the scripts section? I'm not sure.


Chances are one of your players uses a hosting bot. It doesn't belong in my bot's thread because this system is not specific to my bot. GHost uses it.

TKF 09-13-2009 11:42 AM

Battle Tanks does also support this system now.

Strilanc 09-15-2009 02:20 AM

v1.01
- Fixed a potential rounding issue when reading the handicap
- Fixed a floating point precision issue when assigning the handicap

Rising_Dusk 10-12-2009 09:04 PM

Whatever. This isn't a script in the sense that it can just be shoved into a map's code and have it be happy. Because it can be used by many different bots, though, it can't just go in your bot's page.

I do see it as being useful, though. I am going to approve this as a Sample, because of how much an oddball it is and that it doesn't really fit anywhere else.

EDIT:
Do me a favor and attach a screenshot or something of the BNet lobby or something, since this will be in Samples. I'll approve it when you do so.

Anachron 10-13-2009 08:32 AM

Am I the only one who thinks this is kind of useless? There already is a banlist, and I highly doubt this is a good idea at all.

Strilanc 10-13-2009 02:43 PM

Quote:

Originally Posted by Anachron
Am I the only one who thinks this is kind of useless? There already is a banlist, and I highly doubt this is a good idea at all.


I'm having a hard time formulating a reply to your question. I can't figure out what you must think this system does, or what you must think banlist does.

Quote:

Originally Posted by Rising_Dusk
EDIT:
Do me a favor and attach a screenshot or something of the BNet lobby or something, since this will be in Samples. I'll approve it when you do so.


I'll attach an icon.

Anachron 10-13-2009 02:55 PM

Quote:

This library allows the bot to communicate with your map by encoding characters into players' handicaps (idea by Varlock). Warcraft 3 normally only allows 6 possible handicaps, but bots can specify 256 different values. By encoding the original handicap inside the larger handicap, and only performing the encoding just before the map starts, players don't even realize their handicap was temporarily mutilated.
I guess this is what you meant, and I highly doubt someone needs this,.. as most don't have bots.

Rising_Dusk 10-13-2009 03:01 PM

You'd be surprised at how extensive a segment of the community uses GHost or other bots adhering to this standard.

Approved.

Anachron 10-13-2009 03:12 PM

Hmm,.. Seems like that. Never found out whats so good at having stuff like GHost,.. but it seems like its used nowadays.

I guess I will have to check it out, so I am getting to know what this really does.


All times are GMT. The time now is 05:41 PM.

Powered by vBulletin (Copyright ©2000 - 2020, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services