Pattern Help

inevit4ble

Well-Known Member
Reaction score
38
Hi Every1,

Can't work out this pattern. I can see it but not formulate it. Please help

Values are set per level per spell level ie 4/4/3/3/2 means at this level, 4 x Level 1 spells, 4x Level 2 spells, 3x level 3 spells etc
they are going to be saved into a struct but you dont need to worry about that.

Max of the value is 4
Max of 10 values per level
so
4/3/2/1/-/-/-/-/-/-
would be 4x Level 1 spell, 3x LvL2, 2x LvL3, 1x LvL4 and " - " would be 0 / null

Here are the values:
3/1/-/-/-/-/-/-/-/-
4/2/-/-/-/-/-/-/-/-
4/2/1/-/-/-/-/-/-/-
4/3/2/-/-/-/-/-/-/-
4/3/2/1/-/-/-/-/-/-
4/3/3/2/-/-/-/-/-/-
4/4/3/2/1/-/-/-/-/-
4/4/3/3/2/-/-/-/-/-
4/4/4/3/2/1/-/-/-/-
4/4/4/3/3/2/-/-/-/-
4/4/4/4/3/2/1/-/-/-
4/4/4/4/3/3/2/-/-/-
4/4/4/4/4/3/2/1/-/-
4/4/4/4/4/3/3/2/-/-
4/4/4/4/4/4/3/2/1/-
4/4/4/4/4/4/3/3/2/-
4/4/4/4/4/4/4/3/2/1
4/4/4/4/4/4/4/3/3/2
4/4/4/4/4/4/4/4/3/3
4/4/4/4/4/4/4/4/4/4

What I want to do is put the formula into a function that takes hero level and set the values to the correct ones for that level.

It would be amazing if you guys could help me out here!
 

Smitty

Member
Reaction score
20
Hmm, I think I may understand, but some clarification would be needed. Can you explain in terms of sequences? Here;

Let 'n' be the term number, and 'x' be the term

Ie. In sequence 6/7/4/8/4/9/4

Where n=1, x=6
Where n=3, x=4

So, are you looking for a way to find x of a sequence by relating it to n, or have I totally misunderstood?
 

inevit4ble

Well-Known Member
Reaction score
38
Ok let me try clarify, I might be getting confused now as well.

Hero Level = 5
Sequence 5 = 4/3/2/1/-/-/-/-/-/-

n = 0, x = 4
n = 1, x = 3
n = 2, x = 2
n = 3, x = 1
n = 4, x = 0
n = 5, x = 0
n = 6, x = 0
n = 7, x = 0
n = 8, x = 0
n = 9, x = 0

set array[n] = x
 

Smitty

Member
Reaction score
20
Ah, I see.

Hmm, I can't instantly spot an easy pattern for all levels. However if you don't mind using a fairly long trigger there are patterns within groups of levels. If that makes sense :p I'm at work now but I'll try to figure it out when I finish :)
 

inevit4ble

Well-Known Member
Reaction score
38
The whole point is to avoid a long trigger, but nothing can be longer than the old way I did this, 2200 line GUI trigger :O not ever again, even WE lagged lol

If you ignore the 4 as a max, perhaps that will help. I can always put a condition in that checks if value is above 4 and sets it to 4.


And I got to do similar ones as well so like 8 of these in total so even if you get close maybe that will help!
 

Smitty

Member
Reaction score
20
I just realised you designed this on a vertical pattern. Helps a lot XD

Also, your first column doesn't follow the same pattern as the rest, is this intentional? Because if so it's annoying :p
 

inevit4ble

Well-Known Member
Reaction score
38
Well, it would follow the same pattern if you imagine that there are lower levels than 1.
But if you exclude the first sequence will that make it easier?
 

Smitty

Member
Reaction score
20
Yes, because it looks as though you've skipped acolumn between the first and second, since each successive column begins the pattern 2 steps later, whereas the second column is 4 steps behind the first. I have a method but I'm trying to convert the bastard into a trigger :/
 

inevit4ble

Well-Known Member
Reaction score
38
I think I've got quite close as well now. Please share so we can crack this :D

What I have so far is:
JASS:
For Level 2:
loop
    set j = j + 1
    set UD<u>.castsMax[j] = UD<u>.castsMax[j] + 1
    exitwhen j == i/2
endloop

For Even Levels :



loop
    set j = j + 1
    if i == (j*2)+2 then
        set UD<u>.castsMax[j] = UD<u>.castsMax[j] + 1
    elseif i == (j*2) then
        set UD<u>.castsMax[j] = UD<u>.castsMax[j] + 1
    endif
    exitwhen j == i/2
