code
stringlengths
1
1.72M
language
stringclasses
1 value
import code from code import softspace import os import sys import wx import new def sanitise_text(text): """When we process text before saving or executing, we sanitise it by changing all CR/LF pairs into LF, and then nuking all remaining CRs. This consistency also ensures that the files we save have the ...
Python
import wx from wx import py class DVShell(py.shell.Shell): """DeVIDE shell. Once again, PyCrust makes some pretty bad calls here and there. With this override we fix some of them. 1. passing locals=None will result in shell.Shell setting locals to __main__.__dict__ (!!) in contrast to the defaul...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. import wx from wx import py from wx import stc class DVEditWindow(py.editwindow.EditWindow): """DeVIDE EditWindow. This fixes all of the py screwups by providing a re-usable Python EditWindow component. The Py ...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. # importing this module shouldn't directly cause other large imports # do large imports in the init() hook so that you can call back to the # ModuleManager progress handler methods. """wxpython_kit package driver file. Inser...
Python
# Copyright (c) 1999-2002 Gary Strangman; All Rights Reserved. # # This software is distributable under the terms of the GNU # General Public License (GPL) v2, the text of which can be found at # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise # using this module constitutes acceptance of the t...
Python
# Copyright (c) Gary Strangman. All rights reserved # # Disclaimer # # This software is provided "as-is". There are no expressed or implied # warranties of any kind, including, but not limited to, the warranties # of merchantability and fittness for a given application. In no event # shall Gary Strangman be liable ...
Python
# $Id: __init__.py 1945 2006-03-05 01:06:37Z cpbotha $ # importing this module shouldn't directly cause other large imports # do large imports in the init() hook so that you can call back to the # ModuleManager progress handler methods. """stats_kit package driver file. Inserts the following modules in sys.modules: ...
Python
# Copyright (c) 1999-2000 Gary Strangman; All Rights Reserved. # # This software is distributable under the terms of the GNU # General Public License (GPL) v2, the text of which can be found at # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise # using this module constitutes acceptance of the t...
Python
# $Id: __init__.py 1945 2006-03-05 01:06:37Z cpbotha $ # importing this module shouldn't directly cause other large imports # do large imports in the init() hook so that you can call back to the # ModuleManager progress handler methods. """matplotlib_kit package driver file. Inserts the following modules in sys.modu...
Python
# perceptually linear colour scales based on those published by Haim # Levkowitz at http://www.cs.uml.edu/~haim/ColorCenter/ # code by Peter R. Krekel (c) 2009 # modified by Charl Botha to cache lookuptable per range import vtk class ColorScales(): def __init__(self): self.BlueToYellow = {} self....
Python
# Copyright (c) Charl P. Botha, TU Delft. # All rights reserved. # See COPYRIGHT for details. """Utility methods for vtk_kit module kit. @author Charl P. Botha <http://cpbotha.net/> """ import vtk class DVOrientationWidget: """Convenience class for embedding orientation widget in any renderwindowinteractor....
Python
# $Id$ """Mixins that are useful for classes using vtk_kit. @author: Charl P. Botha <http://cpbotha.net/> """ from external.vtkPipeline.ConfigVtkObj import ConfigVtkObj from external.vtkPipeline.vtkMethodParser import VtkMethodParser from module_base import ModuleBase from module_mixins import IntrospectModuleMixin ...
Python
medical_image_properties_keywords = [ 'PatientName', 'PatientID', 'PatientAge', 'PatientSex', 'PatientBirthDate', 'ImageDate', 'ImageTime', 'ImageNumber', 'StudyDescription', 'StudyID', 'StudyDate', 'AcquisitionDate', ...
Python
# $Id$ # importing this module shouldn't directly cause other large imports # do large imports in the init() hook so that you can call back to the # ModuleManager progress handler methods. """vtk_kit package driver file. This performs all initialisation necessary to use VTK from DeVIDE. Makes sure that all VTK clas...
Python
# $Id$ """Miscellaneous functions that are part of the vtk_kit. This module is imported by vtk_kit.init() after the rest of the vtk_kit has been initialised. To use these functions in your module code, do e.g.: import moduleKits; moduleKits.vtk_kit.misc.flatterProp3D(obj); @author: Charl P. Botha <http://cpbotha.ne...
Python
# $Id: __init__.py 1945 2006-03-05 01:06:37Z cpbotha $ # importing this module shouldn't directly cause other large imports # do large imports in the init() hook so that you can call back to the # ModuleManager progress handler methods. """vtktudoss_kit package driver file. Inserts the following modules in sys.modul...
Python
# $Id: __init__.py 1945 2006-03-05 01:06:37Z cpbotha $ # importing this module shouldn't directly cause other large imports # do large imports in the init() hook so that you can call back to the # ModuleManager progress handler methods. """numpy_kit package driver file. Inserts the following modules in sys.modules: ...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. """sqlite_kit package driver file. With this we make sure that sqlite3 is always packaged. """ VERSION = '' def init(module_manager, pre_import=True): global sqlite3 import sqlite3 global VERSION VERSION = ...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. import re # map from itk type string to string ITKTSTR_STRING = { 'C' : 'char', 'D' : 'double', 'F' : 'float', 'L' : 'long', 'S' : 'short' } # map from itk type sign to string ...
Python
# Copyright (c) Charl P. Botha, TU Delft. # All rights reserved. # See COPYRIGHT for details. class SubjectMixin(object): def __init__(self): # dictionary mapping from event name to list of observer # callables self._observers = {} def add_observer(self, event_name, observer): ...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. class MedicalMetaData: def __init__(self): self.medical_image_properties = None self.direction_cosines = None def close(self): del self.medical_image_properties del self.direction_cosin...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. import sys VERSION = 'INTEGRATED' # debug print command: if DEBUG is true, outputs to stdout, if not # then outputs nothing. # import with: from module_kits.misc_kit import dprint DEBUG=False if DEBUG: def dprint(*msg): ...
Python
# $Id: __init__.py 1945 2006-03-05 01:06:37Z cpbotha $ # importing this module shouldn't directly cause other large imports # do large imports in the init() hook so that you can call back to the # ModuleManager progress handler methods. """itktudoss_kit package driver file. This driver makes sure that itktudoss has ...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. import ConfigParser import glob import os import sys import time """Top-level __init__ of the module_kits. All .mkd files in the module_kits directory are parsed and their corresponding module_kits are loaded. MKD specify ...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. import gdcm def sort_ipp(filenames): """STOP PRESS. This is currently incomplete. I'm waiting to see what's going to happen with the IPPSorter in GDCM. Given a list of filenames, make use of the gdcm scanne...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. """gdcm_kit driver module. This pre-loads GDCM2, the second generation Grass Roots Dicom library, used since 2008 by DeVIDE for improved DICOM loading / saving support. """ import os import sys VERSION = '' def init(modul...
Python
# Copyright (c) Charl P. Botha, TU Delft. # All rights reserved. # See COPYRIGHT for details. import itk import re from module_kits.misc_kit.misc_utils import get_itk_img_type_and_dim from module_kits.misc_kit.misc_utils import \ get_itk_img_type_and_dim_shortstring get_img_type_and_dim = get_itk_img_type_an...
Python
# Copyright (c) Charl P. Botha, TU Delft. # All rights reserved. # See COPYRIGHT for details. """itk_kit package driver file. Inserts the following modules in sys.modules: itk, InsightToolkit. @author: Charl P. Botha <http://cpbotha.net/> """ import os import re import sys VERSION = '' def setDLFlags(): # bro...
Python
# dummy
Python
# Copyright (c) Charl P. Botha, TU Delft. # All rights reserved. # See COPYRIGHT for details. import ConfigParser import sys, os, fnmatch import re import copy import gen_utils import glob from meta_module import MetaModule import modules import mutex from random import choice from module_base import DefaultConfigClas...
Python
class canvasSubject: def __init__(self): self._observers = {} def addObserver(self, eventName, observer): """Add an observer for a particular event. eventName can be one of 'enter', 'exit', 'drag', 'buttonDown' or 'buttonUp'. observer is a callable object that will be ...
Python
from canvasObject import * from canvas import *
Python
from wxPython import wx from canvasSubject import canvasSubject ############################################################################# class canvasObject(canvasSubject): def __init__(self, position): # call parent ctor canvasSubject.__init__(self) self._position = posit...
Python
import wx from canvasSubject import canvasSubject from canvasObject import * class canvas(wx.wxScrolledWindow, canvasSubject): def __init__(self, parent, id = -1, size = wx.wxDefaultSize): # parent 1 ctor wx.wxScrolledWindow.__init__(self, parent, id, wx.wxPoint(0, 0), size, ...
Python
# dummy
Python
# dummy
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. from module_kits.misc_kit.mixins import SubjectMixin import vtk # z-coord of RBB box # when this is 1.0, the box does not appear until a canvas reset has # been done... RBBOX_HEIGHT = 0.9 class UnfilledBlock: """Create ...
Python
# Copyright (c) Charl P. Botha, TU Delft # All rights reserved. # See COPYRIGHT for details. import vtk from module_kits.misc_kit.mixins import SubjectMixin from devide_canvas_object import DeVIDECanvasGlyph import operator import wx # we're going to use this for event handling from module_kits.misc_kit import dprin...
Python
# dummy
Python
# Copyright (c) Charl P. Botha, TU Delft. # All rights reserved. # See COPYRIGHT for details. # I could have done this with just a module variable, but I found this # Borg thingy too nice not to use. See: # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 class CounterBorg: """Borg-pattern (similar ...
Python
"""Module to test basic DeVIDE functionality. """ import unittest class BasicVTKTest(unittest.TestCase): def test_vtk_exceptions(self): """Test if VTK has been patched with our VTK error to Python exception patch. """ import vtk a = vtk.vtkXMLImageDataReader() a.Se...
Python
from module_kits.vtk_kit.mixins import SimpleVTKClassModuleBase import vtk class emp_test(SimpleVTKClassModuleBase): """This is the minimum you need to wrap a single VTK object. This __doc__ string will be replaced by the __doc__ string of the encapsulated VTK object, i.e. vtkStripper in this case. ...
Python
# $Id: module_index.py 2790 2008-02-29 08:33:14Z cpbotha $ class emp_test: kits = ['vtk_kit'] cats = ['Tests'] keywords = ['test', 'tests', 'testing'] help = \ """Module to test DeVIDE extra-module-paths functionality. """
Python
"""Module to test basic DeVIDE functionality. """ import unittest class PythonShellTest(unittest.TestCase): def test_python_shell(self): """Test if PythonShell can be opened successfully. """ iface = self._devide_app.get_interface() iface._handler_menu_python_shell(None) se...
Python
"""Module to test basic matplotlib functionality. """ import os import unittest import tempfile class MPLTest(unittest.TestCase): def test_figure_output(self): """Test if matplotlib figure can be generated and wrote to disc. """ # make sure the pythonshell is running self._devide_...
Python
"""Module to test graph_editor functionality. """ import os import time import unittest import wx class GraphEditorTestBase(unittest.TestCase): def setUp(self): self._iface = self._devide_app.get_interface() self._ge = self._iface._graph_editor # the graph editor frame is now the main fram...
Python
# testing.__init__.py copyright 2006 by Charl P. Botha http://cpbotha.net/ # $Id$ # this drives the devide unit testing. neat huh? import os import time import unittest from testing import misc from testing import basic_vtk from testing import basic_wx from testing import graph_editor from testing import numpy_tests...
Python
import sys import unittest class NumPyTest(unittest.TestCase): def test_import_mixing(self): """Test for bug where packaged numpy and installed numpy would conflict, causing errors. """ import numpy try: na = numpy.array([0,0,0]) print na exc...
Python
"""Module to test basic DeVIDE functionality. """ import unittest class BasicMiscTest(unittest.TestCase): def test_sqlite3(self): """Test if sqlite3 is available. """ import sqlite3 v = sqlite3.version conn = sqlite3.connect(':memory:') cur = conn.cursor(...
Python
# Copyright (c) Charl P. Botha, TU Delft. # All rights reserved. # See COPYRIGHT for details. import wx # todo: this should go away... import string import sys import traceback # todo: remove all VTK dependencies from this file!! def clampVariable(v, min, max): """Make sure variable is on the range [min,max]. R...
Python
#! /usr/bin/env python '''Helper script for bundling up a game in a ZIP file. This script will bundle all game files into a ZIP file which is named as per the argument given on the command-line. The ZIP file will unpack into a directory of the same name. The script ignores: - CVS or SVN subdirectories - any dotfiles...
Python
#! /usr/bin/env python '''Helper script for bundling up a game in a ZIP file. This script will bundle all game files into a ZIP file which is named as per the argument given on the command-line. The ZIP file will unpack into a directory of the same name. The script ignores: - CVS or SVN subdirectories - any dotfiles...
Python
import pygame from pygame.locals import * pygame.init() import lib import os import json GROUPS = ('Solid','Background','Foreground') TILE_NAMES = {'Solid':('Center','Left-Side','Right-Side','Top', 'Bottom','Left-Top-Outside-Corner', 'Right-Top-Outside-Corner', ...
Python
import pygame def draw_game_screen(screen,world): screen_area = screen.get_rect() screen_area.center = world.player.rect.center screen_area.clamp_ip(world.area) screen.fill((0,140,210)) image,blit_rect = world.player.get_blit_info() blit_rect.left -= screen_area.left blit_rect.top -= scre...
Python
import pygame class WorldCell: def __init__(self,index,player,terrain,baddies,widgets): pass class GameWorld: def __init__(self,player,factory,cells): self.cells = cells self.factory = factory self.player = player self.current_cell = 0
Python
import pygame import entities from config import CONFIG from constants import UP,DOWN,LEFT,RIGHT class Player(entities.Agent): def __init__(self,pos,size,image_set,sound_set): entities.Agent.__init__(self,pos,size,2, CONFIG['Player Stats']['Speed'], imag...
Python
import pygame import player import baddies import items import world import terrain import menu import hud import music import data from constants import * from config import CONFIG import random class GeneralFactory: def __init__(self): self.images = {} self.sounds = {} self.images['Pla...
Python
import pygame import constants class TerrainTile: def __init__(self,pos,image): self.rect = pygame.Rect(pos,(1,1)) self.rect.left *= constants.TILE_SIZE[0] self.rect.top *= constants.TILE_SIZE[1] self.rect.width *= constants.TILE_SIZE[0] self.rect.height *= constants.TILE_SIZE[1] ...
Python
UP = 0 DOWN = 1 LEFT = 2 RIGHT = 3 TILE_SIZE = [40,40]
Python
import pygame import os import json DATA_DIR = os.path.relpath(os.path.join(__file__,'..','..','data')) def load_image(img_path): img_path = os.path.join(DATA_DIR,'media','images',img_path+'.png') return pygame.image.load(img_path) def load_player_images(name): base_dir = os.path.join('player',name.lower...
Python
import pygame from pygame.locals import * pygame.mixer.pre_init(22050,-16,2,2048) pygame.init() import factories import display from config import CONFIG class MainLoop: def __init__(self): self.screen = pygame.display.set_mode((800,500),HWSURFACE|DOUBLEBUF,32) pygame.display.set_caption('Foxen -...
Python
import pygame from pygame import Rect from constants import LEFT,RIGHT,UP,DOWN class Entity: def __init__(self,pos,size,image_set): self.rect = Rect((0,0),size) self.rect.centerx = pos[0] self.rect.bottom = pos[1] self.image_set = image_set self.velocity = [0,0] self.coll...
Python
import json import os config_path = os.path.relpath(os.path.join(__file__,'..','..','config.json')) config_file = open(config_path,'r') CONFIG = json.load(config_file) config_file.close() del config_file del config_path
Python
import lib def main(): lib.MainLoop().go() if __name__.lower() == '__main__': try: import psyco psyco.full() except ImportError: pass main()
Python
''' Upload script specifically engineered for the PyWeek challenge. Handles authentication and gives upload progress feedback. ''' import sys, os, httplib, cStringIO, socket, time, getopt class Upload: def __init__(self, filename): self.filename = filename boundary = '--------------GHSKFJDLGDS7543FJKLFHR...
Python
import games import time from move import Move from globalconst import BLACK, WHITE, KING, MAN, OCCUPIED, BLACK_CHAR, WHITE_CHAR from globalconst import BLACK_KING, WHITE_KING, FREE, OCCUPIED_CHAR, FREE_CHAR from globalconst import COLORS, TYPES, TURN, CRAMP, BRV, KEV, KCV, MEV, MCV from globalconst import INTACT...
Python
from goal import Goal class CompositeGoal(Goal): def __init__(self, owner): Goal.__init__(self, owner) self.subgoals = [] def removeAllSubgoals(self): for s in self.subgoals: s.terminate() self.subgoals = [] def processSubgoals(self): # rem...
Python
class Controller(object): def stop_process(self): pass
Python
"""Provide some widely useful utilities. Safe for "from utils import *".""" from __future__ import generators import operator, math, random, copy, sys, os.path, bisect #______________________________________________________________________________ # Simple Data Structures: booleans, infinity, Dict, Struct in...
Python
import os from Tkinter import * from Tkconstants import END, N, S, E, W from command import * from observer import * from globalconst import * from autoscrollbar import AutoScrollbar from textserialize import Serializer from hyperlinkmgr import HyperlinkManager from tkFileDialog import askopenfilename from tk...
Python
from UserDict import UserDict class TranspositionTable (UserDict): def __init__ (self, maxSize): UserDict.__init__(self) assert maxSize > 0 self.maxSize = maxSize self.krono = [] self.maxdepth = 0 self.killer1 = [-1]*20 self.killer2 = [-1]*20 self.ha...
Python
import re import sys class LinkRules(object): """Rules for recognizing external links.""" # For the link targets: proto = r'http|https|ftp|nntp|news|mailto|telnet|file|irc' extern = r'(?P<extern_addr>(?P<extern_proto>%s):.*)' % proto interwiki = r''' (?P<inter_wiki> [A-Z][a-zA-Z]+ ) :...
Python
from Tkinter import * from time import time, localtime, strftime class ToolTip( Toplevel ): """ Provides a ToolTip widget for Tkinter. To apply a ToolTip to any Tkinter widget, simply pass the widget to the ToolTip constructor """ def __init__( self, wdgt, msg=None, msgFunc=None, delay=1, foll...
Python
from Tkinter import * class HyperlinkManager(object): def __init__(self, textWidget, linkFunc): self.txt = textWidget self.linkfunc = linkFunc self.txt.tag_config('hyper', foreground='blue', underline=1) self.txt.tag_bind('hyper', '<Enter>', self._enter) self.txt.tag...
Python
import re import sys from rules import Rules from document import DocNode class Parser(object): """ Parse the raw text and create a document object that can be converted into output using Emitter. A separate instance should be created for parsing a new document. The first parameter is the raw tex...
Python
from Tkinter import * from tkSimpleDialog import Dialog from globalconst import * class AboutBox(Dialog): def body(self, master): self.canvas = Canvas(self, width=300, height=275) self.canvas.pack(side=TOP, fill=BOTH, expand=0) self.canvas.create_text(152,47,text='Raven', fill='blac...
Python
from globalconst import BLACK, WHITE, KING import checkers class Operator(object): pass class OneKingAttackOneKing(Operator): def precondition(self, board): plr_color = board.to_move opp_color = board.enemy return (board.count(plr_color) == 1 and board.count(opp_color) == 1 a...
Python
import copy, textwrap from globalconst import * from move import Move from checkers import Checkers class SavedGame(object): def __init__(self): self._model = Checkers() self.to_move = None self.moves = [] self.description = '' self.black_men = [] self.wh...
Python
from abc import ABCMeta, abstractmethod class GoalEvaluator(object): __metaclass__ = ABCMeta def __init__(self, bias): self.bias = bias @abstractmethod def calculateDesirability(self, board): pass @abstractmethod def setGoal(self, board): pass ...
Python
import sys import games from globalconst import * class Player(object): def __init__(self, color): self.col = color def _get_color(self): return self.col color = property(_get_color, doc="Player color") class AlphabetaPlayer(Player): def __init__(self, color, depth=4): ...
Python
from Tkinter import * class AutoScrollbar(Scrollbar): def __init__(self, master=None, cnf={}, **kw): self.container = kw.pop('container', None) self.row = kw.pop('row', 0) self.column = kw.pop('column', 0) self.sticky = kw.pop('sticky', '') Scrollbar.__init__(self, m...
Python
import utils class Observer(object): def update(self, change): utils.abstract()
Python
from Tkinter import * from Tkconstants import W, E, N, S from tkFileDialog import askopenfilename, asksaveasfilename from tkMessageBox import askyesnocancel, showerror from globalconst import * from checkers import Checkers from boardview import BoardView from playercontroller import PlayerController from alpha...
Python
import games import copy import multiprocessing import time import random from controller import Controller from transpositiontable import TranspositionTable from globalconst import * class AlphaBetaController(Controller): def __init__(self, **props): self._model = props['model'] self._...
Python
import math, os, sys from ConfigParser import RawConfigParser DEFAULT_SIZE = 400 BOARD_SIZE = 8 CHECKER_SIZE = 30 MAX_VALID_SQ = 32 MOVE = 0 JUMP = 1 OCCUPIED = 0 BLACK = 1 WHITE = 2 MAN = 4 KING = 8 FREE = 16 COLORS = BLACK | WHITE TYPES = OCCUPIED | BLACK | WHITE | MAN | KING | FREE HUMAN = 0 ...
Python
import sys from goal import Goal from composite import CompositeGoal class Goal_OneKingFlee(CompositeGoal): def __init__(self, owner): CompositeGoal.__init__(self, owner) def activate(self): self.status = self.ACTIVE self.removeAllSubgoals() # because goals are *push...
Python
import os from Tkinter import * from Tkconstants import W, E import Tkinter as tk from tkMessageBox import askyesnocancel from multiprocessing import freeze_support from globalconst import * from aboutbox import AboutBox from setupboard import SetupBoard from gamemanager import GameManager from centeredwindow...
Python
class Move(object): def __init__(self, squares, annotation=''): self.affected_squares = squares self.annotation = annotation def __repr__(self): return str(self.affected_squares)
Python
from composite import CompositeGoal from onek_onek import OneKingAttackOneKingEvaluator, OneKingFleeOneKingEvaluator class Goal_Think(CompositeGoal): def __init__(self, owner): CompositeGoal.__init__(self, owner) self.evaluators = [OneKingAttackOneKingEvaluator(1.0), ...
Python
from abc import ABCMeta, abstractmethod class Goal: __metaclass__ = ABCMeta INACTIVE = 0 ACTIVE = 1 COMPLETED = 2 FAILED = 3 def __init__(self, owner): self.owner = owner self.status = self.INACTIVE @abstractmethod def activate(self): pass ...
Python
from Tkinter import * from ttk import Checkbutton from tkSimpleDialog import Dialog from globalconst import * class SetupBoard(Dialog): def __init__(self, parent, title, gameManager): self._master = parent self._manager = gameManager self._load_entry_box_vars() self.result...
Python
from Tkinter import Widget from controller import Controller from globalconst import * class PlayerController(Controller): def __init__(self, **props): self._model = props['model'] self._view = props['view'] self._before_turn_event = None self._end_turn_event = props['end_t...
Python
from goal import Goal from composite import CompositeGoal class Goal_OneKingAttack(CompositeGoal): def __init__(self, owner): CompositeGoal.__init__(self, owner) def activate(self): self.status = self.ACTIVE self.removeAllSubgoals() # because goals are *pushed* onto t...
Python
from Tkinter import * class CenteredWindow: def __init__(self, root): self.root = root self.root.after_idle(self.center_on_screen) self.root.update() def center_on_screen(self): self.root.update_idletasks() sw = self.root.winfo_screenwidth() sh = self...
Python
class Command(object): def __init__(self, **props): self.add = props.get('add') or [] self.remove = props.get('remove') or []
Python
from globalconst import BLACK, WHITE, MAN, KING from goalevaluator import GoalEvaluator from onekingattack import Goal_OneKingAttack class OneKingAttackOneKingEvaluator(GoalEvaluator): def __init__(self, bias): GoalEvaluator.__init__(self, bias) def calculateDesirability(self, board): ...
Python
import unittest import checkers import games from globalconst import * # (white) # 45 46 47 48 # 39 40 41 42 # 34 35 36 37 # 28 29 30 31 # 23 24 25 26 # 17 18 19 20 # 12 13 14 15 # 6 7 8 9 # (bl...
Python
from Tkinter import PhotoImage from Tkconstants import * from globalconst import BULLET_IMAGE from creoleparser import Parser from rules import LinkRules class TextTagEmitter(object): """ Generate tagged output compatible with the Tkinter Text widget """ def __init__(self, root, txtWidget, hy...
Python
"""Games, or Adversarial Search. (Chapters 6) """ from utils import infinity, argmax, argmax_random_tie, num_or_str, Dict, update from utils import if_, Struct import random import time #______________________________________________________________________________ # Minimax Search def minimax_decision(state, game)...
Python
class DocNode(object): """ A node in the document. """ def __init__(self, kind='', parent=None, content=None): self.children = [] self.parent = parent self.kind = kind self.content = content if self.parent is not None: self.parent.children.append(self...
Python