GroupPickRandomUnit isn't so random.

Builder Bob

Live free or don't
Reaction score
249
I tested your map. To me, it's very confusing what really happens in the beginning.

Regardless, I wrote the following
  • -ffa
  • -save :: I was given two different codes in the games I tried. The first game gave QHB-7ZF, while all games after I ended the game with Restart Mission would give 0H3-WMV. I have no idea why these codes should be given to me, but it doesn't seem to happen in any random way. When trying to start the game from the Warcraft 3 custom game menu again, I was given QHB-7ZF the frist game, and 0H3-WMV in all the games after Restart Mission, just like before.
  • -done :: I had to do this to get the game to start
  • -load QHB-7ZF :: gave Illusionist
  • -load 0H3-WMV :: gave Assault
 

cleeezzz

The Undead Ranger.
Reaction score
268
so its random or no?

it gives different codes because, the game sets your name to Bob_the_builder (new) and then that name carries over. so its a different save name, it only happens in restart game.

>-done :: I had to do this to get the game to start

sorry, when i posted the post above, that thread had an older version of the game mode select, the new one requires -done. also, whys it confusing? i thought the multiboard was pretty self explanatory. I highlighted -done in red just to catch your attention O_O
 

Builder Bob

Live free or don't
Reaction score
249
so its random or no?

It doesn't seem random, no.

also, whys it confusing? i thought the multiboard was pretty self explanatory. I highlighted -done in red just to catch your attention O_O

It's confusing due to many small things. Nothing that can't be figured out, but it could be more intuitive.

When the game starts, your camera is pointing at the middle of the map. This is fine all by itself. After all, you want as little disturbances as possible when the host chooses game mode. In the lower left of the map there is an AoW. Should I move my camera and use it now, or later?
- It would be better if it was hidden for the host until the game mode is chosen.


After I had chosen the game mode, and written -done, there was a lagspike (preloading units fixes this), and then nothing happened. I was thinking, "hmmm... how much longer should I wait?" for a few seconds before I decided to check my AoW again. "Ah, there are units here now!".
- Pan the camera to the units when they are usable to shorten this transition time.


