Results 1 to 15 of 15
http://idgs.in/392699
  1. #1
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default [ASK] Enum Integer

    agan2 yg jago vJASS, ada yang tau library buat Enum Integer, maksud sy integer dimasukkan ke semacam group, terus bisa dipanggil dan dihapus dari group tersebut.

    mohon bantuannya gan...

  2. Hot Ad
  3. #2
    Rain's Avatar
    Join Date
    Dec 2006
    Location
    Everywhere Everyplaces
    Posts
    2,602
    Points
    13,969.78
    Thanks: 94 / 203 / 180

    Default

    sori dix gw gabisa bantu, ga ngerti trigger jass >.< , coba GUI pasti saya coba bantu.

  4. #3
    febutterfly's Avatar
    Join Date
    Apr 2011
    Posts
    114
    Points
    159.00
    Thanks: 50 / 143 / 34

    Default

    dix ga ngerti nie trigger jass >.<
    coba yg d perjelas dikit

  5. #4
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default

    library maksudnya script2 vJASS agan2
    ....

  6. #5
    valkemiere's Avatar
    Join Date
    Oct 2006
    Location
    In my Rainbow Castle
    Posts
    1,874
    Points
    5,111.21
    Thanks: 65 / 32 / 31

    Default

    maaf sy jg ga ngrti . haha. kl bisa d bkin pke gui knp ga coba aja

  7. #6
    MAT-KsatriaKOPI's Avatar
    Join Date
    Jun 2009
    Location
    Bumi, Desa Kopi
    Posts
    6,148
    Points
    23.99
    Thanks: 1,251 / 711 / 519

    Default

    bahasa dewa apa ini @_@
    Resign~ Gutbay Green Baret IDGS~
    KsatriaKOPI Journey's & My Case on page 3~
    ~^o^Tree Tag Community~ fun & easy to Learn^o^~
    IDGS Map Tree Tag~ The Legend of the Ancient Forest
    <a href=http://static.indogamers.com/signaturepics/sigpic178654_3.gif target=_blank rel=nofollow>http://static.indogamers.com/signatu...ic178654_3.gif</a>
    Matthew 5:48,"Be perfect,therefore, as your heavenly Father is perfect."

  8. #7
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default

    @valkemiere:
    masalahnya gk bisa GUI kk, wkwkkwkw

    @kstaria_kopi:
    bah.... dewa apaan itu kk...

  9. #8
    valkemiere's Avatar
    Join Date
    Oct 2006
    Location
    In my Rainbow Castle
    Posts
    1,874
    Points
    5,111.21
    Thanks: 65 / 32 / 31

    Default

    loh terbalik? Kok bsa jass , gui ga bs . coba aq bntu kalo bsa. Minta rincian nya

  10. #9
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default

    gk bisa GUI kk, soalnya agak ribet nih

  11. #10
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default

    ribet jelasinny kk...
    mending kasih contoh ajak...

    edit:
    ha...ha... dah dpt kk
    nyari sendiri,,, klo gitu d close aj thread ni
    tq udah maw nolongin kk
    Spoiler untuk Contoh script vJASS :

    Code:
    library Pool
    //******************************************************************************
    //* BY: Rising_Dusk
    //* 
    //* This script gives the user access to general integer pools. A pool is a data
    //* structure that allows you to give entries to it a weight. This weight
    //* essentially scales how likely certain random accesses to the pool will be
    //* returned by the internal .getRandomInt method. Pools can be useful in any
    //* number of ways, such as item drops, randomizing enemy encounters, randomly
    //* selecting rects weighted by area, and so forth.
    //* 
    //******************************************************************************
    //* 
    //* Example usage:
    //*    local intpool ip = intpool.create()
    //*    call ip.addInt(1, 1.0)
    //*    call ip.addInt(2, 0.5)
    //*    call ip.getRandomInt()
    //*    call ip.getChance(2)
    //*    call ip.getWeight(2)
    //*    call ip.removeInt(1)
    //* 
    //* You will first need to create an intpool as shown above. Once you've done
    //* that, you may use the .addInt method to add an entry to the pool with a
    //* specific weight. The example above adds 2 integers, one twice as likely to
    //* be randomly selected as the other. That means for the above example, the
    //* .getRandomInt method will 66% of the time return 1 and 33% of the time
    //* return 2. If you want to remove an entry from an intpool, the .removeInt
    //* method is what you will want to use. If you would like to update an entry's
    //* weight after already adding it, simply use .addInt again with the new
    //* weight.
    //* 
    //* The .getChance and .getWeight methods are there for convenience. If you are
    //* interested in the exact chance of the intpool returning a specific entry,
    //* then you should use .getChance to obtain the decimal chance out of 1. If you
    //* want to know the weight input for a specific entry, .getWeight will return
    //* that for you.
    //* 
    //* When adding an entry to the intpool with .addInt, the actual magnitude of
    //* the weight doesn't matter. What matters is its magnitude relative to the
    //* magnitudes of all other entries in the intpool. This means that it is ok to
    //* use very large or very small weights and is done at the user's discretion.
    //* 
    //* It is worth noting that if you use .getRandomInt on an intpool with no
    //* entries, the function will return INTPOOL_NO_ENTRIES, which is about as
    //* random an integer as possible so as to avoid people accidentally using it.
    //* 
    globals
        //These constants can be changed
        private constant integer MAX_INSTANCES         = 8191
        private constant integer MAX_ENTRIES           = 256
                constant integer INTPOOL_NO_ENTRIES    = 0x672819
                
        //Don't change the following global declaration
        private hashtable ht = InitHashtable()
    endglobals
    
    struct intpool[MAX_INSTANCES]
        private integer Cnt         = 0
        private real    WeightTotal = 0.
        private integer array Entries[MAX_ENTRIES]
        private real    array Weights[MAX_ENTRIES]
        
        method getWeight takes integer entry returns real
            return Weights[LoadInteger(ht, integer(this), entry)]
        endmethod
        method getChance takes integer entry returns real
            if WeightTotal > 0. then
                return Weights[LoadInteger(ht, integer(this), entry)]/WeightTotal
            endif
            return 0.
        endmethod
        method addInt takes integer entry, real weight returns nothing
            local integer in = 0
            if .Cnt == MAX_ENTRIES then
                //Can't hold any more entries
                debug call BJDebugMsg(SCOPE_PREFIX+"Error: .addEntry has reached MAX_ENTRIES")
                return
            elseif weight <= 0. then
                //Zero or negative weights make no sense
                debug call BJDebugMsg(SCOPE_PREFIX+"Error: .addEntry can't take zero or negative weights")
                return
            endif
            set in = LoadInteger(ht, integer(this), entry)
            if in > 0 then
                //Update old entry
                set .WeightTotal = .WeightTotal - .Weights[in] + weight
                set .Weights[in] = weight
            else
                //Make a new entry
                set .Cnt           = .Cnt + 1
                call SaveInteger(ht, integer(this), entry, .Cnt)
                set .Entries[.Cnt] = entry
                set .Weights[.Cnt] = weight
                set .WeightTotal   = .WeightTotal + weight
            endif
        endmethod
        method removeInt takes integer entry returns nothing
            local integer in = LoadInteger(ht, integer(this), entry)
            if in > 0 then
                call RemoveSavedInteger(ht, integer(this), entry)
                //Remove its entry in the arrays
                set .WeightTotal = .WeightTotal - .Weights[in]
                set .Entries[in] = .Entries[.Cnt]
                set .Weights[in] = .Weights[.Cnt]
                set .Cnt         = .Cnt - 1
            debug else
                debug call BJDebugMsg(SCOPE_PREFIX+"Error: .removeEntry entry doesn't exist")
            endif
        endmethod
        method getRandomInt takes nothing returns integer
            local real    r = GetRandomReal(0, .WeightTotal)
            local integer c = 0
            if .WeightTotal <= 0. then
                debug call BJDebugMsg(SCOPE_PREFIX+"Error: intpool has no entries")
                return INTPOOL_NO_ENTRIES
            endif
            loop
                set r = r - .Weights[c]
                exitwhen r <= 0
                set c = c + 1
            endloop
            return .Entries[c]
        endmethod
    endstruct
    endlibrary
    Last edited by NodiX; 25-04-11 at 13:40. Reason: wedew!!!

  12. #11
    Section's Avatar
    Join Date
    Nov 2006
    Location
    about.me/SECTION
    Posts
    2,095
    Points
    11,041.04
    Thanks: 45 / 112 / 98

    Default

    gw kurang berbakat dengan vJass... cuman kalo struct bisa nampung integer array, lu bikin aja simulasi groupingnya... algoritma sih mungkin kayak gini :
    Code:
    struct IntG {
        int x[]; //persiapan integer array
        int numX; //monitor jumlah array
    }
    
    void AddIntGroup(int c,IntG g){
    g.x[g.numX] = c; //Memasukkan nilai integer ke array terakhir
    g.numX +=1; //sama saja dengan g.numX = g.numX + 1
    }
    
    int GetRandomIntGroup(intG g){
    int xx = GetRandomInt(0,g.numX); //GetRandomInt sudah ada fungsinya di JASS
    return g.x[xx];
    }
    
    void FlushIntGroup(IntG g){
    for(int k=0;k<g.numX;k++){ //melakukan looping dari index 0 sampai index terbelakang
    g.x[k] = 0;}
    g.numX = 0;
    }
    Terus tinggal bikin destructornya biar struct IntG ga makan memori.
    ngerti ga?
    Last edited by Section; 25-04-11 at 13:47. Reason: comments...

  13. #12
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default

    thx kk Section, skrang dah agak ngerti sy...
    ngomong2 tu java y???

    klo vJASS gini kk
    Code:
    struct intG
        integer array x
        integer numX
    
        method addIntGroup takes integer c returns nothing
            set this.x[this.numX]=c
            set this.numX=this.numX+1
        endmethod
    
        method getRandomInt takes nothing returns integer
            local integer xx=GetRandomInt(0,this.numX)
            return this.x[xx]
        endmethod
    
        method flushIntGroup takes nothing returns nothing
            local integer i=0
            
            loop
                exitwhen i>this.numX
                set this.x[i]=0 
                set i=i+1                
            endloop
    
            set this.numX=0
        endmethod
    endstruct
    masalahnya algoritma bwt remove int sy gk tau kk
    soalnya sy maw buat dia bisa masukin/hapus integer

    thx kk dah di jelasin!

  14. #13
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default

    setelah pusing tujuh keliling akhirnya bisa bwt sendiri

    Spoiler untuk IntegerGroup by Nodix :

    Code:
    library IntegerGroup
    //*****************************************************\\
    //    INTEGER GROUP BY NodiX                           \\
    //                                                     \\
    //*****************************************************\\
    struct IntGroup
    
    hashtable ht
    integer array int[400]
    integer index=0
    
    static method create takes nothing returns thistype
        local thistype dat=thistype.allocate()
            
        set dat.ht=InitHashtable()
        return dat
    endmethod
        
    method addInt takes integer i returns nothing
        local boolean t=LoadBoolean(this.ht,0,i)
        
        if not t then
            set this.index=this.index+1
            set this.int[this.index]=i
            call SaveBoolean(this.ht,0,i,true)
            call SaveInteger(this.ht,1,i,this.index)
        else
            static if DEBUG_MODE then
                call BJDebugMsg(SCOPE_PREFIX + ": Couldn't add current integer to group. (" + I2S(i) +")")
            endif
        endif
    endmethod
    
    method remInt takes integer i returns nothing
        local boolean t=LoadBoolean(this.ht,0,i)
        local integer q=LoadInteger(this.ht,1,i)
        
        if t then
            if q==this.index then
                set this.int[q]=0
                call SaveBoolean(this.ht,0,i,false)
            else
                set this.int[q]=this.int[this.index]
                
                call SaveBoolean(this.ht,0,i,false)
                call SaveInteger(this.ht,1,this.int[this.index],q)
                call SaveBoolean(this.ht,0,this.int[this.index],true)
            endif
            set this.index=this.index-1
        else
            static if DEBUG_MODE then
                call BJDebugMsg(SCOPE_PREFIX + ": Couldn't remove integer, integer doesn't exists. (" + I2S(i) +")")
            endif
        endif
    endmethod
    
    method getRandomInt takes nothing returns integer
        if this.index>0 then
            return int[GetRandomInt(1,this.index)]
        endif
        return 0
    endmethod
    
    method getFirstInt takes nothing returns integer
        if this.index>0 then
            return int[1]
        endif
        return 0
    endmethod
    
    method getLastInt takes nothing returns integer
        if this.index>0 then
            return int[this.index]
        endif
        return 0
    endmethod
    
    method flush takes nothing returns nothing
        local integer i=1
        
        call FlushParentHashtable(this.ht)
        loop
            exitwhen i>this.index
            set this.int[this.index]=0
            set i=i+1
        endloop
        set this.index=0
    endmethod
        
    endstruct
    
    endlibrary



  15. #14
    Section's Avatar
    Join Date
    Nov 2006
    Location
    about.me/SECTION
    Posts
    2,095
    Points
    11,041.04
    Thanks: 45 / 112 / 98

    Default

    algoritma gw make C++ yang kebetulan memang serupa dengan Java... wehehehhe...

    oh ya maaf gw lupa masukin remove integer... tp kyknya lo udah nemuin sendiri tuh... hihihi... good good... keep it up!

  16. #15
    NodiX's Avatar
    Join Date
    Dec 2010
    Location
    The Dark Side of the Moon
    Posts
    459
    Points
    897.80
    Thanks: 22 / 21 / 20

    Default

    lumyn capek kk
    gk kasian apa...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •