C# A* improved pathfinder (fast, lightweight)

Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Quote Originally Posted by maritnmine View Post
    I see everything wrong with using var for simple data types. It makes your code far harder to read (as you cannot see the type the object is or what the function you call returns), it basically throws away half of the readabillity, documentation and maintainbillity of your code. C# is supposed to be a strong-type language, but when some dickhead over at Microsoft (I'm sorry Microsoft, but sometimes you really make some dumb ass decisions) came up with the idea of var. As a result of this, half the example codes over at MSDN looks Javascriptified and is way harder to read if they took their time to write int instead of var. It really annoys me when people says programmers are lazy. We are not. We are supposed to write code which other humans shall be able to effectively read, extend, modify and maintain. At the same time we shall write comments in our code and at least a dozen reports on how we decided to design and implement this and that. If you don't take your time to write self-documented code that is both easy to read and understand, you make a hell not only for yourself when you are going to maintain your code, but also for those "dumb-ass next generation kids" who are going to figure out what your code does in ten years.
    I'm clearly not a fan of weak-type languages and I only think they should be used for scripting purposes and not programming larger systems (like those hipsters who wants to run JavaScript server-side). I have been working on a school project in PHP and JS for about a month now and much of the documentation goes to describe what type this variable is. And when you in addition to your code specify what type this variable is, or what this function returns - I don't really see why the language is weak-type. I have been sitting for hours going through the layers in my web-app to find a bug, which turned out was that I managed to mix up a function parameter with a local value. So, yeah....

    TL;DR: Good programmers aren't lazy and weak-type languages sucks.

    Also, Mextur, don't use "continue;", it creates more exit-points for your foreach which makes it harder to read. break, return and continue are all considered as bad practice when used in foreach where they can easily be avoided by using normal if-statements or adding conditions to a while statement.
    Wrong. Hover over var and you see the type ;)

  2. #17
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Quote Originally Posted by Tha View Post
    Wrong. Hover over var and you see the type ;)
    Yhee, waiting a second to get that hover option and then read the var type.. Everytime you need to do that, you can better write the type down instead of using var. In a long time run, it's more efficient.

    Every searched in a weak-typed code what type a variable is (without running and printing what type it is)? It's annoying and time consuming. I'm talking about people who join the development...

  3. #18
    Retired maritnmine is offline
    MemberRank
    May 2007 Join Date
    North KoreaLocation
    1,103Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Quote Originally Posted by Tha View Post
    Wrong. Hover over var and you see the type ;)
    You do know how much faster it is to read the actual type instead of hovering and waiting for the box to appear?

  4. #19
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,610Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Its actually a derpy solution to use var. Not really you want to use if you want to keep your code clean.

  5. #20
    Freak Mextur is offline
    MemberRank
    Mar 2012 Join Date
    216Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Stop about the var. Focus on my last code.

  6. #21
    Retired maritnmine is offline
    MemberRank
    May 2007 Join Date
    North KoreaLocation
    1,103Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Quote Originally Posted by Mextur View Post
    Stop about the var. Focus on my last code.
    No, this is all about the var. Don't use var. Var is bad, mkay.

  7. #22
    Freak Mextur is offline
    MemberRank
    Mar 2012 Join Date
    216Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Quote Originally Posted by maritnmine View Post
    No, this is all about the var. Don't use var. Var is bad, mkay.
    Yea i know. Its bad everywhere but why not use it sometimes when it is there.

  8. #23
    Account Upgraded | Title Enabled! AWA is offline
    MemberRank
    Feb 2008 Join Date
    1,320Posts

    Re: C# A* improved pathfinder (fast, lightweight)

    Here's my rotation function, cleaner and about the same speed as the commonly used one:
    PHP Code:
    internal static int Calculate(int X1int Y1int X2int Y2bool moonwalk false)
    {
        
    int dX X2 X1;
        
    int dY Y2 Y1;

        if (
    moonwalk)
        {
            
    dX *= -1;
            
    dY *= -1;
        }
        
    double d Math.Atan2(dYdX)*180/Math.PI;
        return ((int) 
    90)/45;

    Last edited by AWA; 06-03-14 at 05:47 PM.



Page 2 of 2 FirstFirst 12

Advertisement