I just can't figure out what's wrong with this...
#!/usr/bin/env python # #       Bugs.py #         from __future__ import division  # No Module! if __name__ != '__main__':      print "Bugs.py is not meant to be a module"     exit()  # App import pygame, sys, random, math pygame.init()  # Configuration Vars conf = {     "start_energy": 50,      "food_energy": 25,      "mate_minenergy": 50,      "mate_useenergy": 35,      "lifespan": 300000 }  class Bugs:     def __init__(self):         self.list  = []         self.timers= {}         # Names / colors for sexes         self.sex = ["Male", "Female"]         self.color = ["#CBCB25", "#A52A2A"]         # Bug info tracking         self.bugid = 0         self.buginfo = {"maxgen":0, "maxspeed":0}      def new(self, x=False, y=False, sex=2, speed=0, generation=0, genes=[]):         sex   = sex   if not sex   == 2 else random.randint(0,1)         speed = speed if not speed == 0 else random.randint(1,3)         # Create new bug object         self.bugs.append(BugObj(sex, speed, generation, bugid, pygame.time.get_ticks, genes))         # Make sure it has a timer         if not self.timers[speed]:             self.timers[speed] = 1             pygame.time.set_timer(25 + speed, 1000 / speed)         # Update info tracking variables         if speed      > self.buginfo["maxspeed"]: self.buginfo["maxspeed"] = speed         if generation > self.buginfo["maxgen"]  : self.buginfo["maxgen"]   = generation         self.bugid += 1      def speed_count(self, speed):         a = 0         for i in list[:]:             if i.speed = speed:                 a += 1         return a  class BugObj:     def __init__(self, sex, speed, generation, bugid, born, genes):         global conf         self.sex        = sex         self.speed      = speed         self.generation = generation         self.id         = bugid         self.born       = born         self.genes      = genes         self.died       = -1         self.energy     = conf["start_energy"]         self.target     = "None"      def update(self):         global conf         if self.age() > conf["lifespan"]:             self.die()         else:             f = closest_food()             m = closest_mate()             # If there's a potential mate             if m != 0 and self.energy > conf["mate_minenergy"]:                 if not self.rect.colliderect(m.rect):                     self.move_toward(m)                     self.target = "Mate: " + str(m.rect.center)                 else:                     Bugs.mate(self, m)                     self.target = "Mate: (Reached)"             elif f != 0:                 if not self.rect.colliderect(f.rect):                     self.move_toward(f)                     self.target = "Food: " + str(f.rect.center)                 else:                     self.eat(f)                     self.target = "Food: (Reached)"             else:                 self.target = "Resting"             # Use energy             self.energy -= 0      def closest_food(self):         pass      def closest_mate(self):         pass      def age(self):         if self.died != -1:             return pygame.time.get_ticks - self.born         else:             return self.died - self.born      def die(self):         # Remove self from the list         Bugs.list.remove(self)         # Turn off timer         if not Bugs.speed_count(self.speed):             Bugs.timers[self.speed] = 0             pygame.time.timers(25 + self.speed, 0)         # Bye!         del self  class Food:     def __init__(self)         pass      def update(self)         pass  # Update Loop while 1:     ev = pygame.event.wait()     speed = ev.type - 25     if speed > 24:         for i in Bugs.list[:]:             if i.speed = speed                 i.update()                 print "Updating bug #" + str(i.id)     if speed == 0:         Food.update()   I get the following every time:
  File "Bugs.py" line 53     def new(self, x=False, y=False, sex=2, speed=0, generation=0, genes=[]):                                                                            ^ Indentation Error: unindent does not match any outer indentation level 
                The Python "IndentationError: unindent does not match any outer indentation level" occurs when we mix tabs and spaces in the same code block. To solve the error, remove the spacing and only use tabs or spaces, but don't mix the two in the same code block.
The “indentationerror: unindent does not match any outer indentation level” error is raised when you use both spaces and tabs to indent your code. To solve this error, check to make sure that all your code uses either spaces or tabs in a program.
The error “indentationerror: unindent does not match any outer indentation level” occurs when you mix spaces and tabs to indent your code. To solve this error, ensure all your code uses either spaces or tabs in your program. You can use a text editor to highlight your code to make it easier to spot the differences.
It's possible that you have mixed tabs and spaces in your file. You can have python help check for such errors with
python -m tabnanny <name of python file> 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With