Thread: Python AI

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    Python AI


    I need some help for python AI. I can't understand some codes for python AI. I need to understand this code. So please help me.

    code :

    def __str__(self):
    if self.nature is 'AI':
    return self.name+' ('+self.nature+')'+' as '+self.colour
    else:
    return self.name+' as '+self.colour



    In this code 'AI' is used. But I dont understand this AI. Actually this code is used for chess game. So I need to understand this code for my work. please help me.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    100
    Rep Power
    2
    Originally Posted by bilashcse
    I need some help for python AI. I can't understand some codes for python AI. I need to understand this code. So please help me.

    code :

    def __str__(self):
    if self.nature is 'AI':
    return self.name+' ('+self.nature+')'+' as '+self.colour
    else:
    return self.name+' as '+self.colour

    In this code 'AI' is used. But I dont understand this AI. Actually this code is used for chess game. So I need to understand this code for my work. please help me.
    That 'AI' is nothing but a normal string. If it's the word 'is' that is confusing you, then 'is' is almost as same as '==' Just the difference is the ‘==’ operator tests whether the two referenced objects have the same values. The ‘is’ operator tests if both names print to exact same object.

IMN logo majestic logo threadwatch logo seochat tools logo