[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > Resources > Graveyard


Graveyard Resources which were not approved are moved to this section.

 
 
Thread Tools
Old 02-05-2011, 09:25 PM   #1 (permalink)
Registered User Nestharus
Left
 
Join Date: Jul 2007
Posts: 5,779
Nestharus has disabled reputation
[System] BigInt

gone

Last edited by Nestharus; 12-21-2013 at 08:35 PM.
Nestharus is offline  
Old 02-06-2011, 09:51 AM   #2 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,765
Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)
PayPal Donor: This user has donated to The Hive. 
The Jass Optimizer breaks ExecuteFunc and UnitAlive, but the solution is to NOT use those natives. I'm sure that you will be adding a description later on, like usual, but stuff like this belongs in a scrapyard language like Perl:

Jass:
                if (e[n[y]]) then
                    set n[y] = n[0]
                    set n[0] = y
                    set y = p[y]
                    set p[td] = y
                    set n[y] = td
                else
                    set y = p[y]
                endif
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline  
Old 02-07-2011, 05:52 PM   #3 (permalink)
Registered User Robbepop
Mapper - vJasser
 
Robbepop's Avatar
 
Join Date: Mar 2008
Posts: 782
Robbepop is a jewel in the rough (178)
hiho,

how precise are these BigInts?
does it make sense to use them for numbers with a maximum of 500-200000?

Robbepop
Robbepop is offline  
Old 02-07-2011, 05:54 PM   #4 (permalink)
Registered User Nestharus
Left
 
Join Date: Jul 2007
Posts: 5,779
Nestharus has disabled reputation
100% precise.

This can handle up to around 8187 digits (in the base) or so if you only have one active number.

1234567 would be 7 digits if it were in b10
35,31,22 would be 3 digits for base 36

etc

Quote:
does it make sense to use them for numbers with a maximum of 500-200000?
Not really ;D.

If doing this for save/load, see my new encryption algorithm that generates a key given a player name and encrypts the data with that key at the cost of 1 bit (1 binary digit, which is almost nothing).

Also keep in mind that you can merge up all of your numbers using this to minimize the size of your save/load code.

http://www.hiveworkshop.com/forums/t...yption-189120/

I'm also creating an Encoder that'll do binary shuffling on a BigInt.

Last edited by Nestharus; 02-09-2011 at 07:22 AM.
Nestharus is offline  
Old 02-07-2011, 11:57 PM   #5 (permalink)
Registered User Dr Super Good
Imperial Good
 
Dr Super Good's Avatar
 
Join Date: Jan 2005
Posts: 16,700
Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)
Former Staff Member: This user used to be on the Hive Workshop staff. Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. User of the Year: 2010 
Surly it would be most efficent to store everything in native types...
If you stored all parts in the lower 16 bits of the 32 bit integer type, you would have direct access to bits via simple division of a choosen part instead of having to run an expensive base conversion. Further more, if bitshifting is available (I forget if WC3 had it), you can directly get the overflow and have it ready for the next itteration.

Standardizing the internal base also would allow the creation of efficent methods to add bigint to bigint or even (god help us) multiply bigint with bigint as well as remove all the code needed to support dynamic base size.

This is no substitute for real BigInts... Real BigInts abuse specially created instructions that all computer processors have to allow them to be computed faster. For example, there is a overflow register available meaning that chunks can be as large as 64bits.

JASS probaly has a shit compiler. Consider trying caching some indicies or common opperations into a local to see if a speed gain is given.
Dr Super Good is offline  
Old 02-08-2011, 01:26 AM   #6 (permalink)
Registered User Nestharus
Left
 
Join Date: Jul 2007
Posts: 5,779
Nestharus has disabled reputation
Actually, performing arithmetic on an integer would be much slower than looping through a list.

Also, it doesn't have anything for shifting bits.

All of the stuff can be done in this, and handling big bases would be faster than handling small bases because of the smaller amounts of iteration involved in the larger base operations ;D.

