• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

The Filtering System

Level 4
Joined
Jul 4, 2012
Messages
78
lol, why graveyard? i'm not leaving man XD anyways you started it Nestharus, "using an integer and bitwise is smarter", you don't remember? :)) i am studying dentistry not mathematics, so i do not understand a bit of algorithms so don't blame me for giving up too soon :) anyway i'm not giving up, just making work a bit less for now, and any resource sharing two owners will be graveyarded? o_O

@chobibo
the hex one is a bit confusing, that's why i'm looking for someone who can do it the better way, but others thought i'm leaving my resource...
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I was wrong anyway, but I bet you could use and for this. As I understand it, this uses bit-flagging. i.e:

bit 1=dead, bit 2=alive, bit 3=hero, bit 4=non-hero

if the argument wanted to filter dead units
argument 0b 0001 and 0b 1111 = 0b 0001

using a single loop and a boolean variable, you could store the required filters.

EDIT: Scrap what I just said, it's too inefficient (run-time).
 
Level 4
Joined
Jul 4, 2012
Messages
78
hey, an essential question, how to search for the left most bit? do i have to use the nested ifs like:

for example: 0x40 > hex and 0x20 < hex ? if you don't get what imean, here is the full explanation:

imagine the hex has only 4 options which is one hex digit, i want to search for the leftmost digit, i must do it like this way or not?

JASS:
loop
    exitwhen hex == 0
        if hex > 0x4 then
            if hex > 0x4 and hex < 0x8 then
                if not cond3 then
                    return false
                endif
                set hex = hex - 0x4
            elseif hex > 0x8 and hex < 0x10 then
                if not cond4 then
                    return false
                endif
                set hex= hex - 0x8
            endif
                .
                .
                .
                .

by the way, Nestharus, i recommend you to say the thing fully so i can learn it and after i learn it, i can finish this project and you will get rid of me and my countless questions and infinite stupidity :D once and for all xD,..............
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
You're getting closer ^)^

Code:
example

0x0
0x1
0x2
0x4
0x8
0x10
0x20
0x40
0x80
0x100
0x200
0x400
0x800
0x1000
0x2000
0x4000
0x8000

17 bits

0x1 (middle 3)
0x2 (middle 4)
0x4 (middle 2)
0x8 (middle 2)
0x10 (middle 4)
0x20 (middle 3)
0x40 (middle 4)

0x80 (middle)

0x100 (middle 4)
0x200 (middle 3)
0x400 (middle 4)
0x800 (middle 2)
0x1000 (middle 2)
0x2000 (middle 4)
0x4000 (middle 3)
0x8000 (middle 4)

if (value < 0x80) then
	if (value < 0x8) then
		if (value < 0x2) then
			if (value == 0x1) then
				//0x1
			else
				//0x0
			endif
		elseif (value == 0x2) then
			//0x2
			set value = value - 0x2
		else
			//0x4
			set value = value - 0x4
		endif
	elseif (value < 0x20) then
		if (value == 0x8) then
			//0x8
		else
			//0x10
			set value = value - 0x10
		endif
	elseif (value == 0x20) then
		//0x20
	else
		//0x40
	endif
elseif (value < 0x800) then
	
elseif (value < 0x4000) then
	
etc

very rough, improve it

loop through above if statement structure (improve it ofc) until value == 0
 
Level 4
Joined
Jul 4, 2012
Messages
78
i'm currently in university xD

so this is the final thing? if yes i'll begin my work immediately when i reach my laptop xD

ty as always Nestharus, all credits goes to you, the writing of this system is made by me xD

Edit: wait, wait, something is wrong here, you only considered the pure bits alone not their combinations, for example 0x21 falls in none of these ifs, maybe yo uchange those '=='? or this operates someother way?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Here is another thingie

Code:
example

0x1
0x2
0x4
0x8
0x10
0x20
0x40
0x80
0x100
0x200
0x400
0x800
0x1000
0x2000
0x4000
0x8000


0x1 (middle 4)
0x2 (middle 3)
0x4 (middle 4)

0x8 (middle 2)

0x10 (middle 4)
0x20 (middle 3)
0x40 (middle 4)

