Пример #1
0
 def mk_seq(self):
     sequence = []
     for t in [
         self.lmb,
         ]:
         sequence += lambda_to_sequence(t, self.lcl)
     seq = SequenceBotNone(sequence, self.slot)
     seq.set_game(self.game)
     return seq
Пример #2
0
 def run_term(self, slot, term, dirty=False):
     prop = self.game.proponent
     if dirty:
         if prop.vitalities[slot] <= 0:
             raise Fail('run_seq on dead slot {0}'.format(slot))
         yield ('l', slot, cards.put)
     for card, dir in lambda_to_sequence(term):
         if prop.vitalities[slot] <= 0:
             raise Fail('run_seq on dead slot {0}'.format(slot))
         yield (dir, slot, card)
Пример #3
0
 def apply_to(self, f, arg):
     'slot[f] = slot[f](arg)'
     return self.run_seq(f, apply_sequences([], lambda_to_sequence(arg)))
from traceback import print_exc
import sys

from terms import lambda_to_sequence, sequence_to_str
from abselim import LambdaParserException



if __name__ == '__main__':
    print 'Enter term, possibly with lambdas and numbers.'
    print r'For instance (\target. attack 0 target 10000)'
    while True:
        print '>>>',
        s = raw_input()
        try:
            seq = lambda_to_sequence(s)
        except LambdaParserException as e:
            print e
            continue
        except Exception as e:
            sys.stdout.flush()
            print_exc()
            sys.stderr.flush()
            continue
        print len(seq),
        seq = sequence_to_str(seq)
        if len(seq) > 70:
            seq = seq[:70]+' ...'
        print seq