Developers -vs- Coding

Options
Saitada - Sanctuary
Saitada - Sanctuary Posts: 3,220 Arc User
edited February 2009 in General Discussion
I see so many people screaming and yelling about various mistakes that work their way into the game. One of course being the recent one with the clothing exploit. The rant goes "OMFGWTFBBQ how could you have made such a mistake! OMG it's a scam! WTF your all just idiots! etc etc.

So... ya'll are so bright and smart. so GOOOOOOOD at writing code that you would NEVER make a syntax error or accidentally add an extra 0, or even possibly have a sticky key your unaware of at first. Oh hell, how about your so good you never accidentally bumped another key while typing..

So... your so smart. So "Good" that you never make a mistake. That something has never made it past you. You have always had 100% on every test you did from the time you were in kindergarten till now. Your GOD incarnate.

Alright smart ****. Figure out where the mistake is in this code.... It is a simple mistake that can happen by accidentally BUMPING another key while typing and one a compiler would even overlook as an error and allow through.

C'Mon.. you can figure it out. YOUR SO SMART AND KNOW CODERS NEVER MAKE MISTAKES!

# questor.py 3/11/96 Nuff Said

# define some constants for future use

kQuestion = 'question'
kGuess = 'guess'

# define a function for asking yes/no questions
def yesno(prompt):
ans = raw_input(prompt)
return (ans[0]=='y' or ans[0]=='Y')

# define a node in the question tree (either question or guess)
class Qnode:

# initialization method
def __init__(self,guess):
self.nodetype = kGuess
self.desc = guess

# get the question to ask
def query(self):
if (self.nodetype == kQuestion):
return self.desc + " "
elif (self.nodetype == kGuess):
return "Is it a " + self.desc + "? "
else:
return "Error: invalid node type!"

# return new node, given a boolean response
def nextnode(self,answer):
return self.nodes[answer]

# turn a guess node into a question node and add new item
# give a question, the new item, and the answer for that item
def makeQuest( self, question, newitem, newanswer ):

# create new nodes for the new answer and old answer
newAnsNode = Qnode(newitem)
oldAnsNode = Qnode(self.desc)

# turn this node into a question node
self.nodetype = kQuestion
self.desc = question

# assign the yes and no nodes appropriately
self.nodes = {newanswer:newAnsNode, not newanswer:oldAnsNode}



def traverse(fromNode):
# ask the question
yes = yesno( fromNode.query() )

# if this is a guess node, then did we get it right?
if (fromNode.nodetype == kGuess):
if (yes):
print "I'm a genius!!!"
return
# if we didn't get it right, return the node
return fromNode

# if it's a question node, then ask another question
return traverse( fromNode.nextnode(yes) )

def run():
# start with a single guess node
topNode = Qnode('python')

done = 0
while not done:
# ask questions till we get to the end
result = traverse( topNode )

# if result is a node, we need to add a question
if (result):
item = raw_input("OK, what were you thinking of? ")
print "Enter a question that distinguishes a",
print item, "from a", result.desc + ":"
q = raw_input()
ans = yesno("What is the answer for " + item + "? ")
result.makeQuest( q, item, ans )
print "Got it."

# repeat until done
print
done = not yesno("Do another? ")
print


# immediate-mode commands, for drag-and-drop or execfile() execution
if __name__ == '__main__':
run()
print
raw_input_("press Return>")
else:
print "Module questor imported."
print "To run, type: questor.run()"
print "To reload after changes to the source, type: reload(questor)"

# end of questor.py

Can't figure it out? What? Not so bright huh? Alright then. Give the Coders a break. Mistakes happen. When they do, just grin and bear it. When your dealing with Millions/Billions of lines of code (instead of the 101 above), ONE mistake can really mess a LOT of things up. It can have a cascading effect on multiple items and be a REAL pita to find. QA can miss it easily enough. Happens all the time. So give the coders a break and "if you find an error, report it, don't exploit it."

~Saitada
Post edited by Saitada - Sanctuary on
«1