0x80 (middle)
0x100 (middle)

0x200 (middle 4)
0x400 (middle 3)
0x800 (middle 4)

0x1000 (middle 2)

0x2000 (middle 4)
0x4000 (middle 3)
0x8000 (middle 4)

loop
exitwhen value == 0

if (value < 0x80) then
	if (value < 0x8) then
		if (value < 0x2) then
			//0x1
			set value = value - 0x1
		elseif (value == 0x2) then
			//0x2
			set value = value - 0x2
		else
			//0x4
			set value = value - 0x4
		endif
	elseif (value < 0x20) then
		//0x10
		set value = value - 0x10
	elseif (value == 0x20) then
		//0x20
		set value = value - 0x20
	else
		//0x40
		set value = value - 0x40
	endif
elseif (value < 0x1000) then
	if (value < 0x400) then
		if (value == 0x100) then
			//0x100
			set value = value - 0x100
		else
			//0x200
			set value = value - 0x200
		endif
	elseif (value == 0x400) then
		//0x400
		set value = value - 0x400
	else
		//0x800
		set value = value - 0x800
elseif (value < 0x4000) then
	if (value == 0x1000) then
		//0x1000
		set value = value - 0x1000
	else
		//0x2000
		set value = value - 0x2000
	endif
elseif (value == 0x4000) then
	//0x4000
	set value = value - 0x4000
else
	//0x8000
	set value = value - 0x8000
endif

endloop


alternatively


loop
	if (value/bits[i] == 1) then
		set value = value - bits[i]
	endif
	exitwhen i == 0
	set i = i - 1
endloop


I personally think that the approach of having 32 if statements, 1 for each bit, is better.

With a binary search, you have n log n. If you have 17 bits, that's going to be more than 32 if statement checks ;o.

If you just do the 32, you just have 32

Be sure to use constants, not bits. Also don't use a loop.


This is only the case because you have n filters. If only 1 filter could be active at a time, then the if statement tree approach or a binary search would be better.
 
Level 4
Joined
Jul 4, 2012
Messages
78
o_O, i think you typed it in 20 seconds or less XD

now it makes sense :D ( and also blows mind out :D)

loop
if (value/bits == 1) then
set value = value - bits
endif
exitwhen i == 0
set i = i - 1
endloop



that's what i said at first XD and you said : 'your loop is terrible ' :D

edit:

well, i'll read what you said in home with full focus and will see what i can do..... hmmmm... " DON'T USE A LOOP"......hmmmmmm..... oh....... something is coming out....oh............ ahhhhhhhh! a spark in my mind! i get something... will work on it when reached home , ty Nestharus
 
Level 4
Joined
Jul 4, 2012
Messages
78
i have come to 2 methods:

the hex-binary_search method, with 453 executes at a time,

