Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce repetitions #4

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

reduce repetitions #4

wants to merge 8 commits into from

Conversation

hornc
Copy link
Owner

@hornc hornc commented Aug 26, 2021

Crochet patterns use a form of run length encoding to reduce pattern instruction length.

CCT will be a RLE version of CT -- will need to add this to the converter. Or create an optimiser stage/tool.
Though non RLE instructions should always be valid too.

This branch experiments with the syntax using [rep .... ] n times notation.

TODO: implement proper parsing and interpretation of rep

Testing

regex to highlight the start / stop bit encoded text in the example:

./cct.py examples/hello-world.cct -l310 | egrep "\+ŦŦ\+\+\+\+\+\+Ŧ(\+.{8}Ŧ)*\+\+Ŧ\+\+\+\+\+\+Ŧ|"

Bytes are read from the right edge leftwards. The first byte (rightmost) is \x02 (STX). Reading from right-to-left, it has a Ŧ (1) start bit, then the byte \x02 (MSB first), followed by a + (0) stop bit, then the first character of the string with its start and stop bits, and so on, ending with a start / stop bit bounded \03 (ETX): + ŦŦ++++++ Ŧ.

Base automatically changed from examples to master June 11, 2022 23:59
@hornc
Copy link
Owner Author

hornc commented Jun 13, 2022

Working zero case truth machine example (the un-reduced example code on master) :

./cct.py examples/truth-machine-ascii.cct -l5000 -i"01" | egrep "\+ŦŦ\+\+\+\+\+\+Ŧ(\+.{8}Ŧ)*\+\+Ŧ\+\+\+\+\+\+Ŧ|"
•                                           
Ŧ                                           
+•                                          
Ŧ+                                          
+Ŧ•                                         
Ŧ++                                         
+ŦŦ•                                        
Ŧ++Ŧ                                        
+ŦŦ+•                                       
Ŧ++ŦŦ                                       
+ŦŦ++•                                      
Ŧ++ŦŦŦ                                      
+ŦŦ+++•                                     
Ŧ++ŦŦŦŦ                                     
+ŦŦ++++•                                    
Ŧ++ŦŦŦŦŦ                                    
+ŦŦ+++++•                                   
Ŧ++ŦŦŦŦŦŦ                                   
+ŦŦ++++++•                                  
Ŧ++ŦŦŦŦŦŦ+                                  
+ŦŦ++++++Ŧ•                                 
Ŧ++ŦŦŦŦŦŦ+Ŧ                                 
+ŦŦ++++++Ŧ+•                                
Ŧ++ŦŦŦŦŦŦ+ŦŦ                                
+ŦŦ++++++Ŧ++•                               
Ŧ++ŦŦŦŦŦŦ+ŦŦ+                               
+ŦŦ++++++Ŧ++Ŧ•                              
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ                              
+ŦŦ++++++Ŧ++Ŧ+•                             
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+                             
+ŦŦ++++++Ŧ++Ŧ+Ŧ•                            
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+Ŧ                            
+ŦŦ++++++Ŧ++Ŧ+Ŧ+•                           
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦ                           
+ŦŦ++++++Ŧ++Ŧ+Ŧ++•                          
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦ                          
+ŦŦ++++++Ŧ++Ŧ+Ŧ+++•                         
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ                         
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++•                        
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+                        
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ•                       
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+Ŧ                       
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+•                      
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦ                      
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ++•                     
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦ                     
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++•                    
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦ                    
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ++++•                   
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ                   
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++•                  
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ+                  
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++Ŧ•                 
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++                 
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ•                
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++Ŧ                
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ+•               
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ               
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++•              
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+              
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ•             
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+Ŧ             
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ+•            
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ            
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++•           
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+           
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ•          
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+Ŧ          
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ+•         
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦ         
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++•        
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦ        
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ+++•       
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦ       
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++•      
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦ      
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ+++++•     
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ     
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++•    
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ+    
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++Ŧ•   
Ŧ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
+ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
 ++ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
 ŦŦ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
  +ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
  Ŧ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
   ŦŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
   ++++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
    ŦŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
    +++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
     ŦŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
     ++++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
      ŦŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
      +++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
       ŦŦ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
       ++Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
        Ŧ+ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
        +Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
         +ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
         Ŧ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
          ŦŦ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
          ++Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
           Ŧ+Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
           +Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
            +Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
            Ŧ+Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
             Ŧ+ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
             +Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
              +ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
              Ŧ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
               ŦŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
               ++++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                ŦŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                +++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                 ŦŦ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                 ++Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                  Ŧ+ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                  +Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                   +ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                   Ŧ+++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                    ŦŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                    +++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                     ŦŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                     ++++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                      ŦŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                      +++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                       ŦŦ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                       ++ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                        Ŧ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                        +ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                         ++ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                         ŦŦ++Ŧ++Ŧ++++++ŦŦ   
                          +ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                          Ŧ++Ŧ++Ŧ++++++ŦŦ   
                           ŦŦ+ŦŦ+ŦŦŦŦŦŦ++   
                           ++Ŧ++Ŧ++++++ŦŦ   
                            Ŧ+ŦŦ+ŦŦŦŦŦŦ++   
                            +Ŧ++Ŧ++++++ŦŦ   
                             +ŦŦ+ŦŦŦŦŦŦ++   
                             Ŧ++Ŧ++++++ŦŦ   
                              ŦŦ+ŦŦŦŦŦŦ++   
                              ++Ŧ++++++ŦŦ   
                               Ŧ+ŦŦŦŦŦŦ++   
                               +Ŧ++++++ŦŦ   
                                +ŦŦŦŦŦŦ++   
                                Ŧ++++++ŦŦ   
                                 ŦŦŦŦŦŦ++   
                                 ++++++ŦŦ   
                                  ŦŦŦŦŦ++   
                                  +++++ŦŦ   
                                   ŦŦŦŦ++   
                                   ++++ŦŦ   
                                    ŦŦŦ++   
                                    +++ŦŦ   
                                     ŦŦ++   
                                     ++ŦŦ   
                                      Ŧ++   
                                      +ŦŦ   
                                       ++   
                                       ŦŦ   
                                        +   
                                        Ŧ•  
                                        ++  
                                        ŦŦ  
                                         +  
                                         Ŧ• 
                                         +Ŧ 
                                         Ŧ+•
                                         +Ŧ+
                                         Ŧ+Ŧ
                                          Ŧ+
                                          +Ŧ
                                          ᴑᴑ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant