code: #!/usr/bin/python
  # version 4
  # april 2012 
  # this was written by saikia81 and is copyrighted under the GNU general public license 3
  # it was written in notepad++, a program I recommend!
  # whitespace ftw!
  
  
  #import random, system and operating system possibilities.
  import os, sys
  import random, time #time moduele
  #pickling for data2file
  import cPickle as pickle
  
  
  #introducing the player
  def instructions():
      print 'welcome to the guess my number game V4'
      print "I'll think of a number and you have to guess it\n"
  
  #making a list of all possible numbers for every dificulty
  def list_numbers():
      list_easy = []
      list_medium = []
      list_hard = []
      for n in range(1,101):
          list_easy.append(n)
          list_medium.append(n)
          list_hard.append(n)
      for n in range(101,201):
          list_medium.append(n)
          list_hard.append(n)
      for n in range(-201,0):
          n += 1
          list_hard.append(n)
      return list_easy, list_medium, list_hard
  
  
  #does the player want to change the dificulty
  def change_dificulty(dificulty):
      if dificulty == None:
          dificulty = choose_dificulty()
          return dificulty
      if raw_input("do you want to change dificulty? yes/no: ") == 'yes':
          dificulty = choose_dificulty()
          return dificulty
      else:
          return dificulty
      
  
  #the dificulty the player wants to choose
  def choose_dificulty():
      print '\nwhat dificulty do you want to play in?'
      dificulty = raw_input('choose between "easy", "medium" or "hard":\n') 
      dificulties = 'easy', 'medium', 'hard'
      #if anybody tries to be smart: help them get it right
      wrong = -1
      if dificulty in dificulties: wrong = 0
      elif dificulty not in dificulties:
          wrong += 1 
          for n in (1,2,3):
              if n == 3:
                  print "\nseems like you can't handle choosing a dificulty..."
                  dificulty = "easy"
                  time.sleep(2)
                  print ""
              elif (dificulty not in dificulties):
                  print 'something went wrong!!! please try again\n'
                  dificulty = raw_input('choose between "easy", "medium" or "hard":\n')
                  wrong += 1
              elif dificulty in dificulties:
                  print "\nalright so let's get started :D\n"
                  break
              else:
                  print "you're doing something wrong! I'll chooce a dificulty for you\a\a\a\a\n"
                  dificulty = 'easy'
                  print "ERROR: 008"
                  time.sleep(2)
      else:
          print '\a\a\asomething went wrong the program will shutdown.'
          print "ERROR: 009"
          time.sleep(2.5)
          sys.exit()
      return dificulty
  
  #so here a random number will be choosen depending of the dificulty
  def random_number(dificulty, list_easy, list_medium, list_hard):
      if dificulty == 'easy':
          NUMBER = random.randrange(100) + 1
          print "you have choosen the dificulty easy."
          number_range = '1 and 100: '
          numbers = list_easy
      elif dificulty == 'medium':
          NUMBER = random.randrange(200) + 1
          print "you have choosen the dificulty medium."
          number_range = '1 and 200: '
          numbers = list_medium
      elif dificulty =='hard':
          NUMBER = random.randrange(-200,201)
          print "you have choosen the dificulty hard."
          number_range = '-200 and 200: '
          numbers = list_hard
      else:
          print "dificulty malfunction"
          print "ERROR: 003"
          time.sleep(2.5)
          exit()
      return NUMBER, number_range, numbers
  
  # if the guess != "the (predefined) number": loop.
  def game(dificulty, NUMBER, number_range, numbers):
      time.sleep(2.5)
      os.system('cls')
      guesses=0
      guess='nothing'
      while guess != NUMBER:
          if guess == 'nothing':
              print 'guess a number between', number_range
              try:
                  guess = input()
              except:
                  print "\nsomething went wrong\nyou're getting another try\n\n"
                  continue
              guesses += 1
          elif guess == 'cheater':
              guess = NUMBER
          elif guess not in numbers:
              print "\nthe guess you made isn't in the range of valid numbers.\nAre you sure you want to make this guess?"
              answ = raw_input("'yes'/'no' \n")
              if answ == 'yes':
                  print "it's your funeral"
                  print '\nnguess a number between', number_range
                  guesses += 1
              elif answ == 'no':
                  print "good choice"
                  print '\nguess a number between', number_range
                  try:
                      guess = input()
                  except:
                      print "something went wrong\nyou're getting another try\n"
                      continue
              else:
                  print "that isn't a valid option"
                  print "let's continue\n"
          #if the number is higher than the guess
          elif guess < NUMBER:
              print 'higher...'
              print '\nguess a number between', number_range
              try:
                  guess = input()
              except:
                  print "something went wrong\nyou're getting another try\n"
                  continue
              guesses += 1
              continue
          #if the number is 'lower...'
          elif guess > NUMBER:
              print 'lower...' 
              print '\nguess a number between', number_range
              try:
                  guess = input()
              except:
                  print "something went wrong\n you'll get another try"
                  continue
                  guesses -= 1
              guesses += 1
          #this is actually an error that will never occur... but better safe than sorry.
          else:
              print '\a\a\asorry, something went wrong. The game will now end itself.'
              sys.exit()
      print
      print 'you did it the NUMBER was: ', NUMBER,
      print 'it cost you ', guesses, 'guesses to get it right', 'on dificulty', dificulty
      print
      return guesses
  
  ##Here I will use the 'os' module to keep a highscore system
  #in the default appdata of the users profile.
  #everything here is to see if everything is alright in it's place.
  def highscore(dificulty,guesses):
      FOLDER_LOCALAPPDATA = os.environ['LOCALAPPDATA']
      FOLDER_NUMBER_GAME = FOLDER_LOCALAPPDATA + '\\Number_game'
      #deciding if a new highscore file and/or dir is needed
      if os.access(FOLDER_NUMBER_GAME, 0) == False: #dir
          try:
              os.mkdir(FOLDER_NUMBER_GAME)
          except:
              os.system('cls')
              print 'creating folder: ERROR\nError code: 002'
              os.system('pause')
              sys.exit()
          try:
             HIGHSCORES_DAT = open(FOLDER_NUMBER_GAME+"\\highscores.dat", "w+")
             easy_highscores={}
             medium_highscores={}
             hard_highscores={}
             all_highscores = [easy_highscores,medium_highscores,hard_highscores]
             pickle.dump(all_highscores,HIGHSCORES_DAT)
             HIGHSCORES_DAT.close()
             HIGHSCORES_DAT = open(FOLDER_NUMBER_GAME+"\\highscores.dat", "r+")
             unpickled_file = pickle.load(HIGHSCORES_DAT)
          
          except:
              os.system('cls')
              print 'loading file: ERROR\nError code: 001'
              os.system('pause')
              sys.exit()
          else:
              HIGHSCORES_DAT.close()
      
      
      #done with file and folder creation
      #
      #showing highscores
      
      HIGHSCORES_DAT = open(FOLDER_NUMBER_GAME+"\\highscores.dat", "r")   
      try:
          unpickled_file = pickle.load(HIGHSCORES_DAT)
      except:
          print "couldn't locate or unpickle file"
          print "ERROR: 005"
          print "\n if this was your first run of the game: this is common"
          print "if not, please send a message at dummy@email.com, thank you"
          time.sleep(1)
          print "everything went worse then expected. shutting down"
          time.sleep(2.5)
          sys.exit()
          
      else:
          HIGHSCORES_DAT.close()
  
      if dificulty == "easy": l=0
      if dificulty == "medium": l=1
      if dificulty == "hard": l=2
      highscores = unpickled_file[l]
      
      #creating your highscore...
      your_name = raw_input('what is your name?: ')
      try:
          if highscores[your_name]>guesses:
              os.system('cls')
              print "congratulations, new highscore!!"
              if raw_input('do you want to replace your score yes/no: ') =="yes": highscores[your_name]=guesses
      except:
          print "new user"
          highscores[your_name]=guesses
      
      list_keys= highscores.keys()
      list_values= highscores.values()
  
      list_values.sort()
      
      time.sleep(4)
      os.system('cls') 
      #deeply annoying part
      #highscore display
      print"       ---HIGHSCORE---"
      print "highscores in", dificulty,"dificulty"
      print"\nname                 attempts"
      print"----------------------------------------"
      i=0
      #for values in sorted values list
      for n in list_values:
          #reset found to find next highscore
          found = False
          #set p to 0: to try different keys
          p=0
          #while the matching key and value not found keep looking
          while found != True:
              #m = the next key in list
              m=list_keys[p]
              if highscores[m] == n: found=True
              p+=1
          b=len(m)
          b=21-b
          print m,' '*b,highscores[m]
      
      HIGHSCORES_DAT = open(FOLDER_NUMBER_GAME+"\\highscores.dat", "r")
      unpickled_file = pickle.load(HIGHSCORES_DAT)
      HIGHSCORES_DAT.close()
      if l==0: unpickled_file[0]=highscores
      if l==1: unpickled_file[1]=highscores
      if l==2: unpickled_file[2]=highscores
      HIGHSCORES_DAT = open(FOLDER_NUMBER_GAME+"\\highscores.dat", "w")
      pickle.dump(unpickled_file,HIGHSCORES_DAT)
      HIGHSCORES_DAT.close()
  
  def end():
      time.sleep(1)
      print('''
      The number Game V4
      Copyright (C) 2012  Saikia81
      ''')
      time.sleep(5)
      os.system('cls')
      print("""
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
      """)
      time.sleep(7)
      try:
          if pygame.mixer.get_busy()>0:
              try:
                  pygame.mixer.music.fadeout(3000)
              except:
                  print "ERROR: 012"
      except:
          pass
      time.sleep(3)
      os.system('pause')
      sys.exit()
  
  def main():
      #initializing
      ask_music = raw_input('music "on"?: ')
      if (ask_music == 'on') or (ask_music == 'yes'):
          try:
              import pygame.mixer
              pygame.mixer.init()
              pygame.mixer.music.load("song.mp3")
              pygame.mixer.music.play(-1)
          except:
              print "pygame not working!\nError: 013"
      os.system('cls')
      list_easy, list_medium, list_hard = list_numbers()
      dificulty = None
      instructions()
      while 1:
          dificulty=change_dificulty(dificulty)
          NUMBER, number_range, numbers = random_number(dificulty, list_easy, list_medium, list_hard)
          guesses = game(dificulty, NUMBER, number_range, numbers)
          highscore(dificulty,guesses)
  
          ask_again = raw_input('\ndo you want to play again? yes/no: ')
          os.system('cls')
          if ask_again == 'no': end()
  
  #start
  main()
  