JASS:
function UnitFilter takes unit whichUnit, unit sourceUnit, integer filter returns boolean
            loop
                exitwhen filter == 0
                    if filter < 0x4000 then
                        if filter < 0x80 then
                            if filter < 0x10 then
                                if filter < 0x4 then
                                    if filter < 0x2 then
                                        //1
                                        set filter = filter - 0x1
                                    else
                                        //2
                                        set filter = filter - 0x2
                                    endif
                                else
                                    if filter < 0x8 then
                                        //3
                                        set filter = filter - 0x4
                                    else
                                        //4
                                        set filter = filter - 0x8
                                    endif
                                endif
                            else
                                if filter < 0x20 then
                                    //5
                                    set filter = filter - 0x10
                                elseif filter >= 0x20 and filter < 0x40 then
                                    //6
                                    set filter = filter - 0x20
                                else
                                    //7
                                    set filter = filter - 0x40
                                endif
                            endif
                        else
                            if filter < 0x800 then
                                if filter < 0x200 then
                                    if filter < 0x100 then
                                        //8
                                        set filter = filter - 0x80
                                    else
                                        //9
                                        set filter = filter - 0x100
                                    endif
                                else
                                    if filter < 0x400 then
                                        //10
                                        set filter = filter - 0x200
                                    else
                                        //11
                                        set filter = filter - 0x400
                                    endif
                                endif
                            else
                                if filter < 0x1000 then
                                    //12
                                    set filter = filter - 0x800
                                elseif filter >= 0x1000 and filter < 0x2000 then
                                    //13
                                    set filter = filter - 0x1000
                                else
                                    //14
                                    set filter = filter - 0x2000
                                endif
                            endif
                        endif
                    else
                        if filter < 0x200000 then
                            if filter < 0x40000 then
                                if filter < 0x10000 then
                                    if filter < 0x8000 then
                                        //15
                                        set filter = filter - 0x4000
                                    else
                                        //16
                                        set filter = filter - 0x8000
                                    endif
                                else
                                    if filter < 0x20000 then
                                        //17
                                        set filter = filter - 0x10000
                                    else
                                        //18
                                        set filter = filter - 0x20000
                                    endif
                                endif
                            else
                                if filter < 0x80000 then
                                    //19
                                    set filter = filter - 0x40000
                                elseif filter >= 0x80000 and filter < 0x100000 then
                                    //20
                                    set filter = filter - 0x80000
                                else
                                    //21
                                    set filter = filter - 0x100000
                                endif
                            endif
                        else
                            if filter < 0x2000000 then
                                if filter < 0x800000 then
                                    if filter < 0x400000 then
                                        //22
                                        set filter = filter - 0x200000
                                    else
                                        //23
                                        set filter = filter - 0x400000
                                    endif
                                else
                                    if filter < 0x1000000 then
                                        //24
                                        set filter = filter - 0x800000
                                    else
                                        //25
                                        set filter = filter - 0x1000000
                                    endif
                                endif
                            else
                                if filter < 0x4000000 then
                                    //26
                                    set filter = filter - 0x2000000
                                elseif filter >= 0x4000000 and filter < 0x8000000 then
                                    //27
                                    set filter = filter - 0x4000000
                                else
                                    //28
                                    set filter = filter - 0x8000000
                                endif
                            endif
                        endif
                    endif
            endloop
            if GetUnitAbilityLevel(whichUnit,udg_ABILITY_DUMMY_CLASSIFICATOR)!=0 then
                return false
            endif
            return true
        endfunction

and the hex-if_list method with 468 executes at a time when contains filters from all ranges, 539 executes when containing filters from the first half (the most useful filters moved to first half)

JASS:
function UnitFilter takes unit whichUnit, unit sourceUnit, integer filter returns boolean
            if filter >= 0x2000 then
                if filter >= 0x1000000 then
                    set filter = filter - 0x1000000
                    
                endif
                if filter >= 0x800000 then
                    set filter = filter - 0x800000
                    
                endif
                if filter >= 0x400000 then
                    set filter = filter - 0x40000
                    
                endif
                if filter >= 0x200000 then
                    set filter = filter - 0x200000
                    
                endif
                if filter >= 0x100000 then
                    set filter = filter - 0x100000
                    
                endif
                if filter >= 0x80000 then
                    set filter = filter - 0x80000
                    
                endif
                if filter >= 0x40000 then
                    set filter = filter - 0x40000
                    
                endif
                if filter >= 0x20000 then
                    set filter = filter - 0x20000
                    
                endif
                if filter >= 0x10000 then
                    set filter = filter - 0x10000
                    
                endif
                if filter >= 0x8000 then
                    set filter = filter - 0x8000
                    
                endif
                if filter >= 0x4000 then
                    set filter = filter - 0x4000
                    
                endif
                if filter >= 0x2000 then
                    set filter = filter - 0x2000
                    
                endif
            endif
            if filter < 0x2000 then
                if filter >= 0x1000 then
                    set filter = filter - 0x1000
                    
                endif
                if filter >= 0x800 then
                    set filter = filter - 0x800
                    
                endif
                if filter >= 0x400 then
                    set filter = filter - 0x400
                    
                endif
                if filter >= 0x200 then
                    set filter = filter - 0x200
                    
                endif
                if filter >= 0x100 then
                    set filter = filter - 0x100
                    
                endif
                if filter >= 0x80 then
                    set filter = filter - 0x80
                    
                endif
                if filter >= 0x40 then
                    set filter = filter - 0x40
                    
                endif
                if filter >= 0x20 then
                    set filter = filter - 0x20
                    
                endif
                if filter >= 0x10 then
                    set filter = filter - 0x10
                    
                endif
                if filter >= 0x8 then
                    set filter = filter - 0x8
                    
                endif
                if filter >= 0x4 then
                    set filter = filter - 0x4
                    
                endif
                if filter >= 0x2 then
                    set filter = filter - 0x2
                    
                endif
                if filter == 0x1 then
                    set filter = filter - 0x1
                    
                endif
            endif
            if GetUnitAbilityLevel(whichUnit,udg_ABILITY_DUMMY_CLASSIFICATOR)!=0 then
                return false
            endif
            return true
        endfunction

