code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/env python import time t = time.time() u = time.gmtime(t) s = time.strftime('%a, %e %b %Y %T GMT', u) print 'Content-Type: text/javascript' print 'Cache-Control: no-cache' print 'Date: ' + s print 'Expires: ' + s print '' print 'var timeskew = new Date().getTime() - ' + str(t*1000) + ';'
Python
# Adapted for numpy/ma/cdms2 by convertcdms.py import _vcs import vcs,cdtime,queries import numpy class PPE(Exception): def __init__ (self, parameter,type): self.parameter=parameter self.type=type def __str__(self): return 'Projection Parameter Error: Parameter "'+self.parameter...
Python
import vcs, cdms2, cdutil import time,os, sys # Open data file: filepath = os.path.join(sys.prefix, 'sample_data/clt.nc') cdmsfile = cdms2.open( filepath ) # Extract a 3 dimensional data set and get a subset of the time dimension #data = cdmsfile('clt', longitude=(-180, 180), latitude = (-180., 180.)) data = cdmsfil...
Python
import vcs, cdms2, cdutil import time,os, sys # Open data file: filepath = os.path.join(sys.prefix, 'sample_data/clt.nc') cdmsfile = cdms2.open( filepath ) # Extract a 3 dimensional data set and get a subset of the time dimension #data = cdmsfile('clt', longitude=(-180, 180), latitude = (-180., 180.)) data = cdmsfil...
Python
import vcs, cdms2, cdutil import time,os, sys # Open data file: filepath = os.path.join(sys.prefix, 'sample_data/clt.nc') cdmsfile = cdms2.open( filepath ) # Extract a 3 dimensional data set and get a subset of the time dimension #data = cdmsfile('clt', longitude=(-180, 180), latitude = (-180., 180.)) data = cdmsfil...
Python
import vcs, cdms2, cdutil import time,os, sys # Open data file: filepath = os.path.join(sys.prefix, 'sample_data/clt.nc') cdmsfile = cdms2.open( filepath ) # Extract a 3 dimensional data set and get a subset of the time dimension #data = cdmsfile('clt', longitude=(-180, 180), latitude = (-180., 180.)) data = cdmsfil...
Python
""" FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http://www.gnu.org/license...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2009 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or l...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2009 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or l...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
''' Module which brings history information about files from Mercurial. @author: Rodrigo Damazio ''' import re import subprocess REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*') def _GetOutputLines(args): ''' Runs an external process and returns its output as a list of lines. @param args: the argume...
Python
''' Module which compares languague files to the master file and detects issues. @author: Rodrigo Damazio ''' import os from mytracks.parser import StringsParser import mytracks.history class Validator(object): def __init__(self, languages): ''' Builds a strings file validator. Params: @para...
Python
#!/usr/bin/python ''' Entry point for My Tracks i18n tool. @author: Rodrigo Damazio ''' import mytracks.files import mytracks.translate import mytracks.validate import sys def Usage(): print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0] print 'Commands are:' print ' cleanup' print ' translate' p...
Python
''' Module for dealing with resource files (but not their contents). @author: Rodrigo Damazio ''' import os.path from glob import glob import re MYTRACKS_RES_DIR = 'MyTracks/res' ANDROID_MASTER_VALUES = 'values' ANDROID_VALUES_MASK = 'values-*' def GetMyTracksDir(): ''' Returns the directory in which the MyTrac...
Python
''' Module which parses a string XML file. @author: Rodrigo Damazio ''' from xml.parsers.expat import ParserCreate import re #import xml.etree.ElementTree as ET class StringsParser(object): ''' Parser for string XML files. This object is not thread-safe and should be used for parsing a single file at a time...
Python
''' Module which prompts the user for translations and saves them. TODO: implement @author: Rodrigo Damazio ''' class Translator(object): ''' classdocs ''' def __init__(self, language): ''' Constructor ''' self._language = language def Translate(self, string_names): print string_names
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
#==================================================================== # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you ...
Python
#!/usr/bin/python #for test webpy in visualhost import sys sys.path.insert(0, "/usr/local/bin/python") sys.path.insert(0, "/www/fancyhan.host/ifancc_com/htdocs/115") sys.path.insert(0, "/www/fancyhan.host/ifancc_com/modules") import web from web.contrib.template import render_mako from netcrack import netdisk ...
Python
# -*- encoding:utf-8 -*- from mako import runtime, filters, cache UNDEFINED = runtime.UNDEFINED __M_dict_builtin = dict __M_locals_builtin = locals _magic_number = 6 _modified_time = 1309516407.3164999 _template_filename='templates/main.html' _template_uri='main.html' _template_cache=cache.Cache(__name__, _mod...
Python
#encoding:utf-8 import urllib import json class netdisk(): '''a class which can fetch 115 netdisk`s file though the given url or pickcode the request url examplehttp://uapi.115.com/?ct=upload_api&ac= get_pick_code_info&pickcode=aqbc8e20&version=1175"''' api = "http://uapi.115.c...
Python
#!/usr/bin/env python """ tesshelper.py -- Utility operations to compare, report stats, and copy public headers for tesseract 3.0x VS2008 Project $RCSfile: tesshelper.py,v $ $Revision: 7ca575b377aa $ $Date: 2012/03/07 17:26:31 $ """ r""" Requires: python 2.7 or greater: activestate.co...
Python
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2012 Zdenko Podobný # Author: Zdenko Podobný # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LIC...
Python
#!/usr/bin/python import sys import os import matplotlib import numpy import matplotlib matplotlib.use('AGG') import matplotlib.pyplot as plt from matplotlib.ticker import MaxNLocator from matplotlib.ticker import FormatStrFormatter def getArg(param, default=""): if (sys.argv.count(param) == 0): return default ...
Python
from optparse import OptionParser import random import heapq from operator import itemgetter from collections import defaultdict class Split: def __init__(self): self.train = {} self.test = {} self.counts = {} def add(self,user,trustees): if len(trustees) >= opts.min_trustees:...
Python
# -*- coding:utf-8 -*- import datetime import time import math import coord import tornado.ioloop def handle_bus_message(msg): bus_data = parse_message(msg) handle_bus_data(bus_data) buses = {} buses_state = {} def handle_bus_data(bus_data): name = bus_data["Name"] if bus_data.name not in buse...
Python
# -*- coding:utf-8 -*- import socket import functools import tornado.ioloop import busmanager import config _socket = None _ioloop = tornado.ioloop.IOLoop.instance() def start(): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setb...
Python
import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") application = tornado.web.Application([ (r"/", MainHandler), ]) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start()
Python
# -*- coding:utf-8 -*- Coords = [ (23.152793, 113.342832, 0.33, 0), (23.152792, 113.342624, -0.33, 1), (23.152790, 113.342417, 0.00, 1), (23.153019, 113.342402, 0.17, 1), (23.153249, 113.342386, 0.33, 1), (23.153478, 113.342371, 0.50, 1), (23.153707, 113.342356, -0.33, 2), (23.153937, 113.342340, -0.17, 2), (...
Python
# -*- coding:utf-8 -*- UDP_PORT = 6000 # 校巴终端上传数据端口 HTTP_PORT = 8001 # HTTP接口端口
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 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
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
import utils class Observer(object): def update(self, change): utils.abstract()
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 * 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 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
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
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 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
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 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 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 ttk import Combobox, Label from tkFont import families from tkSimpleDialog import Dialog class PreferencesDialog(Dialog): def __init__(self, parent, title, font, size): self._master = parent self.result = False self.font = font self.size = size ...
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
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
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
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
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
"""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 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 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
class Move(object): def __init__(self, squares, annotation=''): self.affected_squares = squares self.annotation = annotation def __repr__(self): return str(self.affected_squares)
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
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
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 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 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
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
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, 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
class Controller(object): def stop_process(self): pass
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 * 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
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
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2010 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2010 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2010 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2010 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2010 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2010 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python