entities: [['EMAIL_ADDRESS', 'dummy@email.com'], ['DATE_TIME', 'april 2012'], ['LOCATION', 'list_easy'], ['LOCATION', 'game(dificulty'], ['PERSON', 'list_values= highscores.values'], ['PERSON', 'list_values.sort'], ['DATE_TIME', '2012'], ['LOCATION', 'list_easy'], ['URL', 'http://www.gnu.org/licenses/'], ['URL', 'time.sl'], ['URL', 'time.sl'], ['URL', 'time.sl'], ['URL', 'time.sl'], ['URL', 'time.sl'], ['URL', 'os.sy'], ['URL', 'os.ac'], ['URL', 'os.mk'], ['URL', 'os.sy'], ['URL', 'os.sy'], ['URL', 'DAT.cl'], ['URL', 'os.sy'], ['URL', 'os.sy'], ['URL', 'DAT.cl'], ['URL', 'email.com'], ['URL', 'time.sl'], ['URL', 'time.sl'], ['URL', 'DAT.cl'], ['URL', 'os.sy'], ['URL', 'highscores.ke'], ['URL', 'highscores.va'], ['URL', 'values.so'], ['URL', 'time.sl'], ['URL', 'os.sy'], ['URL', 'DAT.cl'], ['URL', 'DAT.cl'], ['URL', 'time.sl'], ['URL', 'time.sl'], ['URL', 'os.sy'], ['URL', 'time.sl'], ['URL', 'pygame.mixer.ge'], ['URL', 'pygame.mixer.mu'], ['URL', 'time.sl'], ['URL', 'os.sy'], ['URL', 'pygame.mixer.in'], ['URL', 'pygame.mixer.mu'], ['URL', 'song.mp'], ['URL', 'pygame.mixer.music.pl'], ['URL', 'os.sy'], ['URL', 'os.sy']]