endloop





For Odd Levels:
loop
    set j = j + 1
    if UD<u>.castsMax[j] = 0 then
        set UD<u>.castsMax[j] = UD<u>.castsMax[j] + 1
        set k = j - 3
        set UD<u>.castsMax[k] = UD<u>.castsMax[k] + 1
        exitwhen k &gt;= 0
    endif  
    exitwhen i == (j*2)-1
endloop





if i == 19 then
    set UD<u>.castsMax[7] = 4
    set UD<u>.castsMax[9] = 3
endif

if i == 20 then
    loop
        set j = j + 1
        set UD<u>.castsMax[j] = 4
        exitwhen j == 9
    endloop    
endif</u></u></u></u></u></u></u></u></u></u></u></u></u></u>


"j" is integer initialized at -1
"i" is integer == Hero Level
"k" is just another integer
castsMax is the array being set

and I would set Level 1 value in the spawn trigger
 

Smitty

Member
Reaction score
20
Right; so far, I can see;
Each even row follows the pattern 4/3/3/2/0
Odd rows follow 4/3/2/1/0
So;

You could create 2 arrays, PatternOdd 3/2/1 and PatternEven 3/3/2

Use an alternator to detect which pattern each level should show, ie.

If:
Alt=0
Then:
Set Alt=1
Do Bla Bla Bla
Else:
Set Alt=0
Do other Bla Bla Bla

This would tell the trigger which pattern to set for that level.

The issue I'm running into is telling the game which value to begin with. For example, if we considered ignoring the first column, the trigger would look like this;

Event;
Whatever (hero gains a level?)

Conditions;
Whatever else

Actions;
If;
Alt=0
Then;
Set Alt=1
Set LevelArray[1]=Take PatternOdd[Cap-Hero Level]
Else;
Set Alt=0
Set LevelArray[1]=Take PatternEven[Cap-Hero Level]
Set Cap=(Cap+1)

Cap is an integer variable, start value 4.
LevelArray is the array we're setting as our end result (since I guess you're asking for these values to be saved into an array)
This is, as I understand it, setting the first value of an array to the appropriate part of the correct pattern. However I should mention I have no computer, so no WE to test anything on, and I've never worked with arrays at all before, so you may need to make this more trigger-y.

The next issue is trying to tell the game to set each following value of LevelArray as the next value of the appropriate pattern, which could be done easily manuay, but it would take work, and be impractical for longer patterns. Also, probably easier, you want to tell it to set all values in LevelArray before and after certain values to all take values 0 or 4.

With this part done, we should have;

Level 1: 1 0 0 0 0 0 0
Level 2: 2 0 0 0 0 0 0
Level 3: 2 1 0 0 0 0 0
Level 4: 3 2 0 0 0 0 0
Level 5: 3 2 1 0 0 0 0
Level 6: 3 3 2 0 0 0 0
Etc.

I think I've understood so far what you want, though I may have completely missed something. Hope this helps, I'll keep thinking about it, but I'm running into problems with my knowledge of arrays and triggering their values. If you want a longer explanation of the purely mathematical aspect as I understand it I can do it if you think it would help, but I'm typing on my phone, so I'll leave it unless you definitely think it would be useful. Besides, you presumably grasp that aspects anway. Let menknow if this helps, or if I'm completely misunderstanding :)
 

inevit4ble

Well-Known Member
Reaction score
38
lol, u still on your phone! Fingers of Steel grr :)

Ye you understand what needs to be done.

I haven't tested my method in the above post yet but if you saw it, you would see how I've tried to accomplish the problems that arose for you.

I'm going to try mix the knowledge from you with my stuff and see what comes out.

Thanks for the effort :D
 

Smitty

Member
Reaction score
20
Haha, yeh, computer should be comic back from repairs soon I hope :/

Looking at what you have there, it seems you're trying to find a solution specifically to this problem, whereas I'm trying to find a general rule. Obviously if this is the only system you need like this, then either method works fine, but a general rule would be more useful if you plan to have multiple instances of this kind of thing, with different variations.

My other suggestion was to set a variable as an array (Pattern) with values ...0/0/0/0/0/1/2/2/3/3/3/4/4/4/4... And create another array to give you the end result. Then tell the result to take values from Pattern following;

(X-(Y*Hero level))+2Z

Where X and Y would be related to each other, and decided by the number of values in Pattern, and Z would represent LevelArray[Z]

However I haven't been able to test this fully. It does seem easier, I'll test it mathematically when I have some time.
 

inevit4ble