note that the executes at a time for other previous 2 methods was 326 ( number and letter ) and 497 (2 digit number).

however, there is an important note, as Nestharus said, this is multi-filter, so if a user wants to filter units by 8 conditions, the first method [hex-binary_search] must
be repeated 8 times, each contains 6 ifs that equals to 56 ifs; but the second method [hex-if_list] only repeats once, and contains 28 ifs, that is half. all other methods except the hex-if_list contain
loops so the repeats apply to each one but this method will not repeat, and if used at its first most-useful conditions, it will have approximately 2x of its normal speed that equals to 14 ifs in the previous example.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Is it not possible to use the multi-filter once and get the desired value? I've read all the pages, I couldn't understand a thing lol.
 
Level 4
Joined
Jul 4, 2012
Messages
78
ok this is the final revision i guess, Nestharus do you accept it? :D
also i improved my benchmark trigger and did the execution counts again, the real difference is now visible :

(Ascending Sort)

currentPosition : 267 (yeah this one really sux [ "no currentPos" said Nestharus])

1 digit number or letter : 542

hex-binary_search : 1045

2 digit number : 1239

hex-if_list : 1075 (containing first to last bits [ the whole range ]) - 1538 (containing the first half of bits [ half range of bits; turbo mode])

and this the final hex-if_list (if approved by Nestharus ofc :D) :

JASS:
function UnitFilter takes unit whichUnit, unit sourceUnit, integer filter returns boolean
            set filter = filter + 0x1
            if filter > 0x2000 then
                if filter > 0x1000000 then
                    set filter = filter - 0x1000000
                    
                endif
                if filter > 0x800000 then
                    set filter = filter - 0x800000
                    
                endif
                if filter > 0x400000 then
                    set filter = filter - 0x40000
                    
                endif
                if filter > 0x200000 then
                    set filter = filter - 0x200000
                    
                endif
                if filter > 0x100000 then
                    set filter = filter - 0x100000
                    
                endif
                if filter > 0x80000 then
                    set filter = filter - 0x80000
                    
                endif
                if filter > 0x40000 then
                    set filter = filter - 0x40000
                    
                endif
                if filter > 0x20000 then
                    set filter = filter - 0x20000
                    
                endif
                if filter > 0x10000 then
                    set filter = filter - 0x10000
                    
                endif
                if filter > 0x8000 then
                    set filter = filter - 0x8000
                    
                endif
                if filter > 0x4000 then
                    set filter = filter - 0x4000
                    
                endif
                if filter > 0x2000 then
                    set filter = filter - 0x2000
                    
                endif
            endif
            if filter < 0x2001 then
                if filter > 0x1000 then
                    set filter = filter - 0x1000
                    
                endif
                if filter > 0x800 then
                    set filter = filter - 0x800
                    
                endif
                if filter > 0x400 then
                    set filter = filter - 0x400
                    
                endif
                if filter > 0x200 then
                    set filter = filter - 0x200
                    
                endif
                if filter > 0x100 then
                    set filter = filter - 0x100
                    
                endif
                if filter > 0x80 then
                    set filter = filter - 0x80
                    
                endif
                if filter > 0x40 then
                    set filter = filter - 0x40
                    
                endif
                if filter > 0x20 then
                    set filter = filter - 0x20
                    
                endif
                if filter > 0x10 then
                    set filter = filter - 0x10
                    
                endif
                if filter > 0x8 then
                    set filter = filter - 0x8
                    
                endif
                if filter > 0x4 then
                    set filter = filter - 0x4
                    
                endif
                if filter > 0x2 then
                    set filter = filter - 0x2
                    
                endif
                if filter > 0x1 then
                    set filter = filter - 0x1
                    
                endif
            endif
            if GetUnitAbilityLevel(whichUnit,udg_ABILITY_DUMMY_CLASSIFICATOR)!=0 then
                return false
            endif
            return true
        endfunction