Comments

  • Devarsi - Sanctuary
    Devarsi - Sanctuary Posts: 542 Arc User
    edited February 2009
    Options
    well to be fair .. coders do have debuggers and they don't just have to sit and read their code line by line (yes i know the debugger doesn't always give the exact line of the error.. but it gives you a starting point to work back from) .. also the recent errors were the more evil.. the ones that still allow the program to compile but are still screwed up ..

    Now I have no idea if the error in the code above is a compile error or not .. hell i dont even know what language that is .. and i wouldn't wanna start sifting through that without being able to compile and see whats messing up
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    well to be fair .. coders do have debuggers and they don't just have to sit and read their code line by line (yes i know the debugger doesn't always give the exact line of the error.. but it gives you a starting point to work back from) .. also the recent errors were the more evil.. the ones that still allow the program to compile but are still screwed up ..

    Now I have no idea if the error in the code above is a compile error or not .. hell i dont even know what language that is .. and i wouldn't wanna start sifting through that without being able to compile and see whats messing up
    Codes Python and the single error is an added _ that a compiler would pass w/o squeeking about. A debugger would most likely overlook it as well although it depends on the debugger used. Some might catch it.

    ~Saitada
  • OMGLAZERZ - Heavens Tear
    OMGLAZERZ - Heavens Tear Posts: 2,327 Arc User
    edited February 2009
    Options
    Better one :: find the bug(s), and/or figure out what it's supposed to do. If you do, please tell me because I forgot (or did I?). b:chuckle

    EDIT: Look people, I wrote the code below as part of a project for CS 270 when I was working on my Associates Degree in 1994. I know what is wrong with it, and I don't need a primer on how to properly write code, or someone with a self-esteem problem to tell me I'm a moron or insinuate such. I posted it because I could, and I thought it was funny. The code itself is pretty clean, not the best, yes, but it isn't the worst code in the world. Yes, it is uncommented which is why I poked fun at it with the "figure out what it does, please tell me" line because when I went back a few years ago to try and re-work it, it took hours to figure it out. I cannot say whether it's commented now or not since I couldn't find it, but it's probably written in C# now, I think.

    Why did I post it beyond that? Because it's a good example of what can happen when you get a really complicated program that should work but doesn't because there is a bug buried deep within it somewhere that the person who wrote it even with proper commenting could have problems finding. I'm sure there is a bug in the code somewhere because the last part I was working on, the division function was not working properly, if I remember right. It was also the most complicated function requiring all the other functions to work correctly.

    But, what's it supposed to do? It was supposed to do basic mathematics how you would do it, not how a computer would do it. It interprets the number how a person would interpret a number by it's digits and base. The actual calculations are integer calculations done how a computer would do them, but that's at the lowest level of operation. The reason for that was as an attempt to see how accurate of a calculation I could get the computer to do without actually relying on floating point calculations. What kind of accuracy am I talking about? 8 digit? 9? 20?

    No, something on a much larger scale: several trillion. Numbers so big I cannot even begin to imagine how big or small it would be. This would require using arrays to hold the numbers in digit form using a base-X number system where X could be any number that was small enough to be calculated within that variable type whether it be an Integer or a long. The bigger the number the variable could hold while doing that, the bigger the number that could be seen using fewer array elements at the expense of more memory.

    Sure, if you have an incessant need to feel superior to someone else, go ahead and post more about how my code that is ~15 years old is crappy, and how I don't know anything about programming because it's obviously the best code I've ever written in my life.

    Go on, do it I know you need to feel better about your lot in life.


    Oh, and for the record, the for loop in the main() function is there so I can test the other functions multiple times by simply changing the 1 to any number of iterations I want it to go through such that I don't have to continually add and delete the loop code or constantly comment it out.
    #include<stdio.h>
    #include<string.h>
    
    #define MAX 10
    #define DMAX MAX*2
    #define TMAX MAX*3
    
    void remzeros(int str[]);
    void setarray(int str[]);
    void disp(int a[]);
    void mult(int num1[],int num2[],int result[]);
    void cont(void);
    int crry(int num[],int i);
    void add(int a[],int b[],int res[]);
    void sub(int num1[],int num2[],int result[]);
    void subarr(int num1[],int num2[],int result[]);
    void div(int num1[],int num2[],int result[]);
    int comp(int top[],int bot[]);
    
    main()
    { int num1[MAX+1],num2[MAX+1],result[DMAX+1],tmp[DMAX+1];
      int i,n;
      num1[0]=MAX;num2[0]=MAX;result[0]=DMAX;tmp[0]=DMAX;
      for(i=0;i<1;++i)
      { for(n=0;n<MAX;++n) num1[n]=num2[n]=0;
        printf("\n\nEnter the 1st # not to exceed %d digits:\n",TMAX);
        setarray(num1);
        printf("\n#1: ");disp(num1);
        printf("\n\nEnter the 2nd # not to exceed %d digits:\n",TMAX);
        setarray(num2);
        printf("\n#2: ");disp(num2);
    
    //     sub(num1,num2,result);
    //     for(n=0;n<=result[0];++n) tmp[n]=result[n];
        div(num1,num2,result);
    //     add(num1,num2,result);
    //     mult(num1,num2,result);
        cont();
      }
    }
    
    // ---------------- Functions --------------------- 
    void div(int num1[],int num2[],int result[])
    { int n,tmp[DMAX+1],dres[DMAX+1],ch=0,res,tst=0;
      for(n=1;n<=DMAX;++n) tmp[n]=dres[n]=result[n]=0;
      for(n=1;n<=num2[0];++n) tmp[n]=num1[n];
      tmp[0]=num2[0];
      printf("\ncomp%cnum1,num2%c = %d",'(',')',comp(num1,num2));
      if(comp(num1,num2)!=0)
      {
          do
          { for(n=1;n<=tmp[0];++n) tmp[n]=num1[n];
            if(comp(tmp,num2)==0)
            { ++tmp[0];ch=-1;
            } else ch=0;
          } while(ch==-1);
          dres[0]=tmp[0];res=0;ch=0;
          
          do
          { 
            if(comp(tmp,num2)!=0)
            { ++res;
              subarr(tmp,num2,result);
              tmp[0]=result[0];
              remzeros(result);
              for(n=1;n<=result[0];++n) tmp[n]=result[n];
              result[1]=tmp[0];tmp[0]=result[0];result[0]=result[1];
              for(n=1;n<=result[0];++n) result[n]=0;
            }
            else if(comp(tmp,num2)==0 && dres[0]<num1[0])
            { printf("\nI got in here!!! <2>");
              do
              { dres[dres[0]]=res;res=0;
                ++tmp[0];++dres[0];
                tmp[tmp[0]]=num1[dres[0]];
              } while(comp(tmp,num2)==0 && dres[0]<num1[0]);
            }
            else ch=-1;
          } while(ch==0);
      } else res=0;
      dres[dres[0]]=res;
      remzeros(dres);
      for(n=1;n<DMAX;++n) tmp[n]=0;
      for(n=1;n<result[0];++n) result[n]=0;
      tmp[0]=DMAX;
      mult(num2,dres,tmp);
      sub(num1,tmp,result);
      
      printf("\n\n ");disp(num1);printf("\n/");disp(num2);
      printf("\n-----------------------------------");
      disp(dres);
      printf("\nRemainder = ");disp(result);
      return;
    }
    int comp(int top[],int bot[])
    { int i=1,n=-1;
      if(top[0]<bot[0]) n=0;
      else if(top[0]>bot[0]) n=-1;
      else
      { while(n==-1)
        { if(top[i]<bot[i]) n=0;
          else if(top[i]>bot[i]) n=1;
          else if(i==bot[0]) n=0;
          else ++i;
        }
        if(i==bot[0]) if(top[i]==bot[i]) n=1;
      }
      return(n);
    }
    
    void cont()
    { char reply;printf("\nPress any key.");scanf("%c",&reply);return; }
    
    void setarray(int str[])
    { char c;
      int n,i,err=1,tmp[TMAX+1];
      for(i=0;i<TMAX;++i) tmp[i]=0;
      while(err==1)
      { err=0;tmp[0]=1;i=1;c='n'; 
        while((c=getchar())!='\n')
        { if(tmp[0]<=TMAX)
          { if(c>='0' && c<='9') tmp[tmp[0]]=c-48;
    //         printf("\n%d ",tmp[tmp[0]]);
    //         printf("\ntmp[0] = %d",tmp[0]);
            ++tmp[0];
          } else if(tmp[0]>TMAX) err=2;
          ++i;
          if((c<'0' || c>'9') && c!='\n') err=1;
        }
        if(i==1) err=1;
        if(err==1) printf("You have entered an invalid number.\nPlease re-enter the data.\n\n");
        else if(i-1>TMAX || err==2)
        { printf("\n\nThe data you have entered is larger than allowed.\nPlease re-enter the data.\n\n"); err=1;
        }
      }
      --tmp[0];
    //   printf("\ntmp[0] = %d\n",tmp[0]);disp(tmp); 
      for(i=MAX;tmp[0]>2;tmp[0]-=3,--i)
      {
          str[i]=tmp[tmp[0]-2]*100+tmp[tmp[0]-1]*10+tmp[tmp[0]];
    //       printf("\nstr[%d] = %d    tmp[0] = %d",i,str[i],tmp[0]);
      }
    //   printf("\nstr[%d] = %d    tmp[0] = %d",i,str[i],tmp[0]);
      if(tmp[0]==2)
      {
          str[i]=tmp[1]*10+tmp[2];
    //       printf("\ntest a   str[%d] = %d    tmp[0] = %d",i,str[i],tmp[0]);
      }
      else if(tmp[0]==1)
      {
          str[i]=tmp[1];
    //       printf("\ntest b  str[%d] = %d    tmp[0] = %d",i,str[i],tmp[0]);
      }
      str[0]=MAX;
    //   disp(str);
    //   
      remzeros(str);
    //   printf("\nstr[0] = %d",str[i]);
    
      return;
    }
    
    void remzeros(int a[])
    { int i=1,n=0;
    //   printf("\na[0] = %d   ",a[0]);
      if(a[1]==0)
      {
        while(a[i]==0 && i<=a[0]) ++i;
        if(i>a[0])
        { n=1;a[1]=0;
        }
        else if(i>0)
        { for(;i<=a[0];++i,++n)
          { a[n+1]=a[i];
            a[i]=-9999;
          }
        }
      }else n=a[0];
    //   printf("\nn = %d",n);
    
      a[0]=n;
      return;
    }
    
    void disp(int a[])
    { int i;
        printf("\n");
      for(i=1;i<a[0];++i)
      {
    // printf("\ni = %d   a[%d] = ",i,i);
          if(a[i]>99 || i==1) printf("%d,",a[i]);
        else if(a[i]>9) printf("0%d,",a[i]);
        else printf("00%d,",a[i]);
      }
    //   printf("\ni = %d   a[%d] = ",i,i);
      if(a[i]>99 || i==1) printf("%d",a[i]);
      else if(a[i]>9) printf("0%d",a[i]);
      else printf("00%d",a[i]);
      return;
    }
    
    int crry(int num[],int i)
    { int c=0;
      while(num[i]>999){ ++c;num[i]-=1000; }return(c);
    }
    void add(int a[],int b[],int res[])
    { int n,i,r,carry,t;
    
      for(n=1;n<res[0];++n) res[n]=0;
      if(a[0]==1 && a[1]==0)
      { r=res[0];
          for(t=b[0];t>0;--t,--r) res[r]=b[t];
        }
        else if(b[0]==1 && b[1]==0)
        { r=res[0];
          for(t=a[0];t>0;--t,--r) res[r]=a[t];
        }
        else
        {
          if(a[0]>=b[0]) t=b[0];
          else t=a[0];
          n=a[0];i=b[0];r=res[0];carry=0;
          for(;t>0;--t,--n,--i,--r)
          { res[r]=a[n]+b[i]+carry; carry=crry(res,r);
    //         printf("\nres[%d] = %d   carry = %d",r,res[r],carry);
          }
    //    disp(res);
          if(a[0]>b[0])
          { for(;n>0;--n,--r)
              { res[r]=a[n]+carry; carry=crry(res,r);
    //           printf("\nres[%d] = %d   carry = %d",r,res[r],carry);
              }
          }
          else if(a[0]<b[0])
          { for(;i>0;--i,--r)
              { res[r]=b[i]+carry; carry=crry(res,r);
    //           printf("\nres[%d] = %d   carry = %d",r,res[r],carry);
              }
            }
            res[r]+=carry;
        }
    //     disp(res);
        remzeros(res);
      printf("\n\n ");disp(a);printf("\n+");disp(b);
      printf("\n-----------------------------------");
      disp(res);
      return;
    }
    void mult(int num1[],int num2[],int result[])
    { int n,out,in,off,carry,i;
      for(n=1;n<=result[0];++n) result[n]=0;
      for(out=num2[0],off=result[0];out>0;--out,--off)
      { carry=0;
        for(in=num1[0],i=off;in>0;--in,--i)
        { result[i]=result[i]+carry+(num1[in]*num2[out]); carry=crry(result,i);
        }
        for(;result[0]<(num1[0]+num2[0]);--i)
        { result[i]+=carry; carry=crry(result,i);
        }
        result[i]+=carry;
          
      }
      remzeros(result);
    //   printf("\nJust removed some zeros!!");
      printf("\n\n ");disp(num1);printf("\nx");disp(num2);
      printf("\n-----------------------------------");
      disp(result);
      return;
    }
    void sub(int num1[],int num2[],int result[])
    { int n,ch=0;
    
      for(n=1;n<=result[0];++n) result[n]=0;
      if(num1[0]>num2[0]) n=-1;
      else if(num2[0]>num1[0]) n=-2;
      else
      { n=1;
        while(n>=1 && n<=num1[0])
        { if(num1[n]>num2[n]) n=-1;
          else if(num2[n]>num1[n]) n=-2;
          else if(num1[n]==num2[n]) ++n;
        }
      }
      if(n==-1) subarr(num1,num2,result);
      else if(n==-2) subarr(num2,num1,result);
      else if(n==num1[0]) result[1]=0;
      remzeros(result);
      if(n==-2) result[1]*=-1;
      printf("\n\n ");disp(num1);printf("\n-");disp(num2);
      printf("\n-----------------------------------");
      disp(result);
      return;
    }
    
    void subarr(int num1[],int num2[],int result[])
    {
      int n,i,t,tmp[MAX+1],a,err=0,ch;
      for(a=1;a<=MAX;++a) tmp[a]=result[a]=0;
      for(a=0;a<=num1[0];++a) tmp[a]=num1[a];
      
      for(n=num1[0],i=num2[0],t=result[0];i>0;--n,--i,--t)
      { if(tmp[n]<num2[i])
        { if(n>0)
          { a=n-1;ch=0;
            while(err==0)
            { if(a>1)
              { if(tmp[a]<=0)
                { --a;++ch;
                } else err=-1;
              }else err=-1;
            }
            if(ch<=n)
            { for(a=0;a<=ch;++a)
              { tmp[n-a]+=1000;
                tmp[n-(a+1)]-=1;
              }
            }
          }
        }
        if(tmp[n]>num2[i]) result[t]=tmp[n]-num2[i];
      }
      for(;n>0;--n,--t) result[t]=tmp[n];
      return;
    }
    
    [SIGPIC][/SIGPIC]
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    C++? Or??

    Still trying to learn Python... Got a book on C++ I haven't gotten into yet. I Mostly do web design and hosting. MySQL **** etc.

    ~S
  • OMGLAZERZ - Heavens Tear
    OMGLAZERZ - Heavens Tear Posts: 2,327 Arc User
    edited February 2009
    Options
    C++? Or??

    Still trying to learn Python... Got a book on C++ I haven't gotten into yet. I Mostly do web design and hosting. MySQL **** etc.

    ~S

    It's ANSI C
    [SIGPIC][/SIGPIC]
  • Bobncut - Sanctuary
    Bobncut - Sanctuary Posts: 419 Arc User
    edited February 2009
    Options
    @OMGLAZERZ: This is easy. It is supposed to illustrate improper use of comments. I love the fact that you included lots of code lines commented out of the compiled program, but not a single comment line to tell what the code does.
  • OMGLAZERZ - Heavens Tear
    OMGLAZERZ - Heavens Tear Posts: 2,327 Arc User
    edited February 2009
    Options
    @OMGLAZERZ: This is easy. It is supposed to illustrate improper use of comments. I love the fact that you included lots of code lines commented out of the compiled program, but not a single comment line to tell what the code does.

    Improper use of comments? Do you even know what was commented out? Check-point print statements used to check what's in certain variables at certain check points and so you can see if the program is behaving itself, or figure out where the code went haywire. They are commented out because at that point they weren't needed, but due to the need to test them in the future they were retained, but commented out to keep them from executing.


    And you are wrong as to the point of the code.


    So, you cannot figure out what the code is supposed to do by reading the <main> function?
    [SIGPIC][/SIGPIC]
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    Unless I'm mistaken (and it's possible as I'm not real familiar with code yet) It appears to be a program for calculating refinements to weapons/armor, etc. at least some of what I see seems that way.

    ~S
  • Bobncut - Sanctuary
    Bobncut - Sanctuary Posts: 419 Arc User
    edited February 2009
    Options
    Hehe I know what you were commenting out. That is how my old C code always looked (all the debug statements left where I had needed them at one point and not a line of comment to help the next reader - although I did usually try to get the tabs right for the {} pairs). But, to be fair, you are also commenting out the modules you did not include - the ones for doing other things than division to user inputted 30 digit numbers.
  • Lessie - Lost City
    Lessie - Lost City Posts: 917 Arc User
    edited February 2009
    Options
    Is the error this line?

    "elif (self.nodetype == kGuess):"
    [SIGPIC][/SIGPIC]
    ^^ Made by Saitada ^^

    Dieho: I win 15 on 1, I roll all of your guild to sz all by myself !
    Lessie: Proof?
    Dieho: I dont have any, but my word is more than enough.
    Lessie: Well I won 33 on 1 the other day :D
    b:cute
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    Is the error this line?

    "elif (self.nodetype == kGuess):"
    nope the error is here where it says raw_input_

    # immediate-mode commands, for drag-and-drop or execfile() execution
    if __name__ == '__main__':
    run()
    print
    raw_input_("press Return>")
    else:
    print "Module questor imported."
    print "To run, type: questor.run()"
    print "To reload after changes to the source, type: reload(questor)"

    # end of questor.py

    the _ after input is the added error in the code, it shouldn't be there. so the line itself should read:

    # immediate-mode commands, for drag-and-drop or execfile() execution
    if __name__ == '__main__':
    run()
    print
    raw_input("press Return>")
    else:
    print "Module questor imported."
    print "To run, type: questor.run()"
    print "To reload after changes to the source, type: reload(questor)"

    # end of questor.py

    ~Saitada
  • Asterelle - Sanctuary_1381265973
    Asterelle - Sanctuary_1381265973 Posts: 7,881 Arc User
    edited February 2009
    Options
    With python indentation is a part of language and defines the flow control. The code you pasted has no indentation and so will not work. What do I win?

    Before you insult people for not spotting a typo in some random python you should learn how to paste it in a readable manner such as how OMGLAZERZ did it.
    [SIGPIC][/SIGPIC]
    Refining Simulator - aster.ohmydays.net/pw/refiningsimulator.html (don't use IE)
    Genie Calculator - aster.ohmydays.net/pw/geniecalculator.html - (don't use IE)
    Socket Calculator - aster.ohmydays.net/pw/socketcalculator.html
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    With python indentation is a part of language and defines the flow control. The code you pasted has no indentation and so will not work. What do I win?

    Before you insult people for not understanding some random python you should learn how to paste it in a readable manner such as how OMGLAZERZ did it.

    rofl, tbh I never even noticed the lack of indentation. Wasn't paying any attention to that lol. Thanks for catching that part!

    ~S
  • OMGLAZERZ - Heavens Tear
    OMGLAZERZ - Heavens Tear Posts: 2,327 Arc User
    edited February 2009
    Options
    Hehe I know what you were commenting out. That is how my old C code always looked (all the debug statements left where I had needed them at one point and not a line of comment to help the next reader - although I did usually try to get the tabs right for the {} pairs). But, to be fair, you are also commenting out the modules you did not include - the ones for doing other things than division to user inputted 30 digit numbers.

    The tabs are right: I was using a coding convention.

    The functions actually call each other, the main is just there to call them while working on them. The functions were going to be used in something I never quite got around to because it got really complicated when it came to decimals, and a lot had to be re-written. If properly finished it was supposed to be able to handle addition, subtraction, multiplication and division of numbers using a base-"X" number system.
    [SIGPIC][/SIGPIC]
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    Ok here it is corrected. It still has the error in it.
    # questor.py		3/11/96 Nuff Said
    
    # define some constants for future use
    
    kQuestion = 'question'
    kGuess = 'guess'
    
    # define a function for asking yes/no questions
    def yesno(prompt):
    	ans = raw_input(prompt)
    	return (ans[0]=='y' or ans[0]=='Y')
    
    # define a node in the question tree (either question or guess)
    class Qnode:
    	
    	# initialization method
    	def __init__(self,guess):
    		self.nodetype = kGuess
    		self.desc = guess
    
    	# get the question to ask	
    	def query(self):
    		if (self.nodetype == kQuestion):
    			return self.desc + " "
    		elif (self.nodetype == kGuess):
    			return "Is it a " + self.desc + "? "
    		else:
    			return "Error: invalid node type!"
    
    	# return new node, given a boolean response
    	def nextnode(self,answer):
    		return self.nodes[answer]
    
    	# turn a guess node into a question node and add new item
    	# give a question, the new item, and the answer for that item
    	def makeQuest( self, question, newitem, newanswer ):
    
    		# create new nodes for the new answer and old answer
    		newAnsNode = Qnode(newitem)
    		oldAnsNode = Qnode(self.desc)
    
    		# turn this node into a question node
    		self.nodetype = kQuestion
    		self.desc = question
    
    		# assign the yes and no nodes appropriately
    		self.nodes = {newanswer:newAnsNode, not newanswer:oldAnsNode}
    	
    	
    
    def traverse(fromNode):
    	# ask the question
    	yes = yesno( fromNode.query() )
    	
    	# if this is a guess node, then did we get it right?
    	if (fromNode.nodetype == kGuess):
    		if (yes):
    			print "I'm a genius!!!"
    			return
    		# if we didn't get it right, return the node
    		return fromNode
    	
    	# if it's a question node, then ask another question
    	return traverse( fromNode.nextnode(yes) )
    
    def run():
    	# start with a single guess node
    	topNode = Qnode('python')
    	
    	done = 0
    	while not done:
    		# ask questions till we get to the end
    		result = traverse( topNode )
    		
    		# if result is a node, we need to add a question
    		if (result):
    			item = raw_input("OK, what were you thinking of? ")
    			print "Enter a question that distinguishes a",
    			print item, "from a", result.desc + ":"
    			q = raw_input()
    			ans = yesno("What is the answer for " + item + "? ")
    			result.makeQuest( q, item, ans )
    			print "Got it."
    		
    		# repeat until done
    		print
    		done = not yesno("Do another? ")
    		print
    
    
    # immediate-mode commands, for drag-and-drop or execfile() execution
    if __name__ == '__main__':
    	run()
    	print
    	raw_input_("press Return>")
    else:
    	print "Module questor imported."
    	print "To run, type: questor.run()"
    	print "To reload after changes to the source, type: reload(questor)"
    
    # end of questor.py
    

    p.s. And before anyone has the chance to say it.. No. I did not write this piece myself, it's a copy and paste job from someone else.

    ~S
  • OMGLAZERZ - Heavens Tear
    OMGLAZERZ - Heavens Tear Posts: 2,327 Arc User
    edited February 2009
    Options
    With python indentation is a part of language and defines the flow control. The code you pasted has no indentation and so will not work. What do I win?

    Before you insult people for not spotting a typo in some random python you should learn how to paste it in a readable manner such as how OMGLAZERZ did it.

    I didn't even notice my initial post had gotten all un-indented like it had...had to go back and add the tags. It looked fine when I posted...copypasta from the file.
    [SIGPIC][/SIGPIC]
  • Amy_Nailo - Lost City
    Amy_Nailo - Lost City Posts: 141 Arc User
    edited February 2009
    Options
    It is the company's job to ensure that they release a bug-free (as much as possible) software. It's the same thing in every aspect of business when you have customers. What would happen if your car's brake suddenly stops working because of an unknown bug ? You would be mad pissed for buying something malfunctioning. Its the same thing with perfect world, when a serious bugs happens, players are mad and they are right to be mad. (Don't give me the "It's free" ********).

    Bugs happen, it's unfortunate, the coders / developpers / designer of perfect world don't mean them to happen, but they do. Everyone has to live with it. They do the best they can to prevent them, and I'm pretty sure they are as mad as the players when they happen.

    Before you start blasting me, let me tell you that I don't think yelling and complaining online is a good thing to do, BUT, I understand the people that are mad and says it.

    - Amy
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    It is the company's job to ensure that they release a bug-free (as much as possible) software. It's the same thing in every aspect of business when you have customers. What would happen if your car's brake suddenly stops working because of an unknown bug ? You would be mad pissed for buying something malfunctioning. Its the same thing with perfect world, when a serious bugs happens, players are mad and they are right to be mad. (Don't give me the "It's free" ********).

    Bugs happen, it's unfortunate, the coders / developpers / designer of perfect world don't mean them to happen, but they do. Everyone has to live with it. They do the best they can to prevent them, and I'm pretty sure they are as mad as the players when they happen.

    Before you start blasting me, let me tell you that I don't think yelling and complaining online is a good thing to do, BUT, I understand the people that are mad and says it.

    - Amy

    Exactly.

    ~S
  • Hisui - Heavens Tear
    Hisui - Heavens Tear Posts: 1,369 Arc User
    edited February 2009
    Options
    python sucks. learn j2ee.
    [SIGPIC][/SIGPIC]
    私の番ですよ。- Sig by Symour

    Check out ForsakenX 's sig thread O_O
    Enrage - We Eat.
  • jemima
    jemima Posts: 5 Arc User
    edited February 2009
    Options
    A compiler wouldn't overlook the error you had in your code.
    Python is generally interpreted, so you won't get an error until you reach that line in the code, at which point you'll get a nice descriptive error telling you exactly what's wrong.
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "blah.py", line 95, in ?
        raw_input_("press Return>")
    NameError: name 'raw_input_' is not defined
    
    Were the code actually compiled, it would be picked up at run time.

    Try it. Go type random characters after the raw_input_ line. You won't get an error having a line that says "asdasfasfasfdasfasf" until the interpreter reaches that line.


    And seriously, this thread fails. You try to point out how hard coding is by posting up a basic python program with an easily picked up error. While it works with a mainly non-programming audience, which you have, any decent programmer should be able to pick it up fairly easily (assuming they actually know python. If they didn't it might be merely easy instead of trivial).
    int array[10];
    init_array(array);
    int n=0;
    while(n++<10){
      do_something(array[n]);
    }
    
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    jemima wrote: »
    You try to point out how hard coding is by posting up a basic python program with an easily picked up error. While it works with a mainly non-programming audience, which you have, any decent programmer should be able to pick it up fairly easily (assuming they actually know python. If they didn't it might be merely easy instead of trivial).
    My point was, that writing code and having a mistake slip through, wasn't as unusual as most would like to pretend. I added one small error into the code I showed to make the point visually that mistakes can and do happen, and while the devs don't want them too, errors CAN slip in that they miss. Some errors wouldn't even throw the compiler off and could slip through like items selling for 1000000 instead of 100000 the accidental addition of a single 0 and you have 10x what the item "should" sell for.

    As I don't have a compiler on this machine I didn't bother to check to see if what I did would throw an error. I admit to assuming it probably wouldn't. In that from your example I would be proven wrong, but my point still remains unchanged.

    ~Saitada
  • Tigriss - Heavens Tear
    Tigriss - Heavens Tear Posts: 760 Arc User
    edited February 2009
    Options
    b:surrenderb:surrender I don't understand any of this thread. Good thing I don't complain about anything but other players.b:surrenderb:surrender
    "Jesus fricking christ on a pogo stick. Your a mass of fricking idiots I swear!"
    -Saitada
    [SIGPIC][/SIGPIC]
    Thankies Crystalynnex
  • bobzilla21
    bobzilla21 Posts: 694 Arc User
    edited February 2009
    Options
    I got it! the last raw_input_("press Return>") shouldn't have that 2nd "_" in there.

    EDIT: Dang, you already posted the answer...why'd I waste my time searching then.b:cry
    I figured I should do something with my sig, so I made this for fun. My very first (poorly made) animation. b:victory
    [SIGPIC][/SIGPIC]
    As for why Luffy is murdering Naruto, I have no idea either, but it looks cool.b:laugh
  • Solandri - Heavens Tear
    Solandri - Heavens Tear Posts: 2,843 Arc User
    edited February 2009
    Options
    My point was, that writing code and having a mistake slip through, wasn't as unusual as most would like to pretend. I added one small error into the code I showed to make the point visually that mistakes can and do happen, and while the devs don't want them too, errors CAN slip in that they miss. Some errors wouldn't even throw the compiler off and could slip through like items selling for 1000000 instead of 100000 the accidental addition of a single 0 and you have 10x what the item "should" sell for.

    A good programmer writes robust code. He considers the possibility of common errors and writes code which checks to prevent them. Input errors are very common, and should be expected, especially if they can have the devastating effect that we saw. For the example you gave, just add a few lines of code which at startup checks all the input item values against the current price of gold. If its sell price to an NPC is higher than its equivalent value in gold, then stop the server startup and throw up an error message on the server console.

    e.g. Item sells 3 gold in the cash shop and should sell for 100,000 to an NPC. When starting the server, it checks the current price of gold for the last 100 sales, sees it's selling for an average 100k/gold. 3*100k > 100000, so it passes and continues with startup.

    But if the value has accidentally been keyed in as 1,000,000, it checks and sees 3*100k < 1000000, so fails, stops the startup, and spits out an error message about the price being out of bounds.

    Least that's the way I write code. (And before you ask, yes I'd add a failsafe so when starting a new server with no historical gold sales, the default conversion rate is not 0 coin per gold.)
  • Darksylph - Heavens Tear
    Darksylph - Heavens Tear Posts: 1,816 Arc User
    edited February 2009
    Options
    I don't think most people got upset that a bug existed. I've played multiple MMORPGs, and glitches and bugs slip through on occasion. But there's 2 things which could have been and have been done better on other games to handle the situation.

    (1) Test servers. Many games have public or semi-public test servers. New patch content is applied here first & players actively search for glitches. Many bugs are caught here first before going to the main play servers. These are sort-of Beta testers for patches.

    (2) A quicker response to what had happened. On Sanctuary, Gold prices were rising tremendously for many hours before the game was finally taken down. Posts appeared on the forums again many hours before anything was done. Now i know some dont understand the importance and might ***** when they took the servers down for emergency maintenance. I would not. And even though on the forums you see many of the most 'addicted' users, the majority of users tend to understand and go on with other things.

    So no, i dont expect all coding to be flawless and perfect the first time around. I understand mistakes happen and nobody is perfect. I do however think more preventative measures could have been taken then what actually happened.

    Also of note, many people made alot of money through selling gold at inflated prices due to the glitch. And these abusers werent punished and got to keep alot of profits. Most companies would have chosen to do a roll-back in such cases. I do not know the reasons that PWI chose not to. Some assume it was because they didnt keep updated backups. If that was the case, then again, better preventative measure comes to mind. Some say it was due to the almighty dollar, and while there's nothing illegal with that, it's still an unethical decision. While PWI says they owe noone a refund once you purchase zen, it falls under the same idea as a recall. Where a company choses to take back there product (in this case, zen sold during the glitch) and refund the money, or at the very least, re-credit the account (this under the assumption that there was a roll-back and as such none of the gold ever entired into the economy)
  • Saitada - Sanctuary
    Saitada - Sanctuary Posts: 3,220 Arc User
    edited February 2009
    Options
    A good programmer writes robust code. He considers the possibility of common errors and writes code which checks to prevent them. Input errors are very common, and should be expected, especially if they can have the devastating effect that we saw.

    Yup I'm learning that. I'm primarily self taught. Taught myself HTML, XHTML, XML (<---still working out the differences between all these three), CSS, some MySQL, and PHP as I needed. Still learning the ins and outs of MySQL and PHP, and starting on Python and planning on C++ and Java. Doing all that and learning Linux from scratch to move away from windows based systems completely.

    ~S
  • Yukiko - Lost City
    Yukiko - Lost City Posts: 178 Arc User
    edited February 2009
    Options
    Good thing developers aren't required to know their trade and ensure there are no mistakes... oh wait..

    Syntax errors = It just won't work (in 99.9% of cases)
    Forgetting to fix a numerical value = Priceless, or a few million from an NPC.

    I can see how Saitada would assume such a thing, being relatively new at Programming, but you need to see the bigger picture here. People invest real money in this game, free to play or not, and money is of course what keeps this game going. You make mistakes such as this, and you risk losing some income.

    Personally, having assisted in game development (in a private arena) a mistake such as that isn't 'simple', its careless, and "pretty much" inexcusable as you not only **** off customers, you create additional and (what should be) unnecessary work for an apparently already exhausted staff.

    Flame on! b:shutup
  • Harima Kenji - Sanctuary
    Harima Kenji - Sanctuary Posts: 41 Arc User
    edited February 2009
    Options
    thats why they need to try it out before implementing it! most server have a testing server where it is used to try the patch first before applying it to the real one.

    btw, try C or C++
  • OMGLAZERZ - Heavens Tear
    OMGLAZERZ - Heavens Tear Posts: 2,327 Arc User
    edited February 2009
    Options
    thats why they need to try it out before implementing it! most server have a testing server where it is used to try the patch first before applying it to the real one.

    btw, try C or C++

    C and C++ will both let you do anything, even if it's possibly wrong, and it will compile, and you won't necessarily know something is wrong until it wipes your computer out.
    [SIGPIC][/SIGPIC]
  • Isala - Sanctuary
    Isala - Sanctuary Posts: 1,607 Arc User
    edited February 2009
    Options
    C and C++ will both let you do anything, even if it's possibly wrong, and it will compile, and you won't necessarily know something is wrong until it wipes your computer out.

    Pretty much. 99% of my errors in C and C++ weren't noticed until I tested out several test variables, and even then... FINDING the actual error took ages. It's a very forgiving language, unfortunately... Same with COBOL. I hate COBOL. Miss one period, and suddenly, you've got errors out the wazoo.

    I am curious what language this is programmed in, myself. Is it a C derivitive, a Basic derivitive, or some other language? Is it an actual game engine, or is every single thing in here a hard coded thing? Plus... How do you sanitize your database? I know that there are some characters omitted from things like the faction slogans. Is that so people don't accidentally put in the symbols for the comments and fry your entire code? Just curious here. I've wondered for a while what's under the hood of this game.