Because this is stored digit by digit, it supports any base to any base conversion as the numbers are grouped properly when re added ^_^. And working with binary digits would be the slowest possible thing to do in JASS. The smaller the base, the slower.
Nestharus is offline  
Old 02-08-2011, 04:03 PM   #7 (permalink)
Registered User Dr Super Good
Imperial Good
 
Dr Super Good's Avatar
 
Join Date: Jan 2005
Posts: 16,700
Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)Dr Super Good has been here far too long (2964)
Former Staff Member: This user used to be on the Hive Workshop staff. Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. User of the Year: 2010 
Quote:
Actually, performing arithmetic on an integer would be much slower than looping through a list.
Is the JASS compiler really that shit that loops (which usually involve integer arithimitic) are slower than integer arithimitic? To me that sounds a bit contradictory. Your processor can perform hundreds of millions of integer arithmitic opperations to memeory a second, billions to cache. Weather it is adding 1 to 1 or adding a million to a million, they take the same time as all 4 bytes for each number have to be loaded in any case.

I am afriad I seem to not be communicating my ideas properly.

Its a pitty you can not bitshift, that would make this system so much more efficent (as bitshift opperations are extreemly cheap compared to division or other calculatory instructions).

My sujestion was to make it use a hard coded base of 65536 as that would be half an integer allowing for up to half 65536 with muliplication (due to sign bits and no access to overflow registers) and fewer parts would mean fewer itteration needed (and as all parts are still the same word size, there is no extra computation cost). Further more, there would be no need to base convert to binary (expensive time wise as you said) since you could gain access to individual bits by division of powers of 2 and then modulation (again if bitshift and binary opperators were available, this would become insanly fast via masking flags).

Sigh, I guess JASS just plain sucks.
Dr Super Good is offline  
Old 02-08-2011, 06:01 PM   #8 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,765
Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)
PayPal Donor: This user has donated to The Hive. 
JASS compiles into a beautiful game, providing an overall programming experience vastly superior than a "fast" programming language that does not have such satisfying output. How much more fun is it to run an algorithm through a function that you built rather than running it through something like a cell-phone calculator?
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline  
Old 02-08-2011, 07:34 PM   #9 (permalink)
Registered User Nestharus
Left
 
Join Date: Jul 2007
Posts: 5,779
Nestharus has disabled reputation
I see, but that'd fail as then you couldn't really retrieve specific digits w/o math operations. If I wanted to loop through digit by digit and I wanted a base 10 number, I couldn't do it, or it'd be much, much slower.

On another note, I am planning to change multiply to only take a single parameter and add a pow method ;D.

method multiply takes integer value, integer exponent returns nothing

to

method multiply takes integer value returns nothing

I will apply this change as soon as I finish up this set of hw. I only have like 1 hour left to finish half an assignment ;o.

edit
Removed pow and changed s2i to convertString.

edit
fixed add method (was broken)

Last edited by Nestharus; 02-09-2011 at 06:21 AM.
Nestharus is offline  
Old 02-09-2011, 08:05 AM   #10 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,765
Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)
PayPal Donor: This user has donated to The Hive. 
This has a lot of potential. When you're done mucking around with the API in the Base system this is good to go.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline  
Old 02-09-2011, 08:44 AM   #11 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,765
Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)
PayPal Donor: This user has donated to The Hive. 
Alright, API on Base is secure, so this is in the field.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline  
Old 02-10-2011, 01:47 AM   #12 (permalink)
Registered User Nestharus
Left
 
Join Date: Jul 2007
Posts: 5,779
Nestharus has disabled reputation
Added the ever useful method toInt takes nothing returns integer

edit
fixed 2 bugs ^_^, working perfectly now. The 2 bugs had to do with untested methods (sh sh). The new toInt that was just added and the never used convertString, lol ; D.


edit
Optimized it a bit and changed how a lot of the loops operated. Do not worry as I tested every single method this time!! I also tested for leaks.

add,divide,multiply,convertString,toString, forwards/backwards list continuity testing, leak testing, push,pop,enq,deq, toInt. It was all thoroughly tested this time >: O.

However, if somehow I missed a bug, let me know ;D.