Nestharus, by the way is there a limit on first post size? (the main post; on this thread, the one that contains the code of Filtering System)?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I'm not a part of the staff at THW, mag is the one that runs JASS section right now =)


Also, you'd need way more to hit the character limit


You need to explain why you have 3 args here and improve your API next though

function UnitFilter takes unit whichUnit, unit sourceUnit, integer filter returns boolean


You also need an API listing. Look at comment header thread to see a good example
 
Level 4
Joined
Jul 4, 2012
Messages
78
i know that you are not the moderator of here, by approve i mean you finally accept it as the final algorithm :)

which unit is unit being filtered, source unit is the unit used for checking visibility and alliance which can be passed as null if those checks are not going to be made, and filter for the filter hex :)

i'm currently busy with Anatomy, Histology (Junqueira), Bio Chemistry (Lehninjer and Harper), Embrylogy (Longman), so i have a little time for writing API :D, but i will do it as fast as i can.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,467
This can use some more synergy with the handle IDs of the unittypes themselves. Below is a list of all the common.j listing for unitttype handle ID's.

JASS:
    constant unittype UNIT_TYPE_HERO                        = ConvertUnitType(0)
    constant unittype UNIT_TYPE_DEAD                        = ConvertUnitType(1)
    constant unittype UNIT_TYPE_STRUCTURE                   = ConvertUnitType(2)

    constant unittype UNIT_TYPE_FLYING                      = ConvertUnitType(3)
    constant unittype UNIT_TYPE_GROUND                      = ConvertUnitType(4)

    constant unittype UNIT_TYPE_ATTACKS_FLYING              = ConvertUnitType(5)
    constant unittype UNIT_TYPE_ATTACKS_GROUND              = ConvertUnitType(6)

    constant unittype UNIT_TYPE_MELEE_ATTACKER              = ConvertUnitType(7)
    constant unittype UNIT_TYPE_RANGED_ATTACKER             = ConvertUnitType(8)

    constant unittype UNIT_TYPE_GIANT                       = ConvertUnitType(9)
    constant unittype UNIT_TYPE_SUMMONED                    = ConvertUnitType(10)
    constant unittype UNIT_TYPE_STUNNED                     = ConvertUnitType(11)
    constant unittype UNIT_TYPE_PLAGUED                     = ConvertUnitType(12)
    constant unittype UNIT_TYPE_SNARED                      = ConvertUnitType(13)

    constant unittype UNIT_TYPE_UNDEAD                      = ConvertUnitType(14)
    constant unittype UNIT_TYPE_MECHANICAL                  = ConvertUnitType(15)
    constant unittype UNIT_TYPE_PEON                        = ConvertUnitType(16)
    constant unittype UNIT_TYPE_SAPPER                      = ConvertUnitType(17)
    constant unittype UNIT_TYPE_TOWNHALL                    = ConvertUnitType(18)    
    constant unittype UNIT_TYPE_ANCIENT                     = ConvertUnitType(19)
    
    constant unittype UNIT_TYPE_TAUREN                      = ConvertUnitType(20)
    constant unittype UNIT_TYPE_POISONED                    = ConvertUnitType(21)
    constant unittype UNIT_TYPE_POLYMORPHED                 = ConvertUnitType(22)
    constant unittype UNIT_TYPE_SLEEPING                    = ConvertUnitType(23)
    constant unittype UNIT_TYPE_RESISTANT                   = ConvertUnitType(24)
    constant unittype UNIT_TYPE_ETHEREAL                    = ConvertUnitType(25)
    constant unittype UNIT_TYPE_MAGIC_IMMUNE                = ConvertUnitType(26)
 
Level 4
Joined
Jul 4, 2012
Messages
78
can you explain more? the problem is that i don't know what those 'ConvertUnitType(x)' means and how i can use them, are they a special type of integer or something else, and problems like this :)

