Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.fbb.msu.ru/trac/snake/changeset/115%3A4cafedd51b69
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 09:29:30 2016
Êîäèðîâêà: IBM-866
Changeset 115:4cafedd51b69 òÀÓ Python Battle

Changeset 115:4cafedd51b69


Ignore:
Timestamp:
12/20/10 14:32:26 (5 years ago)
Author:
Daniil Alexeyevsky <me.dendik@òÀæ>
Branch:
default
Message:

Added The Void Cell to represent everything outside of field, used in snake.Rule.applies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • snake.py

    r109 r115 ˆà
    117117        char = char.lower()ˆà
    118118        assert char in self.codes, "Illegal symbol in rule: %s" % charˆà
    119ˆà        cell = engine.Cell(x, y, self.snake)ˆà
    ˆà119        cell = engine.Cell(x, y)ˆà
    ˆà120        cell.snake = self.snakeˆà
    120121        if char in 'htb':ˆà
    121122            if is_my:ˆà
    òÀæ òÀæ ˆà
    132133    def applies (self, field, x, y):ˆà
    133134        """True if the rule applies in the field at position (x,y)."""ˆà
    ˆà135        wall = engine.Cell(-1, -1)ˆà
    ˆà136        wall.type = 'void'ˆà
    ˆà137ˆà
    134138        for px, fx in zip(range(7), range(x - 3, x + 4)):ˆà
    135139            for py, fy in zip(range(7), range(y - 3, y + 4)):ˆà
    136ˆà                if (fx, fy) in field:ˆà
    137ˆà                    if field[fx, fy] != self.pattern[px, py]:ˆà
    138ˆà                        return Falseˆà
    139ˆà                else:ˆà
    140ˆà                    if self.pattern[px, py].type != 'any':ˆà
    141ˆà                        return Falseˆà
    ˆà140                if field.get((fx, fy), wall) != self.pattern[px, py]:ˆà
    ˆà141                    return Falseˆà
    142142        return Trueˆà
    143143ˆà
Note: See TracChangeset for help on using the changeset viewer.