예제 #1
0
    def test_cycled_programms(self):
        programms = (
            #(["+++[>++<-]>."], "F"),
            #(["+++[>+++++<-]>."], "O"),
            #(["++[>+++[>+++<-]<-]>>."], "R"),
            #(["++[>++[>+++++<-]<-]>>+."], "U"),
            ([
r"++[(  (>+++++(     ",                
r"   >  [      <     ",                
r"   )++)      -     ",                
r"             ]     ",                
r"      .+>>]-<(     ",                
r"                   ",                
r"                   ",                
r"                   ",                
r"                   ",                
r"                   ",                
r"                   ",                
                
                
                ], "U"),
                    )
        
        for program, rightresult in programms:
            game = Game(Map(60,60))
            pl = Player("darvin",game)
            
            pl.cast("create_robot", Coords(0,0), Direction('e'))
            self.place_operators(pl, program, 0,0)
            
            pl.cast("run") 
            for i in range(100):
                game.tick()
            
            self.assertEqual(rightresult, pl.robots[0].output)
예제 #2
0
    def test_import(self):
        programms = (
            (["++++++++.>+++++.<++++..++++-."], "HELLO"),
            (["++++++++.>+++++.<++++..++++-."], "HELLO"),
            (["++++++++.>+++++.<++++..++++-."], "HELLO"),
            (["++++++++.>+++++.<++++..++++-."], "HELLO"),
                ([\
"+++(",\
"   +",\
"   +",\
".++(",\
"",\
], "G"),

            )
        
        for program, rightresult in programms:
            mapp = Map.from_list(program)
            game = Game(mapp)
            pl = Player("darvin", game)
            
            pl.cast("create_robot", Coords(0,0), Direction('e'))
            
            pl.cast("run") 
            for i in range(100):
                game.tick()
            self.assertEqual(rightresult, pl.robots[0].output)
예제 #3
0
    def test_many_programms(self):
        programms = (
            #(["++++++++.>+++++.<++++..++++-."], "HELLO"),
            #(["++++++++.>+++++.<++++..++++-."], "HELLO"),
            #(["++++++++.>+++++.<++++..++++-."], "HELLO"),
            #(["++++++++.>+++++.<++++..++++-."], "HELLO"),
                ([\
" +++(",\
"    +",\
"    +",\
" .++(",\
"",\
], "G"),

            )
        
        for program, rightresult in programms:
            game = Game(Map(60,60))
            pl = Player("darvin",game)
            
            pl.cast("create_robot", Coords(0,0), Direction('e'))
            self.place_operators(pl, program, 0,0)
            
            pl.cast("run") 
            for i in range(100):
                game.tick()
            self.assertEqual(rightresult, pl.robots[0].output)
예제 #4
0
 def test_one_player(self):
     game = Game(Map(13,13))
     pl = Player("darvin", game)
     
     self.assertEqual(pl.game, game)
     
     pl.cast("create_robot", Coords(0,0), Direction('e'))
    
     program = "+.+.+.+.+"
     for op, x in zip(program, range(len(program))):
         pl.place_operator(op, Coords(x,0))
         
     pl.cast("run")
     
     for i in range(100):
         game.tick()
     
     self.assertEqual("ABCD", pl.robots[0].output)