if you also give some advises, then this system is shaped by ideas of Nestharus, Magtheridon96 and Bribe ! such a wonder! 3 EXPERTS in a work xD

edit:
btw, this system is now in 20nd rank in total views :) (1142)
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
If you use GetHandleId on the unittype, you can get that integer out of it.

That'll kill this reouce. Not talking about performance, talking about the entire point of why this thing was made in the first place :\.


You can't add handles





As for using an array, yes, that should be done. It'll cut down your code by a lot. However, it will reduce performance, but don't worry so much about that =).

JASS:
loop
    loop
        exitwhen filter > powers[i]
        set i = i - 1
    endloop

    exitwhen filter == 1 or not IsUnitType(whichUnit, filterArray[i + 1])
    set filter = filter - powers[i + 1]
endloop

return true


If only there was a good way to just jump from bit to bit, but I don't know :\.


You can ofc try to do early break with filter == 1 so that you don't have to always iterate over 32 bits, but this'll make your worst case scenario worse.
 
Level 4
Joined
Jul 4, 2012
Messages
78
oh, come on, it seems that i have to update my system for at least 10 years... but i like your advise :) i'll work on it and see if something interesting comes out of it; but all of you must know that people don't really need to even take a look at algorithms or do something about them, only they have to know which conditions are available, and use them within an 'if', if there were a way to hide the code, i would hide all of algorithm :) so people don't even think about messing with them xD they should take a look at algorithms when they want to learn something from them.]

all i said above didn't mean that i don't like ideas! i LOVE them, so please keep on saying any idea and advise/hint you have :D

by the way, i think this system will never get approved, because the type of this system is somehow able to keep getting improved for ever xD
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
First, try reading through post #2

http://www.hiveworkshop.com/forums/jass-resources-412/repo-comment-headers-192184/

it'll help improve your documentation a lot

once you do that, I'll look at it again

as it stands, I don't want to read this, you have way too much text and no API listing

edit
and please remove the 2-digit number version. Imagine a resource using this. If one uses 2-digit and another uses another version and so on.. it just turns into a mess.

2-digit version only has cons compared to the others, so I don't see why it should be approved :\.

edit
and the final thing ofc is..

if (IsUnitType(whichUnit, UNIT_TYPE_HERO) and IsUnitVisible(whichUnit, whichPlayer)) then

vs

if (UnitFilter(whichUnit, null, UNIT_TYPE_HERO_FILTER + UNIT_VISIBLE_FILTER)) then

There is the pro of only using whichUnit once, but...



oh, and I saw your constants. Not good names. Use the standard JASS constant names so that we know what to type without having to look them up. Prefix or append them with something. I personally recommend the style I used there.

Also, change your weird sourceUnit thing to something like viewingPlayer.
 
Level 4
Joined
Jul 4, 2012
Messages
78
ATLAST! sorry for updating a bit late, i was taking mid-term exams at university.
ok i did what you said, check the new update.

edit
and the final thing ofc is..

if (IsUnitType(whichUnit, UNIT_TYPE_HERO) and IsUnitVisible(whichUnit, whichPlayer)) then

vs

if (UnitFilter(whichUnit, null, UNIT_TYPE_HERO_FILTER + UNIT_VISIBLE_FILTER)) then

There is the pro of only using whichUnit once, but...

still don't getting what you mean ...
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,467
I don't see a need for this personally but it's a resource. Change the functions to "public" or change the function names manually so that they line up with your constant prefix FX_, so instead of UnitFilter,ItemFilter,PlayerFilter, you have FS_UnitFilter,FS_ItemFilter,FS_PlayerFilter.

Additionally, your main argument for this resource is that it is efficient and saves lines of code - I am not sure of any of that. It would help you develop a user base if you gave an example comparing the traditional way of filtering to this system's way of filtering, so you can show a before-and-after comparison which will help sell your resource. I'm not approving this until you care about it a bit more, yourself, enough to position it better.
 
Level 4
Joined
Jul 4, 2012
Messages
78
Additionally, your main argument for this resource is that it is efficient and saves lines of code - I am not sure of any of that.

