Пример #1
0
def cmp_objects(a, b, max_rows):
    ((ai, aj, ar, ac, _), _, _) = a
    ((bi, bj, br, bc, _), _, _) = b
    if Rect((ai, aj, ar, ac)).contains(bi, bj, br, bc):
        return -1
    elif Rect(bi, bj, br, bc).contains(ai, aj, ar, ac):
        return 1
    else:
        return rule(ai + ar, aj, max_rows) - rule(bi + br, bj, max_rows)
Пример #2
0
def cmp_objects(a, b, max_rows):
    ((ai, aj, ar, ac, _), _, _) = a
    ((bi, bj, br, bc, _), _, _) = b
    if Rect((ai, aj, ar, ac)).contains(bi, bj, br, bc):
        return -1
    elif Rect(bi, bj, br, bc).contains(ai, aj, ar, ac):
        return 1
    else:
        return rule(ai + ar, aj, max_rows) - rule(bi + br, bj, max_rows)
Пример #3
0
 def compile(self, rules):
   for r in rules:
     r.pattern = normalize(r.pattern)
     r.pattern.set_context(self)
     name = r.pattern.compile(r.symbol)
     if name != r.symbol:
       self.rules[r.symbol].append(rule(r.symbol, [name], identity))
Пример #4
0
 def __init__(self, tokens, rules):
   self.symbols = defaultdict(set)
   self.edges = defaultdict(set)
   self.rules = defaultdict(list)
   self.rules["_empty_"].append(rule("_empty_", []))
   for r in rules:
     self.rules[r.symbol].append(r)
   self.predict(0, "start")
Пример #5
0
from rules import rule
rule("if\s+(?!\(){{anything:condition}}\s*{", "if ({condition}) {")
rule("(?<![;\{\}\n])\n", ";\n")
Пример #6
0
#Import class from file
#TODO: Refactor this, looks messy
from GamePlan import GamePlan

import rules
import Player
import cards

#Instatiations
gameplan = GamePlan()
ruleDeck = cards.Deck()

#Adding rules--------------------------
#Architect's job!
higherRule = rules.rule()
higherRule.effect = "Higher"
higherRule.usesCards = ruleDeck.getAll()[0:28]
gameplan.ruleList.append(higherRule)

lowerRule = rules.rule()
lowerRule.effect = "Lower"
lowerRule.usesCards = ruleDeck.getAll()[28:52]
gameplan.ruleList.append(lowerRule)

anyRule = rules.rule()
anyRule.effect="Play_Any"
anyRule.usesCards = ruleDeck.getAll()
gameplan.ruleList.append(anyRule)
#--------------------------------------
Пример #7
0
def partition(elem):
    if not elem.tag in part1:
        return rules.rule(elem.text)
    else:
        return elem.text