• 🏆 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!

[April Fool's 2012] Math

The purpose of this library is to do math operations.

JASS:
/*****************************
*
*   Math
*   v1.0.0.1
*   By Magtheridon96
*
*   - Does Math
*
*   API:
*   ----
*
*       - public constant real PI
*       - public constant real E
*       - public constant real GOLDEN_RATIO
*
*       - struct Int extends array
*           - static method operator [] takes integer i returns thistype
*               - Converts a real to an Int instance
*
*           - static method convertString takes string s returns thistype
*           - method toString takes nothing returns string
*               - Converts a string to an Int and an Int to a string
*
*           - method operator value takes nothing returns integer
*               - Returns the value
*
*           - method add takes Int i returns Int
*           - method subtract takes Int i returns Int
*           - method multiply takes Int i returns Int
*           - method divide takes Int i returns Int
*               - Simple arithmetic operations
*
*			- method log takes Int base returns Int
*				- Finds the logarithm of an Int given a base
*
*           - method abs takes nothing returns real
*               - Returns the absolute value of the Int
*
*           - method max takes Int i returns Int
*           - method min takes Int i returns Int
*               - Return the max/min value of the Int relative to another Int
*
*           - method greaterThan takes Int i returns boolean
*           - method lessThan takes Int i returns boolean
*           - method equalTo takes Int i returns boolean
*               - Logic functions
*
*           - method toBoolean takes nothing returns boolean
*               - Converts an Int to a boolean
*
*****************************/
library Math

    globals
        public constant real PI = 3.141592653
        public constant real E = 2.718281828
        public constant real GOLDEN_RATIO = 1.618033988
        public constant real MAX_INT = 2147483647
        public constant real MIN_INT = -2147483648
    endglobals
    
    struct Int extends array
        static method operator [] takes integer i returns thistype
            return i
        endmethod
        
        static method convertString takes string s returns thistype
            return S2I(s)
        endmethod
        
        method toString takes nothing returns string
            return I2S(this)
        endmethod
        
        method operator value takes nothing returns integer
            return this
        endmethod
        
        method add takes Int i returns Int
            return this.value + i.value
        endmethod
        
        method subtract takes Int i returns Int
            return this.value - i.value
        endmethod
        
        method multiply takes Int i returns Int
            return this.value * i.value
        endmethod
        
        method divide takes Int i returns Int
            return this.value / i.value
        endmethod
		
		method log takes Int base returns Int
			local Int res = 0
			loop
				exitwhen integer(this) <= 1
				set res = res + 1
				set this=this/base
			endloop
			return res
		endmethod
        
        method abs takes nothing returns Int
            if this.value < 0 then
                return -this
            endif
            return this
        endmethod
        
        method max takes Int i returns Int
            if this.value > i.value then
                return this
            endif
            return i
        endmethod
        
        method min takes Int i returns Int
            if this.value > i.value then
                return i
            endif
            return this
        endmethod
        
        method greaterThan takes Int i returns boolean
            return this.value > i.value
        endmethod
        
        method lessThan takes Int i returns boolean
            return this.value < i.value
        endmethod
        
        method equalTo takes Int i returns boolean
            return this.value == i.value
        endmethod
        
        method toBoolean takes nothing returns boolean
            return this.value != 0
        endmethod
    endstruct
    
endlibrary
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
But your implementation suck, plus it's not written by me !
I need it in my map, and the idea was fine, but which takes more time is the implementation, not the idea.
You deserve 0 credit, and i will submit my own, as it is afterall my own work.
Or you could credit me and use my implementation.
We could also use our both sumissions, since i'm planning on adding debug stuff for mine.
 
Okay.png


edit
Ok, April Fools Day :D
Unfortunately, most of you knew :p
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,306
This resource has many, many, many issues

#1, it uses division when it should be using Newton Raphson division. Obviously you're an idiot for not realizing this.

Your log method totally fails. Look at Ln by Blinkboy. In fact, you should just copy your favorite Ln by Blinkboy into this and then we can have all of his code graveyarded since he's a fag. Don't give him credit either, after all, fags don't deserve credit.

The idea of a Math library in general is epic fail ; |. The person who came up with the idea for this should be shot >.<. This isn't Java, this is wc3.

You are missing greaterThanOrEqualTo and lessThanOrEqualTo.

Math for a lib name is much too obscure. This should be called IntegerMathByMagtheridon96.

Otherwise I don't see any other extremely critical issues, so start fixing >: o /rage.

edit
@Troll-Brain, go for that real implementation bro, but be sure to name it RealMathByTrollBrain. Mag can then change his lib to FakeMathByMagtheridon96. When you put the two together, you will get the ultimate combination of math ;o.
 
:O
I Am SUCH A FAILURE. ZOMGGG

On another serious note:
Ln only handles one base
Log can handle any base
(I know you know this, so I'm wondering why you were suggesting a change to Ln only)

The person who came up with the idea for this should be shot >.<

I have several posts made by you in which you talked about posting a Math lib ;D (2010-ish)

if there's a function that could do an efficient and fast exponent parsing then it will be very good

A fast Pow function seems nice :D
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
And 99 % of them played Dota :p

Oh and Bribe that's totally unfair to say that wc3 modding > sc2 modding, it's much much better in many ways.
It's just different, sure for coders that's boring actually.
For instance i'm the first to cry about the lacks of scripting features, like local blocks, and galaxy is even worse than jass in many points (excepted the number of natives available)

Anyway, i will buy sc2 and give it a try in few days.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I've already played the campaign with a "limited" version, you know the one where you can't log to battle.net :thumbs_up:
It's sad, but i'm getting bored of wc3 modding, even vJass with all these new fugly speedfreak standards kill the fun for me.
Note, that i still won't let you win the legendary fight easily :ogre_hurrhurr:

Time to close this thread btw, no ?
I personnaly don't care but coz of me and the others that's pretty much a flood topic, even if it was one since the begin :p
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,454
I will get sc2 when I build my new computer either this year or next. But I don't plan to mod it for the same reason I don't want to build a program from scratch: the workspace is too open and not specific enough. I work better if I have to follow limited structure, like building legos instead of carving art out of wood.
 
Level 10
Joined
May 27, 2009
Messages
494
Having a talk with Galaxy Editor seems fun
Unfortunately, Blizzard made the Galaxy Editor fill in their missing jobs in Wc3's Editor like a native for local multiboards, custom UI and such..
Plus, I already tried modding Sc2 since I have a free sc2 from beta (cool isn't?)

What I don't like is you still need to log-in your freaking BNet account just to open that Galaxy Editor.. Oh damn.. even though you may search google to avoid that annoying log in screen
But in case of terrain, shading is awesome o.o

In triggers, well its just somewhat like JNGP wherein you may add things like LUA or something plus a more gui function.. still, to fill in the missing parts Blizzard missed in wc3 editor.

Well if you want your mod to be compatible with old PCs which have at least 512mb ram, 64mb internal video card, Pentium IV 2.44GHz CPU, Windows XP, use wc3
 
Top