about efficiency, i give you guarantee that it is efficient, benchmark it if you like. about saving lines of code, unless you got a map like DotA that has tons of spells and each one of them needs at least two or more condition blocks, no it won't save because itself has 500 lines of script, but when you got a map like DotA, you will only write 2 line per block and if you write it for some spell, then it saves lines, also not only lines but ease of conditioning, for normal block you have to write each native with each's own argument list and parameters but with this you have to write only a filter's name which is about 10 to 15 characters. so i guess it saves a lot of script writing on huge maps.

i mean: if GetUnitLife>0.406 and IsUnitAlly(u,GetOwningPlayer(u2)== true and GetUnittype(u,UNIT_TYPE_HERO) and GetUnitType(u,UNIT_TYPE_UNDEAD) and ....
// actions
endif

VS

if UnitFilter(u,u2,FS_UNIT_ALIVE+FS_UNIT_ALLY+FS_UNIT_HERO+FS_UNIT_UNDEAD+....)
// actions
endif

also if i could, i would change thos FS_UNIT_ to something like FSU_ to further shorten the one line but Mag and Nes said it must make sense :)

I don't see a need for this personally but it's a resource. Change the functions to "public" or change the function names manually so that they line up with your constant prefix FX_, so instead of UnitFilter,ItemFilter,PlayerFilter, you have FS_UnitFilter,FS_ItemFilter,FS_PlayerFilter.
It would help you develop a user base if you gave an example comparing the traditional way of filtering to this system's way of filtering, so you can show a before-and-after comparison which will help sell your resource. I'm not approving this until you care about it a bit more, yourself, enough to position it better.

Agreed. I WILL DO THAT :) thank you.
 
The usefulness of this is not in the performance, it's in the convenience.

You throw away the need to use all these wierd functions in conjunction with each other in a boolean expression and what you get is a function that expresses your intent even more than you ever could.

UnitFilter(unit, viewing_player, COND_1 + COND_2 + COND_3 + COND_4)

The above statement expresses the intent to filter a unit from the standpoint of a viewing player based on a specified set of criterion and it requires less thinking than an explicit cascade of conditions binded by the (and) operator.

It's sweet, sweet syntax sugar that makes your code nicer to look at and easier to modify.

You can even combine the constants this system gives you to define constraints as constant integers. You can combine derivative constraints and what you gain is a set of constants that depend on each other giving you a maintainable constraint tree.

An arbitrary example:

JASS:
constant integer TARGETABLE = ENEMY + ALIVE
constant integer FREEZABLE = TARGETABLE + NOT_FROZEN
constant integer DEFROSTABLE = TARGETABLE + FROZEN
constant integer POISONABLE = TARGETABLE + NOT_POISONED + NOT_FROZEN
// ... more constraints.
// I'm not very creative.
 
Level 4
Joined
Jul 4, 2012
Messages
78
wow, nice describing Mag, I should put a link in main page to your post instead of that "the main purpose of filtering system was......" !
You can even combine the constants this system gives you to define constraints as constant integers. You can combine derivative constraints and what you gain is a set of constants that depend on each other giving you a maintainable constraint tree.

An arbitrary example:

JASS:
constant integer TARGETABLE = ENEMY + ALIVE
constant integer FREEZABLE = TARGETABLE + NOT_FROZEN
constant integer DEFROSTABLE = TARGETABLE + FROZEN
constant integer POISONABLE = TARGETABLE + NOT_POISONED + NOT_FROZEN
// ... more constraints.
// I'm not very creative.

o_O! i never even thought about that. that's nice! i can put a section in API which introduces this function to users so they can make their own constraints.... Thank you, Mag... as always. you advocated my resource even better than me :)
 
Level 4
Joined
Jul 4, 2012
Messages
78
i get the idea of classifying things from somewhere that i don't remember now, in there it was classificator XD ok i'll fix it.

Nes, you are mistaking, Before adding 0x1 to filter, the first if was filter > 0x1fff or filter >= 0x2000, after adding, it changed to filter > 0x2000; the second if was filter < 0x2000 that after adding 0x1, it changed to filter < 0x2001.
 
Top