Page 1 of 2
1
2
LastLast
  1. #1
    The Patient Dantrag's Avatar
    15+ Year Old Account
    Join Date
    Apr 2009
    Location
    Russia, Rostov-on-Don/Moscow
    Posts
    232

    self-made program: Intellect Calculator

    hi all.
    yesterday i spent 40 minutes trying to calculate amount of mana regeneration provided from 4 int socket bonus on my belt, and that was horrible. i thought *hey, a lot of pallys are forced to manually calculate the same things* and decided to make a program which will do this for you.

    why not RAWR? rawr is very powerful thing, but it works with items, not with abstract numbers.
    why not *just gem all with int*? because you can choose the place of your blue and red sockets to get better socket bonuses. sweet time when Jeweller's gems were all-colored...

    this is link to download:
    http://rapidshare.com/files/324968895/IntCalc1.2.exe - v_1.2

    http://rapidshare.com/files/40804295...lator.exe.html - v_2.0 (C#)
    http://depositfiles.com/files/hd171fgfe - v_2.0 mirror
    http://rapidshare.com/files/40804298...lator.rar.html - source directory of VisualStudio 2008 solution (instead of source code)

    it requires .net framework installed
    changelog:
    v_1 release
    v_1.1. added feature to save screenshots, but sometimes (1 of 100 atempts) it crashes with random bug while saving. it seems to be compiler's bug as i've talked with compiler's creator.
    v_1.2 added 'mana regen from initial pool', counting for 7min fight by default. also fixed bug with 'always-on-top' type of window.
    v_2.0 fully converted the prog to C#.NET platform. Now you can copy/paste the results, save them as text file and see the wonderful 'about' button! ;-)



    i'd like to post source code of my program too:

    Quote Originally Posted by pascal 1.2 code
    uses graphabc;
    var int,mana,crit,sp,hltime,foltime:real;
    pleatime:integer;
    bloodelf:boolean;


    type criticalmp5=record
    HL,FoL:real;
    end;
    type manaregen=record
    replenish,racial,plea,poolregen:real;
    crit:criticalmp5;
    function inittotal(IsHlCrit:boolean):real;
    begin
    result:=replenish+racial+plea+poolregen;
    if IsHlCrit then
    result+=crit.HL else result+=crit.fol;
    end;
    end;

    var mp5:manaregen;


    procedure describeINT(x:integer);

    begin
    int:=x*1.21;
    sp:=int*0.2;
    textout(10,2,'amount of int - '+x.ToString+'('+int.ToString+' with talents&BoK)');
    textout(10,20,'sp - '+sp.ToString);
    mana:=int*15;
    textout(10,40,'mana - '+mana.ToString);
    mp5.poolregen:=mana/7/60*5;
    textout(10,60,'regen from mana pool in 7min fight - '+mp5.poolregen.tostring);

    crit:=(int/166.66667)/100;

    ///replenish
    mp5.replenish:=mana*0.01;
    textout(10,80,'replenish mp5 - '+mp5.replenish.ToString);
    ///dp
    mp5.plea:=(mana*0.25/pleatime)*5;
    textout(10,100,'mp5 from plea every '+pleatime.tostring+' - '+mp5.plea.ToString);
    ///racial
    if bloodelf then
    begin
    mp5.racial:=(mana*0.06/120)*5;
    textout(10,120,'mp5 from racial every 120s - '+mp5.racial.ToString);
    end
    else mp5.racial:=0;

    textout(10,140,'crit - '+(crit*100).ToString+'%');
    ///regen from crits
    mp5.crit.hl:=crit*1274/hltime*0.3*5;
    mp5.crit.FoL:=crit*307/foltime*0.3*5;
    textout(10,160,'crit mp5 from HL spam - '+mp5.crit.HL.ToString+', FoL spam - '+mp5.crit.FoL.ToString);

    var hlregen:=mp5.inittotal(true);
    var folregen:=mp5.inittotal(false);

    textout(10,180,'total mp5 - '+hlregen.ToString+'(with hl spam) to '+folregen.ToString+'(with FoL spam)');
    end;

    begin
    window.Height:=250;
    window.Width:=520;
    window.Caption:='Intellect calculator';
    mainform.TopMost:=false;
    repeat
    textout(10,window.Height - 30,'input amount of intellect (integer value)');
    var intellect:integer;
    readln(intellect);
    textout(10,window.Height - 30,'input interval between Divine Pleas (in seconds, integer value) ');
    readln(pleatime);

    textout(10,window.Height - 30,'input your HL casting time (in seconds, real value) ');
    readln(HLtime);
    textout(10,window.Height - 30,'input your FoL casting time (in seconds, real value) ');
    readln(FoLtime);

    textout(10,window.Height - 30,'are you Blood Elf? print 1 if you are or 0 if you are not ');
    var x:char;
    readln(x);
    if x='1' then BloodElf:=true
    else BloodElf:=false;

    describeint(intellect);


    textout(10,window.Height - 30,'would you like to save results to "IntCalc.jpg"? print 1/0 ');
    readln(x);
    var BEracial:string;
    if Bloodelf then BEracial:=' with BE racial' else beracial:=' w/o BE racial';
    textout(10,window.Height - 30,FoLtime.ToString+' FoL cast, '+hltime.ToString+' HL cast, plea used every '+pleatime.ToString+'s'+BEracial);
    if Bloodelf then BEracial:='+BE' else beracial:='w-o BE';
    var s:string;
    s:='int calc -'+intellect.ToString + '-'+pleatime.ToString +'-'+hltime.ToString+'-'+foltime.ToString+beracial+'.jpg';

    sleep(10);
    if x='1' then window.Save(s);


    textout(10,window.Height - 30,'would you like to perform another calculations? print 1/0 ');
    readln(x);
    if x='1' then window.Clear
    else window.Close;
    until false;
    end.
    this code can be not too optimized, but since the calculations are not hard but just boring i hadn't tried to optimize it.

    used compiler (for Pascal version) - http://pascalabc.net/ , site is in russian. C# version is made in Visual Studio 2008.
    i hope this program is useful... because a lot of my programs are written because of boredom. i have even program to make *heads or tails* decision.
    Last edited by Dantrag; 2010-07-20 at 06:27 PM.
    [Talisman of Resurgence] icon is made of small kitten's red eyes. each time you use the proc, the god kills two more kittens to refresh it's icon after cooldown.
    Holy Paladin trinket comparison

  2. #2
    Fluffy Kitten Nerph-'s Avatar
    15+ Year Old Account
    Join Date
    Sep 2008
    Location
    Belgium
    Posts
    8,844

    Re: self-made program: Intellect Calculator

    I'm afraid even with a lot of intellect gems, the intellect of a typical forum member here will remain 0.

  3. #3
    Deleted

    Re: self-made program: Intellect Calculator

    Quote Originally Posted by Skulldancer

    Man this could be a key logger
    I hope you'r kidding...

  4. #4

    Re: self-made program: Intellect Calculator

    Quote Originally Posted by d3v
    I'm afraid even with a lot of intellect gems, the typical intellect of a forum member here will remain 0.
    ^this

  5. #5

    Re: self-made program: Intellect Calculator

    Your code makes my eyes bleed. This is a great example of why strongly typed, case sensitive languages are better to begin with than languages which allow you to violate coding conventions dozens of times a line. I'm also not at all certain of how you managed to bloat such an incredibly simple program so much. You can probably achieve the same thing with C and command line arguments using at most 20 lines of code, as opposed to your 100+.

    Now, I'm not just going to be a dick making fun of somebody obviously new to programming and self taught. Coding conventions weren't the first thing on my mind when I was teaching myself either. For a little while I even thought they were a waste of time. I can assure you the small amount of time needed to get into the habit of holding to standard conventions will pay itself back countless thousands of times if you continue to program, even just side projects for yourself. So, here are some conventions to make your code more readable. These are not remotely exhaustive, just the errors I noticed in your coding when I skimmed through.

    1. Variables absolutely must have meaningful names. Naming something "x" tells the person reading your code absolutely nothing. If you want to counter with "but I'm the only one reading my code," then you've obviously never had to go back and look at something you coded more than a few weeks in the past. Out of sight, out of mind applies to code better than almost anything else I can think of. For loop counters or other such temporary variables, single letter names are fine. Normally you'd use "i" as your loop iteration counter. If you need to nest loop, use letters of the alphabet in increasing order, so after i would be j, then k, and so on. If you're nesting loops more than 3 levels deep you might want to consider a different approach, though.

    2. Capitalization is very important. Since you can't put spaces in variable names, they rapidly become unreadable. A variable named "mystringtokenizer" or even worse a function named "loadconfigfromxmlfile" are a pain to read at best. When a variable name is more than one word, you should use one of two notations. The less common method is to separate words with underscores, so the variable would become "my_string_tokenizer" and is easy to read. The most common method is by capitalizing the first letter of every word but the first (variables always begin with a lower case letter by convention), so you'd get "myStringTokenizer." This is more compact and equally readable, and is called camel notation for the humped look of the names. In the case that you have an abbreviation as part of your variable name, you only capitalize the first letter as if it were a word, so a variable might look like "UdpConnectionSocket."

    3. Function or method names should start with a capital letter, and otherwise follow variable naming conventions.

    4. Constants should be defined at the top of the file and should be in all caps.

    5. Any "magic numbers" should be defined as constants. This both makes your code easier to read and also easier to maintain if the magic number needs to be changed (you only need to change the definition, and not every line of code which references it). A magic number is some number written in your code that has some specific purpose and is never changed at runtime. For example, in the following line, 166.66667 is a magic number. Numbers whose purpose is obvious do not need to be defined as constants (like the 100 that's obviously converting a percentage representation to a decimal in the following line).

    crit:=(int/166.66667)/100;
    6. Blocks of code which can be logically grouped should be separated from other lines by a single line of whitespace. Functions should be separated from each other by 3 lines of white space.

    7. Indent 4 spaces when increasing the nest level. Consider the rather convoluted Hello World! programs that follow. They produce identical binaries, but one is much more readable. Feel free to compile and run them to confirm.

    Quote Originally Posted by Bad Programmer
    #include <stdio.h>

    int main() {
    char hello&#91;] = {'H','e','l','l','o',' ','W','o','r','l','d'};
    int i;
    for (i = 0; i < 11; i++) {
    printf("%c",hello[i ]);
    if (i == 10)
    printf("!\n");
    }
    return 0;
    }
    Quote Originally Posted by Good Programmer
    #include <stdio.h>

    int main() {
    char hello&#91;] = {'H','e','l','l','o',' ','W','o','r','l','d'};
    int i;
    for (i = 0; i < 11; i++) {
    printf("%c",hello[i ]);
    if (i == 10)
    printf("!\n");
    }
    return 0;
    }
    8. NEVER mix conventions within the same project. If you're using underscores in your variable naming, you shouldn't be using camel notation.

    9. In a case insensitive language, never ever reference a variable or function using a different case. If you called your variable FOO when you created it, don't call it foo or Foo later. This causes tons of unnecessary ambiguity. The vast majority of "serious" programming languages are case sensitive for exactly this reason (though you can make things even more confusing if you decide to use multiple variables with only differences in capitalization).

    10. Avoid declaring multiple variables on a single line. This is less readable than giving each variable its own line. You should also initialize variables that have a logical starting position (counters almost always start at 0, for instance).

    Now, after that likely unwanted lesson in coding conventions, here's some coding convention humor to cheer you up.

    http://www.lysator.liu.se/c/ten-commandments.html

    [Edit] Clarified something that was ambiguous.

  6. #6

    Re: self-made program: Intellect Calculator

    Quote Originally Posted by Fishbeans
    /snippity snip snip
    his coding is fine, incase you didn't notice he's taking into account mp5, mana return with Divine Plea, and racials so no you aren't going to be able to do it in 20 lines of code, unless you don't leave spaces between the sets of code that do different things and don't use the enter key. also your example of bad and good coding doesnt apply as I know of a couple different programing languages that only indent once and wont endent again if you hve a for loop (do loop) inside a while loop (for example)

    now if this was for some proffesional project (job etc) then I could see cleaning it up a little but for what its intended for its fine

  7. #7

    Re: self-made program: Intellect Calculator

    his coding is fine
    Not according to the standards accepted by the entire world. I didn't make these rules up, nor are they arbitrary.

    incase you didn't notice he's taking into account mp5, mana return with Divine Plea, and racials so no you aren' going to be able to do it in 20 lines of code
    Yes, I noticed. It's still trivial algebra, and each calculation can be handled on a single line. The OP is using tons of intermediary calculations. He's also split tons of text output across multiple lines, which is unnecessary if you use formatted output. The code is just not well written. I once wrote a fully functional library information system in less than 500 lines of code that was object oriented to boot. Don't tell me I don't know how to minimize code size.

    unless you don't leave spaces between the sets of code that do different things and don't use the enter key.
    Three words. Command line parameters. It's faster and more convenient. Alternatively, you could get all the necessary information from a single input rather than half a dozen.

    also your example of bad and good coding dont apply as I know of a couple different programing languages that only indent once and wont endent again if you hve a for loop (do loop) inside a while loop (for example)
    Two things. First, the presence of some idiotic programming language that restricts whitespace usage to reduce readability is not proof of anything except that people do illogical things. Second, I can use your same logic by pointing out that some languages require proper indentation to function, like Python. Therefore I must be right, and indentation is not only good practice, but required. I doubt you could name one of your indent-free languages, however.

    now if this was for some proffesional project (job etc) then I could see cleaning it up a little but for what its intended for its fine
    You're missing the whole point of having coding conventions. It's pretty obvious that you're an amateur programmer at best, so I'm wasting my time explaining why conventions exist to you.

  8. #8
    The Patient Dantrag's Avatar
    15+ Year Old Account
    Join Date
    Apr 2009
    Location
    Russia, Rostov-on-Don/Moscow
    Posts
    232

    Re: self-made program: Intellect Calculator

    2 fishbeans
    thanx for advice, but i didn't payed too much attention to formatting. the main reason why i've posted code is to guarantee that this is not something that will blow your pc up =)

    i know that in C/C#/C++ this code would be much smaller, but i know only pascal enough. i'll begin to study C since February 2010.
    as for variables/constants : i knew that, and in some my other projects (f.e. in very simple game where you are controlling pacman with bombs, gun and speed burst abilities and a lot of monsters) i've used a lot of constants and variables have much nicer names, but in such a simple program i was writing formulas just by taking them from my memory (i've spent a lot of paper before ).

    currently now i am studying data organizing / dynamic memory operating, so i'm not so scrubby to don't know about constants capitalization like ThisVariableName.
    also pascal is not case sensitive language so i hadn't paid a lot of attention to function's name's case.
    as for pt.8 : for me this way to organize a ton of *mp5* variables had seemed better (at least while i was making this).

    also you didn't noticed that i didn't use formatted output. i used standart Pabc module to create window and so on.
    p.s. TextOut procedure i've used has this interface:
    TextOut(x:integer,y:integer,s:string); /// outputs string S into the box with coordinates of top left corner (x,y) as a graphic element. after such output this text became uneditable and unaccessible.

    regardless, thanks for advice. next my project will be more readable (if it won't be called 'EyeBleeder' )
    [Talisman of Resurgence] icon is made of small kitten's red eyes. each time you use the proc, the god kills two more kittens to refresh it's icon after cooldown.
    Holy Paladin trinket comparison

  9. #9

    Re: self-made program: Intellect Calculator

    Quote Originally Posted by Even Better Programmer
    #include <stdio.h>

    int main() {
    printf("hello world\n");
    return 0;
    }


    Quote from: Primaul on November 20, 2009, 09:59:45 am
    Legendary items are just that, legendary. If everyone has one (and it's very easy to get) then it ceases to be legendary, just orange.

    Epic items are just that, epic. If everyone has one (and it's very easy to get) then it ceases to be epic, just purple.

  10. #10
    High Overlord Lilbwnr's Avatar
    10+ Year Old Account
    Join Date
    Sep 2009
    Location
    Southern California
    Posts
    116

    Re: self-made program: Intellect Calculator

    i have a calculator of my own it goes like this
    1. open gem slots?
    2. already have my prismatic gem for my meta?
    3. gem int
    4. profit ;D

  11. #11

    Re: self-made program: Intellect Calculator

    Quote Originally Posted by Tinyknight
    This made me lol, your accusing him of being an amateur? Of course hes an amateur! Hes written a little bit of code to do some WoW related arithmatic, not an operating system!
    1. Read what he typed again.

    2. Read the quote pertaining to the sentence you quoted, and who its from.

    3. Scroll up, and read the name of the author.

    4. Reflect on how dumb you look.

  12. #12
    anyone still use this?

    ---------- Post added 2010-07-19 at 06:24 PM ----------

    I ask because I decided to try and use it.... and AS SOON as I clicked to use it my virus scan alerted OFF the hook. dont use it if you dont have a virus scan

  13. #13
    Deleted
    Quote Originally Posted by best programmer
    #include <stdio.h>

    void main() {
    printf("hello world\n");
    }
    even better

  14. #14
    The Lightbringer Requital's Avatar
    15+ Year Old Account
    Join Date
    Jul 2007
    Location
    But-hurt much? Appears so!
    Posts
    3,865
    Quote Originally Posted by Fishbeans View Post
    Your comments make my eyes bleed.
    It's attitudes like yours that make these forums less enjoyable every day. I don't recall anywhere in his post did he say hey help me with my coding. He wrote a simple tool to do a simple job if you don't like it don't use it but don't flame him on offering something to people free of charge. Who cares how you would have coded it you didn't so your opinion is null and void leave the guy alone.

    /endrant

    Good small app does what it's intended to not perfect but gives you a great idea without breaking out spreadsheets I'm not holy and even I used it just to see the accuracy.
    Quote Originally Posted by Boubouille View Post
    Can you imagine if someone insulted you in a thread, you reported it, and I told you "sorry, wrong thread to be butthurt"?

  15. #15
    And this is why I changed my major from Software Engineering to Chemical Engineering.

  16. #16
    Quote Originally Posted by Skulldancer View Post
    Man this could be a key logger
    Did you really have to quote his WHOLE POST just to say that stupid line?

    Jesus Christ, you are an idiot.

  17. #17
    Is there a way you could possibly upload this to a different hosting site for d/l?Rapidshare wont let me d/l because my ISP uses proxys=the Q to download is endless
    I guess I'm back? Sighhhh....

  18. #18
    Thanks for the work.

    As an aside, I can't believe how many of the criticizing people leave the open brace on the same line, smush the first statement directly below it, leave the return statement unisolated, and call it readable.

    ---------- Post added 2010-07-20 at 12:43 PM ----------

    Quote Originally Posted by Forcelink View Post
    Is there a way you could possibly upload this to a different hosting site for d/l?Rapidshare wont let me d/l because my ISP uses proxys=the Q to download is endless
    You could copy and paste the code as he presented it into a text file, and install a pascal compiler and run it yourself. http://www.freepascal.org/ for example.

  19. #19
    Quote Originally Posted by Kavelos View Post
    Thanks for the work.

    As an aside, I can't believe how many of the criticizing people leave the open brace on the same line, smush the first statement directly below it, leave the return statement unisolated, and call it readable.

    ---------- Post added 2010-07-20 at 12:43 PM ----------



    You could copy and paste the code as he presented it into a text file, and install a pascal compiler and run it yourself. http://www.freepascal.org/ for example.
    Ah great, thanks

    Im so bored, time to use my highly limited java knowledge to write the same program >.<
    I guess I'm back? Sighhhh....

  20. #20
    Deleted
    Quote Originally Posted by Fishbeans View Post
    <Snip, really>
    He is coding, They'r hatin much.

    Props for coding a program and sharing it, there is the honesty to copypaste the code into the post and still we get dickwads flaming him.

    To the OP: Good job.

    Yeah, a bit unreadable code but fuck that.

    Edit: Indentation is not supported on the forum, every space in the beginning of the line is trimmed automatically kthx.
    Last edited by mmocc33a037dee; 2010-07-20 at 02:05 PM. Reason: Explanation for dickwads

Posting Permissions

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