When trying to select the archers (I didn't do this when using the save/load code), I noticed that only one of them was highlighted and had a 'choose unit' button. I couldn't understand why that was, so I looked around, trying to find out how I could choose the others.
I know now that only one archer is unlocked in the beginning, and that you must get points to unlock the rest.
- To let the player know immediately why he/she can't choose all archers, my suggestion is that you add a button to the archers that cannot be picked, saying something like: "This Hero is locked. You need X points to unlock it."


As you can see, they are no game breakers, only minor things. Even so, these were things that had me confused for a few seconds here and there. It's up to you whether the potential confusion is important to remove or not.
 

cleeezzz

The Undead Ranger.
Reaction score
268
>- It would be better if it was hidden for the host until the game mode is chosen.

im planning on using a fade filter, just havent got my hands on it yet

>- Pan the camera to the units when they are usable to shorten this transition time.
hmm ill add that right now
EDIT: done

>This Hero is locked. You need X points to unlock it.
ill try to add that too
EDIT: done


thanks

but back on topic, why isn't it random

EDIT: did a couple tests, 5 random ints at map init 1-100 proved that it IS random. but, this GroupPickRandomUnit does not give me a random unit. I also checked how many units were in the group, it listed 6 units, yet every time, its the illusionist archer. WHY

EDIT: i went to the extreme...

JASS:
            set g = NewGroup()
            call GroupEnumUnitsInRect( g, bj_mapInitialPlayableArea, Condition(function PrivateFilter))
            loop 
                exitwhen z == 21
                set RandomUnit[z] = GroupPickRandomUnit(g)
                set z = z + 1
            endloop
            set c = GetRandomInt(0,20)
            set Hero[GetPlayerId(p)] = RandomUnit[c]
            set z = 0
            loop 
                exitwhen z == 21
                set RandomUnit[z] = null
                set z = z + 1
            endloop

but it returns a different unit than before but now its always that one. what is wrong with this.
 

cleeezzz

The Undead Ranger.
Reaction score
268
:[

question: is there anything at all that influences the "randomness" of GroupPickRandomUnit?

JASS:
function GroupPickRandomUnit takes group whichGroup returns unit
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupRandomConsidered = 0
    set bj_groupRandomCurrentPick = null
    call ForGroup(whichGroup, function GroupPickRandomUnitEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
    return bj_groupRandomCurrentPick
endfunction


wait a minute...

0 + 1 = 1, random int 1 to 1 will always be 1...
 

Azlier

Old World Ghost
Reaction score
461
If there is a problem, it has to do with GetRandomInt. It seems this function works on everybody's computer but yours... :nuts:
 

cleeezzz

The Undead Ranger.
Reaction score
268
see the post above, sorry i edited, how does that function make sense.? It looks more like a FirstOfGroup function to me..
 

saw792

Is known to say things. That is all.
Reaction score
280
First Unit: 100% chance of being set to current pick.
Second Unit: 50% chance of being set to current pick.
Third Unit: 33% chance of being set to current pick.

It makes sense. The first unit of the group is always set to the current pick, then when the function is run again for the next unit, there is a 50% chance to pick it instead of the first unit, etc.

It ends up giving an even chance to all units within the group. In theory.
 

cleeezzz

The Undead Ranger.
Reaction score
268
but wouldn't that mean, using it to retrieve 1 unit would always be the same unit? cuz the 1st unit is always 100 % which is why im having this "random" problem.

>It ends up giving an even chance to all units within the group.
in the long run, but to get 1 unit out of a group, its 100%
 

saw792

Is known to say things. That is all.
Reaction score
280
No, it's a ForGroup... which means it runs once for every unit in the group. Every time it runs it has a chance of overwriting the last value. So for two units, the second run has a 50% chance of overwriting the last value (which is the first unit), thus a 50% chance to pick each of them.
 

cleeezzz

The Undead Ranger.
Reaction score
268
oh i see...then why isn't it working, this problem is extremely puzzling, ive also created this function yet, r returns 1 every time

JASS:
function GroupGetRandomUnit takes group g returns unit
    local integer count = CountUnitsInGroup(g)
    local integer r
    local unit fog
    local integer i = 1
    local group ng = NewGroup()
    set r = GetRandomInt(1, count) 
    call BJDebugMsg(I2S(r))
    call GroupAddGroupAdv(g,ng) //same thing as GroupAddGroup, create a copy of group g
    loop
        set fog = FirstOfGroup(ng)
        exitwhen fog == null
        call BJDebugMsg(GetUnitName(fog))
        call BJDebugMsg(I2S(i))
        if r == i then
            set ru = fog
        endif            
        set i = i + 1
        call GroupRemoveUnit(ng, fog)
    endloop
    set fog = null
    call ReleaseGroup(ng)
    set ng = null
    return ru
endfunction


and its not that unchecking fixed random seed isnt working, cuz at map init, i display random integers and their different each game...
 

Builder Bob

Live free or don't
Reaction score
249
Your problem doesn't make much sense

Could you try this function and tell what the debug messages say?
JASS:
function GroupGetRandomUnit takes group g returns unit
    local integer count = CountUnitsInGroup(g)
    local integer r
    local unit fog
    local integer i = 1
    local group ng = NewGroup()
    call BJDebugMsg("there are " + I2S(count) + " units in the group")
    set r = GetRandomInt(1, count)
    call BJDebugMsg("I picked number " + I2S(r) + " from the group")
    call GroupAddGroupAdv(g,ng) //same thing as GroupAddGroup, create a copy of group g
    loop
        set fog = FirstOfGroup(ng)
        exitwhen fog == null
        call BJDebugMsg(GetUnitName(fog))
        call BJDebugMsg(I2S(i))
        if r == i then
            set ru = fog
        endif            
        set i = i + 1
        call GroupRemoveUnit(ng, fog)
    endloop
    set fog = null
    call ReleaseGroup(ng)
    set ng = null
    return ru
endfunction

If I remember correctly you said you only have problems with random numbers on map init.
If count > 1, yet r always become 1, then run the function at a 0.001 timer instead of on map init.
 

saw792

Is known to say things. That is all.
Reaction score
280
Perhaps the problem occurs when you set the group? As in the group only contains one unit. Unlikely, but worth a shot.
 

cleeezzz

The Undead Ranger.
Reaction score
268
call BJDebugMsg(GetUnitName(fog))

that shows the name of fog, or the units in the group, all 6 heroes are in the group and are different units.

>If I remember correctly you said you only have problems with random numbers on map init.

actually, its the other way around, these functions i create return unrandom integers while a random integer with no purpose that is shown at map init is completely random.

>Could you try this function and tell what the debug messages say?

what the hell? ... count returned 1, yet fog shows 6 hero names? then somethings wrong with count then...
 

Builder Bob

Live free or don't
Reaction score
249
>If I remember correctly you said you only have problems with random numbers on map init.

actually, its the other way around, these functions i create return unrandom integers while a random integer with no purpose that is shown at map init is completely random.

Oh, well, in that case you should fill an array with random numbers at map init and go through that array whenever you need a random number. I kid, I kid :)
 

cleeezzz

The Undead Ranger.
Reaction score
268
edited post, see above

offtopic 2222 posts XD

why does WE hate me? only counts 1 unit in the group but when using fog to loop through all the units, there are actually 6? ...
 

Builder Bob

Live free or don't
Reaction score
249
edited post, see above

offtopic 2222 posts XD

ok, now we're getting somewhere.

What do you get if you do this?
JASS:
globals
    private integer Count
endglobals

private function CountUnitsManually takes nothing returns nothing
    set Count = Count + 1
    call BJDebugMsg(GetUnitName(GetEnumUnit()) + " is in the group. Increasing Count to " + I2S(Count))
endfunction

function GroupGetRandomUnit takes group g returns unit
    local integer count = CountUnitsInGroup(g)
    local integer r
    local unit fog
    local integer i = 1
    local group ng = NewGroup()
    set Count = 0
    call ForGroup(g, function CountUnitsManually)
    call BJDebugMsg("there are " + I2S(count) + " units in the group")
    set r = GetRandomInt(1, count)
    call BJDebugMsg("I picked number " + I2S(r) + " from the group")
    call GroupAddGroupAdv(g,ng) //same thing as GroupAddGroup, create a copy of group g
    loop
        set fog = FirstOfGroup(ng)
        exitwhen fog == null
        call BJDebugMsg(GetUnitName(fog))
        call BJDebugMsg(I2S(i))
        if r == i then
            set ru = fog
        endif            
        set i = i + 1
        call GroupRemoveUnit(ng, fog)
    endloop
    set fog = null
    call ReleaseGroup(ng)
    set ng = null
    return ru
endfunction


By the way, it might be a good idea to show the function GroupAddGroupAdv(). Maybe this function is doing something to add those units that you see through your variable fog?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Sticking with the desserts for now the latest recipe is Fried Apple Pies - https://www.thehelper.net/threads/recipe-fried-apple-pies.194297/
  • The Helper The Helper:
    Finally finding about some of the bots that are flooding the users online - bytespider apparently is a huge offender here - ignores robots.txt and comes in from a ton of different IPs
  • Monovertex Monovertex:
    @The Helper I'm really not seeing the "Signature" link in the sidebar on that page. Here's a screenshot:
  • The Helper The Helper:
    I have reported it - I was wondering why nobody I have given sigs to over the last few years have used them
  • The Helper The Helper:
    Ghan has said he has fixed this. Monovertex please confirm this fix. This was only a problem with people that had signatures in the upper levels like not the special members but the respected members.
  • The Helper The Helper:
    Here is a better place to manage this stuff https://www.thehelper.net/account/account-details which I think should be way more visible
  • The Helper The Helper:
    I am hoping that online user count drop is finally that TikTok bot banned
  • Ghan Ghan:
    I added the filter last night.
  • The Helper The Helper:
    They are still there

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top