Well-Known Member
Reaction score
38
Ye I was aiming at this problem specifically. My reasoning was that if I get one to work right then the others just need some value adjusters and they should work as well.

What you're referring to by saving a pattern, I think if that route was to be taken, a hashtable would be the right way to go.
ie. Reference X vs Reference Y is Value Z
 

Smitty

Member
Reaction score
20
No, X and Y would be decided by how long the pattern was, since they determine what starting point to use for the result.

Z would be an actual variable, representing the array number, and isn't related to X or Y at all. It would just tell the game which slot of an array to read/set.

That said I've never used hashtables, so I may be misunderstanding their use in this situation :)

Here's an applied use of that formula (slightly edited):

Just walking somewhere currently, so I'll pull this off the top of my head;

Create 2 integer arrays with 3 slots called Odd (3/2/1) and Even (3/3/2).
Create a 3rd integer array with 10 slots called LevelArray.
Alt is an integer variable, initial value 0
Z is an integer variable, initial value 0
w is an integer variable, initial value 4

Then trigger:

Event:
A hero gains a level

Conditions:

Actions:
If;
_Alt=0
Then;
_Set Alt=1
_For every integer between 1 and 10 loop actions;
__If;
___(W-(Level of hero)+Z)>0
__Then;
___If;
____(W-(Level of hero)+Z)<4
___Then;
____Set LevelArray[Z+1]=Odd[W-(level of hero)+Z]
___Else;
____Set LevelArray[Z+1]=0
__Else;
___Set LevelArray[Z+1]=4
_Set Z=(Z+1)
Else;
_Set Alt=0
_Set W=(W+1)
_For every integer between 1 and 10 loop actions;
_If;
__(W-(Level of hero)+Z)>0
_Then;
__If;
___(W-(Level of hero)+Z)<4
__Then;
___Set LevelArray[Z+1]=Even[W-(level of hero)+Z]
__Else;
___Set LevelArray[Z+1]=0
_Else;
__Set LevelArray[Z+1]=4
_Set Z=(Z+1)
Set Z=0

This should work completely. The nice thing is by tweaking 3 numbers you can use this for any pattern with an infinite length and number of levels. Note that if you want to have this system running for more than one hero you'll need a different LevelArray variable for each hero, and a different alternator, and probably the same trigger for each referring to different variables. But it's a HELL of a lot better than 2200 lines of GUI, and can be used for any similar situation :)

The result of using this trigger should be;

Level 1: 1 0 0 0 0 0 0 0 0 0
Level 2: 2 0 0 0 0 0 0 0 0 0
Level 3: 2 1 0 0 0 0 0 0 0 0
Level 4: 3 2 0 0 0 0 0 0 0 0
Level 5: 3 2 1 0 0 0 0 0 0 0
Level 6: 3 3 2 0 0 0 0 0 0 0
Etc.

If you need the pattern to start somewhere other than 1/0/0/0/0/0/0/0/0/0 then you'll need to tweak a few values, if you specify exactly how you want it in this instance I can show you, otherwise this should do fine :)

Good luck, and I hope this solves it for you :)





I can haz cake nao? :]

EDIT: Small fix
 

inevit4ble

Well-Known Member
Reaction score
38
oOo

Will have to try this out! I implemented my one and made it customizable for 2 of the patterns but it seems my idea needs a more solid base. I'm going to test this new idea out.

Thx bro
 

Smitty

Member
Reaction score
20
I think in this situation simple is best :) hope it works, if not shout. I had to write freehand, so sorry if it's not very clear what's what. I can clarify if needed.

Also, you'll need to add conditions obviously, depending on the map, ie. Checking what hero, etc. But I'd guess you're smart enough to figure that out ;)

Good luck :)

Did it work?????? I want to know!! XD
 

Smitty

Member
Reaction score
20
I don't know if you solved this already but I realised I forgot to actually save the changes I made yesterday ><

Introduction of variable W to ensure the correct value is taken.

If you already fixed/realised this, then my bad, but I thought I ought to put it up here anyway. Apso...
Lemme know how this works if you use it :]
 

inevit4ble

Well-Known Member
Reaction score
38
Ok well to give you an update,

I took your methods, chopped them up and used the reasoning with my trigger and so far this works for 4 of the 7 patterns. The last 3 are completely different from these 4 so next step is to work on them.
Here in the trigger, sorry but its in jass but you should be able to follow it:
JASS:
        function WizSorSpellTable takes unit u returns nothing
//     ------------------
//      Constants
        local integer i = GetHeroLevel(u)
        local integer j = -1
        local integer k
        local boolean even = false
