Naming conventions for subroutines

pier4r
Skynet
Skynet
Posts: 3390

Naming conventions for subroutines

Post#1 » 04 Feb 2017, 11:18

While I collected some already in the FAQ, i have a couple of questions.

How do you name subroutines and, more importantly, how do you highlight the usage of tags to keep track of them?

My first approach would be

XX bot_class description used_tags

XX = a double digit number for sorting priority
bot_class = as (assault), sn (sinper), sg (shotgun), mg, kt (generic kill them all), bs (generic best score)
description = a short description
used_tags = example: bt45 (bot tags 4 and 5) or but4 (bot untag4), or ttE (team tagE)
http://www.reddit.com/r/Gladiabots/wiki/players/pier4r_nvidia_shield_k1 -> Gladiabots CHAT, stats, insights and more ;

User avatar
Kanishka
Skynet
Skynet
Posts: 1421
Contact:

Re: Naming conventions for subroutines

Post#2 » 04 Feb 2017, 12:49

I once used:
st.ai.function

st -- indicates it is a Sub-Tree
ai -- name of compatible ai
function -- what it's supposed to do

More sophisticated:
st.tn.bot_class.position.behaviour
st -- Sub-Tree
tn -- TierN, where n is a digit. A specific Tier of AIs has the same tag format, for example, all the Tier 3 AIs may use TagC for Captain. For compatibility.
bot_class -- for bot specific behavior
position -- typically center or flank. More positions could be used, though.
behaviour -- Retreat, aggressive, rush, counter, etc.
Fixes break an AI more than bugs do. :ugeek:

Gladiabots Off-Topic Chat


My Stats: Kanishka_RN3;Kanishka_MiPad

Hamster
Script
Script
Posts: 28

Re: Naming conventions for subroutines

Post#3 » 04 Feb 2017, 19:09

For me I have a simple naming convention: I use 3chr strings (eg: "_^_") at the start. This has two features this keeps all the subroutines relating to that AI in order in the list. (so my sniper has the "~~^" prefix, and my shotgun has "~^~". After the Prefix I'll then have some info about it (e.g "atk(shortrange)".

since the the list is alphabetical, my main ai for that cluster of subroutines is just called "! main" which puts it top of the list (for that group).

so:

    ~^~ !Main(sniper)
    ~^~ atk(longrange)
    ~^~ retreat!
    +++ !Main(shotgun)
    +++ atk(shortrange)
    +++ push balls

    etc.

pier4r
Skynet
Skynet
Posts: 3390

Re: Naming conventions for subroutines

Post#4 » 04 Feb 2017, 19:27

Wouldn't be easier with numbers at the start?
http://www.reddit.com/r/Gladiabots/wiki/players/pier4r_nvidia_shield_k1 -> Gladiabots CHAT, stats, insights and more ;

User avatar
Kanishka
Skynet
Skynet
Posts: 1421
Contact:

Re: Naming conventions for subroutines

Post#5 » 05 Feb 2017, 10:20

Characters are placed even before numbers.
Fixes break an AI more than bugs do. :ugeek:

Gladiabots Off-Topic Chat


My Stats: Kanishka_RN3;Kanishka_MiPad

pier4r
Skynet
Skynet
Posts: 3390

Re: Naming conventions for subroutines

Post#6 » 05 Feb 2017, 10:37

yes I know, but If you never use special characters, and you just use number, is more natural. I mean I remember that 0 comes before 1, but i don't remember whether ! comes before % or other symbols. I should always look up.
http://www.reddit.com/r/Gladiabots/wiki/players/pier4r_nvidia_shield_k1 -> Gladiabots CHAT, stats, insights and more ;

User avatar
Kanishka
Skynet
Skynet
Posts: 1421
Contact:

Re: Naming conventions for subroutines

Post#7 » 05 Feb 2017, 12:36

That's true.
Fixes break an AI more than bugs do. :ugeek:

Gladiabots Off-Topic Chat


My Stats: Kanishka_RN3;Kanishka_MiPad

tinnvec
Hello World
Hello World
Posts: 7

Re: Naming conventions for subroutines

Post#8 » 15 Mar 2017, 14:54

I'm striving for a single generic AI, so I have one called "_main" and then I tier my subroutines with numbers.

So subroutines that _main calls start with a 0, subroutines that 0xxx subroutines call start with 1, etc. If I get to more than 10 tiers, I can start with lowercase letters since all my subroutines start with a capital letter (I think 10 tiers would be insane over-complexity though so I don't intend to get there).

It may not be perfect, but it's a system the works pretty well for me so far.

harthag
Automaton
Automaton
Posts: 197

Re: Naming conventions for subroutines

Post#9 » 15 Mar 2017, 15:17

I use a single letter code, C, T, X, or Z, followed by an underscore.

C = main, functiinal AI (I picked the letter "c" to stand for "combo", as in "combination of subroutines")

T = test. I use this for testing very specific functions, usually no more than 4 nodes at a time

X = a complete subroutine, not just a scrap like "T" above, but still in testing phase

Z = completed subroutine implemented or ready to implement in an active "C" level AI

Some examples:
C_Main AI
Z_attack
X_new evade
T_target tracking

pier4r
Skynet
Skynet
Posts: 3390

Re: Naming conventions for subroutines

Post#10 » 15 Mar 2017, 17:29

tinnvec wrote:I'm striving for a single generic AI, so I have one called "_main" and then I tier my subroutines with numbers.

So subroutines that _main calls start with a 0, subroutines that 0xxx subroutines call start with 1, etc. If I get to more than 10 tiers, I can start with lowercase letters since all my subroutines start with a capital letter (I think 10 tiers would be insane over-complexity though so I don't intend to get there).

It may not be perfect, but it's a system the works pretty well for me so far.

That is a good idea.
http://www.reddit.com/r/Gladiabots/wiki/players/pier4r_nvidia_shield_k1 -> Gladiabots CHAT, stats, insights and more ;

User avatar
Ritter Runkel
Neural Network
Neural Network
Posts: 498

Re: Naming conventions for subroutines

Post#11 » 15 Mar 2017, 23:59

I use:

.o0 <task>
.oM <map>
.oS <map>.<subtree>

mcompany
Autonomous Entity
Autonomous Entity
Posts: 872

Re: Naming conventions for subroutines

Post#12 » 16 Mar 2017, 02:48

I'm currently doing them as ”00_”, ”01_”, ”02_”, etc. as prefixes for main AIs and ”10_”, ”11_”, etc. as prefixes for subtrees (although, 10 attacking subtrees are the only one​ of this category getting used)

Return to “Strategies”

Who is online

Users browsing this forum: No registered users and 1 guest