This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import pdb | |
| import sys | |
| import pygame | |
| from pygame.locals import QUIT, MOUSEBUTTONDOWN | |
| class Game: | |
| BLACK = (0,0,0) | |
| WHITE = (255,255,255) | |
| GREY = (140,140,140) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getTalk(volume='shout'): | |
| def whisper(word='hello'): | |
| return word.lower()+'...' | |
| def shout(word='hello'): | |
| return word.capitalize()+"!" | |
| if volume == 'shout' : # reference function without calling it | |
| return shout | |
| else: | |
| return whisper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> a = [1,2] | |
| >>> b = [1,2] | |
| >>> c = a | |
| >>> a is b | |
| False | |
| >>> a is c | |
| True | |
| >>> a == b | |
| True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> li = ["Larry", "Curly"] | |
| >>> li.pop (1) | |
| <built−in method pop of list object at 010DF884> | |
| >>> getattr(li, "pop") (2) | |
| <built−in method pop of list object at 010DF884> | |
| >>> getattr(li, "append")("Moe") (3) | |
| >>> li | |
| ["Larry", "Curly", "Moe"] | |
| 1. This gets a reference to the pop method of the list. Note that this is not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def min_val(self, player, depth, max_depth): | |
| #print "min_val depth of", depth | |
| if self.game_won()[0]: | |
| return self.utility() | |
| if depth >= max_depth: #do I need =>? | |
| return 0 | |
| else: | |
| depth = depth + 1 | |
| min_init = 10 | |
| player = self.next_turn(player) |
NewerOlder