//     ------------------
//      Changables    
        local integer min
        local integer max
        local integer a1
        local integer a2
        local integer b1
        local integer b2
        local integer c
        local integer d1
        local integer d2
        local integer skip
        local integer pattern
        local boolean run
//     ------------------
        if UD<u>.cla == &quot;Wizard&quot; then
//     ------------------
            if i == 19 then
                set UD<u>.castsMax[7] = 4
                set UD<u>.castsMax[9] = 3
                return
            endif
//     ------------------
            set max     = 4
            set min     = 1
            set a1      = 2
            set a2      = 2
            set b1      = 2
            set b2      = 0
            set c       = -3
            set d1      = 2
            set d2      = -1
            set run     = true
            set skip    = 5
            set pattern = 3
//     ------------------            
        elseif UD<u>.cla == &quot;Sorcerer&quot; then
//     ------------------
            if i == 19 then
                set UD<u>.castsMax[8] = 6
                set UD<u>.castsMax[9] = 4
                return
            endif
//     ------------------
            set max     = 6
            set min     = 3
            set a1      = 3
            set a2      = 1
            set b1      = 2
            set b2      = 1
            set c       = -1
            set d1      = 2
            set d2      = 0
            set run     = false
            set skip    = 4
            set pattern = 4
//     ------------------
       elseif UD<u>.cla == &quot;Druid&quot; or UD<u>.cla == &quot;Cleric&quot; then
//     ------------------
            if i == 7 then
                set UD<u>.castsMax[0] = 6
            endif
            if i == 19 then
                set UD<u>.castsMax[5] = 5
                set UD<u>.castsMax[7] = 4
                set UD<u>.castsMax[9] = 3
                return
            endif
            if i == 20 then
                set UD<u>.castsMax[8] = 4
                set UD<u>.castsMax[9] = 4
                return
            endif
//     ------------------
            set run     = false//New Levels on Odd
            set pattern = 3//Starts from Level 3
            set max     = 6
            set min     = 1
            set a1      = 2
            set a2      = 2
            set b1      = 2
            set b2      = 0
            set c       = -3
            set d1      = 2
            set d2      = -1
            set skip    = 3
//     ------------------          
        endif
//     ------------------ 
        if i &lt; pattern then 
            //For Levels before pattern starts:
            loop
                set j = j + 1
                if UD<u>.castsMax[j] != max and UD<u>.castsMax[j] &gt; 0 then
                    set UD<u>.castsMax[j] = UD<u>.castsMax[j] + 1
                endif
                exitwhen j == 1
            endloop
            return
        endif
//     ------------------        
        if i == 20 then
            loop
                set j = j + 1
                set UD<u>.castsMax[j] = max
                exitwhen j == 9
            endloop    
            return
        endif
//     ------------------ 
        //Check if level is even or odd
        set k = i/2
        set k = k * 2
        if k == i then
            set even = true
        endif
//     ------------------ 
        if even == run then
            //For Increment Levels :
            loop
                set j = j + 1
                if i == (j*a1)+a2 then
                    set UD<u>.castsMax[j] = UD<u>.castsMax[j] + 1
                elseif i == (j*b1)+b2 then
                    set UD<u>.castsMax[j] = UD<u>.castsMax[j] + 1
                endif
                exitwhen i == (j*b1)+b2
            endloop
        else
            //For New Levels:
            loop
                set j = j + 1
                if UD<u>.castsMax[j] == 0 then
                    set UD<u>.castsMax[j] = min
                    if i != skip then    
                        set k = j + c
                        set UD<u>.castsMax[k] = UD<u>.castsMax[k] + 1
                        if UD<u>.cla == &quot;Druid&quot; or UD<u>.cla == &quot;Cleric&quot; then
                            if i &gt;= 11 then
                                set k = k - 2
                                set UD<u>.castsMax[k] = UD<u>.castsMax[k] + 1
                            endif
                        endif
                    endif
                endif  
                exitwhen i == (j*d1)+d2
            endloop
        endif
//     ------------------ 
    endfunction</u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u></u>

There's 2 parts, the setting up of variables and then the pattern function
 

Smitty

Member
Reaction score
20
Hmm, what's different about the last 3? Is it still a vertical pattern (referring to the grid you used in the first post to demonstrate) 1/2/2/3/3/3/4/4/4/ etc?

I still can't test the trigger I gave you (GRRRRR!!) but it should work for all values following that pattern :s you may wish to edit the original value of W if you want to start from, say, the 3rd row, but that depends what you want to do with it. Show me the pattern for the last few rows and I'll see what emerges if you still want help :)

Good luck ^.^
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top