Last edited by Nestharus; 02-10-2011 at 07:00 AM.
Nestharus is offline  
Old 02-16-2011, 04:32 AM   #13 (permalink)
Registered User Nestharus
Left
 
Join Date: Jul 2007
Posts: 5,779
Nestharus has disabled reputation
Updated to 1.1.3.0

3 new method additions
Jass:
method mod takes integer k returns integer
method rl takes nothing returns nothing
method rr takes nothing returns nothing

Demo
Jass:
struct tester extends array
    private static method onInit takes nothing returns nothing
        /*//mod demo
        local BigInt int = BigInt.create(Base["0123456789"])
        call int.add(12923,0)
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "11==" + I2S(int.mod(16)))
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "5==" + I2S(int.mod(6)))
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "471==" + I2S(int.mod(566)))
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "98==" + I2S(int.mod(225)))
        */

       
        //rotate demo
        local BigInt int = BigInt.create(Base["0123456789"])
        call int.add(123456789,0)
        //rotate left
        call int.rl()
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "912345678==" + I2S(int.toInt()))
       
        //rotate left
        call int.rl()
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "891234567==" + I2S(int.toInt()))
       
        //rotate right
        call int.rr()
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "912345678==" + I2S(int.toInt()))
       
        //rotate right
        call int.rr()
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "123456789==" + I2S(int.toInt()))
    endmethod
endstruct

So I guess with push, pop, enq, deq, rl, and rr, you have full bit shift operations. With mod, you can now do efficient modulo.


edit
Added
Jass:
method addBig takes BigInt k returns nothing
method multiplyBig takes BigInt k returns nothing
method copy takes nothing returns BigInt

Jass:
struct tester extends array
    private static method onInit takes nothing returns nothing
        /*//copy demo
        local BigInt int = BigInt.create(Base["0123456789"])
        local BigInt copy
       
        call int.add(194382,3)
        call int.multiply(204202)
        call int.add(2482,10)
        set copy = int.copy()
       
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, int.toString() + "==\n" + copy.toString())
        */

       
        /*//multiply big demo
        local BigInt int = BigInt.create(Base["0123456789"])
        local BigInt int2 = BigInt.create(Base["0123456789"])
       
        call int.add(3429201,0)
        call int2.add(5942242,0)
        call int2.add(793483,8)
       
        call int.multiplyBig(int2)
       
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "272101290085442208642==\n" + int.toString())
        */

       
        /*//add big demo
        local BigInt int = BigInt.create(Base["0123456789"])
        local BigInt int2 = BigInt.create(Base["0123456789"])
       
        call int.add(3429201,0)
        call int2.add(5942242,0)
        call int2.add(793483,8)
       
        call int.addBig(int2,3)
       
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "79348305945671201==\n" + int.toString())
        */

    endmethod
endstruct

Last edited by Nestharus; 02-16-2011 at 07:10 AM.
Nestharus is offline  
Old 02-16-2011, 12:22 PM   #14 (permalink)
Registered User D4RK_G4ND4LF
Glorious Bacon of Light
 
D4RK_G4ND4LF's Avatar
 
Join Date: Feb 2009
Posts: 1,337
D4RK_G4ND4LF is a glorious beacon of light (585)D4RK_G4ND4LF is a glorious beacon of light (585)D4RK_G4ND4LF is a glorious beacon of light (585)D4RK_G4ND4LF is a glorious beacon of light (585)D4RK_G4ND4LF is a glorious beacon of light (585)D4RK_G4ND4LF is a glorious beacon of light (585)D4RK_G4ND4LF is a glorious beacon of light (585)
SC2 Spell Contest - Winner: Colossal Worm 
awesome!
I once did something similar in c++ but I had way less functions
how much slower are your bigints compared to casual ints?
D4RK_G4ND4LF is offline  
Old 02-16-2011, 12:48 PM   #15 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,765
Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)Bribe has a brilliant future (1278)
PayPal Donor: This user has donated to The Hive. 
About a million billion times slower ;)
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 05:07 AM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle