Author Topic: The HCL Standard (map devs read this)  (Read 3976 times)

uakf.b

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
  • Karma: +86/-12
    • View Profile
The HCL Standard (map devs read this)
« on: December 14, 2013, 07:11:07 pm »
Original post by summer/Varlock

This thread is now about the HCL system as developed and explained in the posts below this one. It is used for passing a very limited amount of data from the bot to the map by encoding information in player handicaps. The intention is that it will be used to set game modes and other game settings when you want the bot to specify them rather than the players. Please read this thread for more information, including some example JASS code you can include in your map to use the HCL system.

Quick link to the JASS code: http://www.wc3c.net/showthread.php?p=1094560#post1094560

Library mirror, just in case:
Code: [Select]
///////////////////////////////////////////
/// 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
« Last Edit: December 14, 2013, 08:20:51 pm by uakf.b »