HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

UnitIds

10-18-2009, 01:15 PM#1
Tot
I wanna make a small script, which loops through all possible unitids an checks if the id is valid.

Probleme 1)
how to check if id is valid (creating units with invalid id's crushes the game)?

Probleme 2)
how to get all possible combinations?
like this?
Collapse JASS:
function GetBit takes integer i returns integer
     if i==1 then
          return '1'
     ...
     elseif i==... then
          return 'c'
     ...
     endif
     return ' '
endfunction

function BruteForceIds takes nothing returns nothing
     local integer i=0
     local integer j=0
     local integer k=0
     local integer l=0
     local integer id
     loop
          exitwhen i>...
          loop
               exitwhen j>...
               loop
                    exitwhen k>...
                    loop
                         exitwhen l>...
                         set id=GetBit(i)*1000+GetBit(j)*100+GetBit(k)*10+GetBit(l)
                         set l=l+1
                    endloop
                    set k=k+1
               endloop
               set j=j+1
          endloop
          set i=i+1
     endloop
endfunction

blizz's id-system + me = me
10-18-2009, 01:31 PM#2
Earth-Fury
If you mean checking if every possible rawcode is valid, then you don't. It would take 4294967296 iterations to check all possible rawcodes, as rawcodes are 32 bit integers. Even if you limit yourself to printable ASCII, that's still about 3755991008 iterations. (At 100000 iterations per second, which you likely won't reach, it would take 10 hours to execute. That's using the smaller of the two potential value counts.)

Why do you want to do this?
10-18-2009, 01:49 PM#3
Tot
I wanna make a system that stores all valid unitypes in an array/table/list/whatever for my MOW-map (link in sig)

I wanna bruteforce them to reach all possible ones and they are way to much to enter them by hand

The only chars I need to bf are:
abcdefghijklmnopqrstuvwxyz1234567890 and this+ABCDEFGHIJKLMNOPQRSTUVWXYZ for the first place
--> 62*36*36*36 combinations --> 2892672 combinations

I can make some limitations (first palce has to be heounHEOUN)
--> 10*36*36*36 combinations --> 466560 combinations

At 100000 iterations per second:
1) ca 28.9 sec ~~29 sec = 1/2 min

2) ca 4.7 sec ~~ 5 sec = 1/12 min


--> is possible in a waitable time
10-18-2009, 03:04 PM#4
Rising_Dusk
You still didn't quite explain why you need all valid ID's in an array. I mean, that's useless, because you're going to have an O(n) search through the whole array to determine if something is inside it. That means you're going to be suiciding processing power all over the place.

Just don't do it, man, just don't.
10-18-2009, 03:16 PM#5
Tot
Quote:
Originally Posted by Rising_Dusk
You still didn't quite explain why you need all valid ID's in an array. I mean, that's useless, because you're going to have an O(n) search through the whole array to determine if something is inside it. That means you're going to be suiciding processing power all over the place.

Just don't do it, man, just don't.

I know that I'm killing my processor
I don't have to determine if an id is inside, cause i've all valid ones in the array and for checking if an id is valid I've a function (used to get all possible ones)

That's not useless
EXAMPLE: PandaMines AMHS
I'ven't to register each type manually, I've only to

Collapse JASS:
local integer i=0
loop
    exitwhen i==NUMBER_OF_VALID_IDS
    call RegisterUnitShadow(ID_ARRAY[i],...)
    set i=i+1
endloop

and this can waste some processing time, cause it's only run once

--> can be used to setup all systemes that have some registerunittype-function floating around

==================================================
I only need to know how to check if an id is valid and how you can calcualte with them
10-18-2009, 03:19 PM#6
Rising_Dusk
Whatever you do, please don't submit this. I don't want to have to honestly review this. It'll just hurt your feelings.
10-18-2009, 03:33 PM#7
PurplePoot
The correct formula for the rawcode ABCD is:

'A'*0x1000000 + 'B'*0x10000 + 'C'*0x100 + 'D'

Also, for the love of god don't do this.
10-18-2009, 03:39 PM#8
Tot
Quote:
Originally Posted by Rising_Dusk
If it works as it's supposed to do, I'll probably under special circumstances eventually submit this

Quote:
Originally Posted by PurplePoot
The correct formula for the rawcode ABCD is:

'A'*0x1000000 + 'B'*0x10000 + 'C'*0x100 + 'D'
thanks

EDIT1:

everything works

EDIT2:

hrmmm....not everything works fine...

Collapse JASS:
private function GetBit takes integer w, boolean first returns string
        local string which="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        if FIRST_BASIC==true and first==true then
            set which="heounHEOUN"
        elseif FIRST_NO_NUMERICS==true and first==true then
            set which="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
        endif
        if ONLY_FIRST_CAPITAL==true and first==false then
            set which="abcdefghijklmnopqrstuvwxyz0123456789"
        endif
        return SubString(which,w,w+1)
    endfunction

this function returns for every intege w from 0 to 100 null, for every!
I know, that the probleme is somewhere in the return Substring(which,w,w+1)-part, but don't know exactly
10-19-2009, 12:03 AM#9
TEC_Ghost
Dear God,

Help us all...

Sincerly, TEC_Ghost.
10-19-2009, 05:38 AM#10
Seshiro
Please use GMSI or something kinda zjaz would be easier, more performant and not that retarded!
Greez
10-19-2009, 07:01 AM#11
DioD
GetObjectName(RAWCODE) != NULL
10-19-2009, 07:37 AM#12
Anachron
Never ever do this!!

Why would you need to load all of the possible combinations?

I mean, even if you write Data into those indexes, its still enough to just create the Data if you need it.

And with never, I really mean NEVER EVER.

In my last Arena, Templar Arena, I had to load about 300 spells, items and abilities at mapstart, and hell yes, the computer freezes even then. Now think about when you load tons of hundreds of thousands of IDs.
10-19-2009, 08:56 AM#13
Captain Griffen
If you must do this, don't touch strings. Use 4 arrays, holding each of the possible values, and loop around them.
10-19-2009, 11:29 AM#14
Tot
Quote:
Originally Posted by Seshiro
Please use GMSI or something kinda zjaz would be easier, more performant and not that retarded!
Greez

hä?

Quote:
Originally Posted by DioD
GetObjectName(RAWCODE) != NULL

thx

Quote:
Originally Posted by Anachron
Never ever do this!!

Why would you need to load all of the possible combinations?

I mean, even if you write Data into those indexes, its still enough to just create the Data if you need it.

And with never, I really mean NEVER EVER.

In my last Arena, Templar Arena, I had to load about 300 spells, items and abilities at mapstart, and hell yes, the computer freezes even then. Now think about when you load tons of hundreds of thousands of IDs.

it would not be run everytime the map is started, it'll be only run once, then stores all possible id's somewhere else (problbla .txt-file, if i figure out how to get/set data in there)

Quote:
Originally Posted by Captain Griffen
If you must do this, don't touch strings. Use 4 arrays, holding each of the possible values, and loop around them.

ok, I'll try it


ehm, how to save data generated via vJass in a file inside the map and get the datas back if they are needed (I know there is something around with .slk, but they are not inside the map --> not end-user friendly)
10-19-2009, 11:53 AM#15
Anachron
Quote:
it would not be run everytime the map is started, it'll be only run once, then stores all possible id's somewhere else (problbla .txt-file, if i figure out how to get/set data in there)
There is no way.

Just think about it:
  • Would change the filesize
  • So it changes the checksum
  • So it can beat up the 8mb limit
  • It could be used by hackers to create viruses on your pc.
  • Its wc3. It has its limits.
  • See above.