;ò
-ð‰Jc           @   sƒ  d  k  Z  d  k Z d  k Z d Z d e f d „  ƒ  YZ d Z d Z d Z d Z	 d Z
 d Z d Z d Z d Z d Z d	 Z d
 Z d Z d d d d f Z d d d d f Z d d d d f Z d d d d f Z d d d d f Z d d d d f Z d d d d f Z d d d d f Z d d „ Z d „  Z d „  Z d e f d „  ƒ  YZ d „  Z d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d  S(   Ns$   High-level scripting aids for Golly.s   rectc           B   s#   t  Z d  Z d „  Z g  d „ Z RS(   s:   A simple class to make it easier to manipulate rectangles.c         C   s)   t  i |  i |  i |  i |  i g ƒ Sd S(   s6   Return true if rect is completely visible in viewport.N(   s   gollys   visrects   selfs   xs   ys   wds   ht(   s   self(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   visible   s     c         C   s  t  | ƒ d j o t |  _ në t  | ƒ d j oË t |  _ | d |  _ |  _ | d |  _ |  _	 | d |  _
 |  _ | d |  _ |  _ |  i
 d j o t d ƒ ‚ n |  i d j o t d ƒ ‚ n |  i |  i
 d |  _ |  i	 |  i d |  _ n t d ƒ ‚ t i |  | ƒ d  S(	   Ni    i   i   i   i   s   rect width must be > 0s   rect height must be > 0s"   rect arg must be [] or [x,y,wd,ht](   s   lens   Rs   Trues   selfs   emptys   Falses   xs   lefts   ys   tops   wds   widths   hts   heights
   ValueErrors   rights   bottoms	   TypeErrors   lists   __init__(   s   selfs   R(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   __init__   s     	  (   s   __name__s
   __module__s   __doc__s   visibles   __init__(    (    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   rect   s    	i    i   s   Draws   Picks   Selects   Moves   Zoom Ins   Zoom Outiÿÿÿÿs   B3/S23c         C   s   t  i |  ƒ d S(   s˜   Set the rule for the Game of Life.
Although it affects subsequent calls to pattern.evolve(),
only the last call to this function matters for the viewer.N(   s   gollys   setrules   s(   s   s(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   ruleQ   s     c         C   s'   x  |  i d ƒ D] } d G| GHq Wd S(   s2   Supply a textual description to the whole pattern.s   
s   #DN(   s   ss   splits   line(   s   ss   line(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   descriptionZ   s      c      	   C   sù   |  d } |  d } |  d } | d } | d } | d } | | d | | d | | | d | | d | | d | d | d | d | d | d | d | d | d | d | d | d | d | d | d | d f f Sd S(   sè   Return the composition of two transformations S and T.
A transformation is a tuple of the form (x, y, A), which denotes
multiplying by matrix A and then translating by vector (x, y).
These tuples can be passed to pattern.__call__().i    i   i   i   N(   s   Ss   xs   ys   As   Ts   ss   ts   B(   s   Ss   Ts   As   Bs   ss   ys   xs   t(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   composea   s     s   patternc           B   s   t  Z d  Z d „  Z d „  Z e d „ Z d „  Z d „  Z d d e d „ Z	 d d d e d	 „ Z
 e d
 „ Z d „  Z g  d d e d „ Z RS(   s"   This class represents a cell list.c         C   s   t  t i |  | ƒ ƒ Sd S(   s   Join patterns.N(   s   patterns   gollys   joins   selfs   q(   s   selfs   q(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   __add__r   s     c         C   s   |  i | ƒ Sd S(   su   The __getitem__() function is an alias to evolve().
It allows to access the pattern's phases as elements of an array.N(   s   selfs   evolves   N(   s   selfs   N(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   __getitem__v   s     c         C   s    t  t i |  | | | Œ ƒ Sd S(   s'   The same as 'apply(A).translate(x, y)'.N(   s   patterns   gollys	   transforms   selfs   xs   ys   A(   s   selfs   xs   ys   A(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   __call__|   s     c         C   s   |  | | ƒ Sd S(   s   Translate the pattern.N(   s   selfs   xs   y(   s   selfs   xs   y(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys	   translate€   s     c         C   s   |  d d | ƒ Sd S(   s¹   Apply a matrix transformation to the pattern.
Predefined matrices are:
identity, flip, flip_x, flip_y, swap_xy, swap_xy_flip,
rcw (rotate clockwise) and rccw (rotate counter-clockwise).i    N(   s   selfs   A(   s   selfs   A(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   apply„   s     i    c         C   s   t  i |  | | | Œ d S(   s$   Paste pattern into current universe.N(   s   gollys   putcellss   selfs   xs   ys   A(   s   selfs   xs   ys   A(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   putŒ   s     s   untitledc         C   s>   t  i | ƒ t  i |  | | | Œ t  i ƒ  t  i	 t
 ƒ d S(   s3   Paste pattern into new universe and display it all.N(   s   gollys   news   titles   putcellss   selfs   xs   ys   As   fits	   setcursors   zoomin(   s   selfs   titles   xs   ys   A(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   display   s
     
c         C   s   t  i |  | | ƒ d S(   sY   Save the pattern to file 'fn' in RLE format.
An optional description 'desc' may be given.N(   s   gollys   stores   selfs   fns   desc(   s   selfs   fns   desc(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   save—   s     c         C   s½   | d j  o t d ƒ ‚ n |  i i | ƒ o |  i | Sn d } x? |  i i ƒ  D]. } | | j  o
 | j  n o
 | } qU qU Wt t	 i
 |  i | | | ƒ ƒ } |  i | <| Sd S(   s±   Return N-th generation of the pattern.
Once computed, the N-th generation is remembered and quickly accessible.
It is also the base for computing generations subsequent to N-th.i    s   backward evolving requestedN(   s   Ns
   ValueErrors   selfs   _pattern__phasess   has_keys   Ms   keyss   ks   patterns   gollys   evolves   p(   s   selfs   Ns   ks   Ms   p(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   evolve   s       .c         C   s¶   t  ƒ  |  _ t | ƒ t j o t i |  | ƒ ns t | ƒ t j o t i |  t | ƒ ƒ nF t | ƒ t j o& t i |  t	 i
 | | | | Œ ƒ n t d ƒ ‚ |  |  i d <d S(   s   Initialize a pattern from argument P.
P may be another pattern, a cell list, or a multi-line string.
A cell list should look like [x1, y1, x2, y2, ...];
a string may be in one of the two autodetected formats:
'visual' or 'RLE'.
o  'visual' format means that the pattern is represented
   in a visual way using symbols '*' (on cell), '.' (off cell)
   and '\n' (newline), just like in Life 1.05 format.
   (Note that an empty line should contain at least one dot).
o  'RLE' format means that a string is Run-Length Encoded.
   The format uses 'o' for on-cells, 'b' for off-cells and
   '$' for newlines.
   Moreover, any of these symbols may be prefixed by a number,
   to denote that symbol repeated that number of times.

When P is a string, an optional transformation
(x0, y0, A) may be specified.
s   list or string is required herei    N(   s   dicts   selfs   _pattern__phasess   types   Ps   lists   __init__s   patterns   strs   gollys   parses   x0s   y0s   As	   TypeError(   s   selfs   Ps   x0s   y0s   A(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   __init__¬   s     &(   s   __name__s
   __module__s   __doc__s   __add__s   __getitem__s   identitys   __call__s	   translates   applys   puts   displays   Nones   saves   evolves   __init__(    (    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   patterno   s    					c         C   s   t  t i |  ƒ ƒ Sd  S(   N(   s   patterns   gollys   loads   fn(   s   fn(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   loadÎ   s    c   
      C   s^  t  i } t  i } t  i } t  i } t |  ƒ } t	 | ƒ } d }	 | d @d j o) d }	 | d d j o | d 8} q~ n xX t d | |	 ƒ D]D } | | | j  o | | } n | | | j o | | } q‘ q‘ WxX t d | |	 ƒ D]D } | | | j  o | | } n | | | j o | | } qì qì Wt | | | | d | | d g ƒ Sd  S(   Ni   i   i   i    (   s   syss   maxints   minxs   maxxs   minys   maxys   lists   patts   clists   lens   clens   incs   xranges   xs   ys   rect(
   s   patts   maxxs   maxys   minxs   minys   clists   clens   ys   xs   inc(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys	   getminboxÔ   s0    	
	
       c         C   sQ  d } d } t i |  d | ƒ d } t i ƒ  } xt ot i ƒ  } | | d j o5 | } | | f \ } } t i |  d | | ƒ n t i
 d ƒ t i ƒ  } t | ƒ d j o | t d ƒ j o t i d ƒ | Sn | t d ƒ j o | d	  } d } n | d j  o
 d } n | | 7} t i |  d | | ƒ q6 q6 Wd  S(
   Ns   _s    s    f0.5f0.050000000000000003i    i   i   iÿÿÿÿ(   s   cursor1s   cursor2s   gollys   shows   prompts   inps   times   oldsecss   Trues   newsecss   sleeps   getkeys   chs   lens   chr(   s   prompts   newsecss   oldsecss   inps   chs   cursor1s   cursor2(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys	   getstringñ   s2     



c         C   sk   t  |  ƒ d j o t Sn |  i d d ƒ }  |  d d j p |  d d j o |  d }  n |  i ƒ  Sd  S(   Ni    s   ,s    s   +s   -i   (   s   lens   ss   Falses   replaces   isdigit(   s   s(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   validint  s     " c          C   s,   t  i ƒ  \ } }  t | ƒ t |  ƒ f Sd  S(   N(   s   gollys   getposs   xs   ys   int(   s   ys   x(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys	   getposint  s    c         C   s    t  i t |  ƒ t | ƒ ƒ d  S(   N(   s   gollys   setposs   strs   xs   y(   s   xs   y(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys	   setposint!  s    (%   s   gollys   syss   times   __doc__s   lists   rects   insides   outsides
   left_rights
   top_bottoms   up_downs	   clockwises   anticlockwises   draws   picks   selects   moves   zoomins   zoomouts   identitys   flips   flip_xs   flip_ys   swap_xys   swap_xy_flips   rcws   rccws   rules   descriptions   composes   patterns   loads	   getminboxs	   getstrings   validints	   getposints	   setposint($   s   loads
   top_bottoms	   setposints   moves   swap_xy_flips   flip_xs   flip_ys	   getminboxs	   clockwises   selects   rects   composes	   getstrings   patterns   rcws   outsides
   left_rights	   getposints   zoomins   __doc__s   draws   descriptions   rccws   times   anticlockwises   syss   validints   up_downs   identitys   gollys   zoomouts   insides   flips   rules   picks   swap_xy(    (    s4   /HD/Golly/golly/src/Scripts/Python/glife/__init__.pys   ?   sF   						_			 			