Ejemplo n.º 1
0
Archivo: gui.py Proyecto: 8e7/Tetris-AI
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
            pygame.quit()
            exit()

    for i in range(0, 20):
        for j in range(10):
            if game.grid[i] & (1 << j):
                screen.blit(onimg, (300 + j * 35, 750 - i * 35))
            else:
                screen.blit(offimg, (300 + j * 35, 750 - i * 35))
    if game.alive and game.lines < 230:
        if mode == 0:
            rot, pos = main.move(game, main.tet[main.testcases[0][cnt]],
                                 main.tet[main.testcases[0][cnt + 1]], points,
                                 2)
            #rot, pos = main.move(game, main.tet[4], main.tet[4], points, 2)
            mode = 1
            y = 20
        else:
            arr = main.tet[main.testcases[0][cnt]].tile[rot]
            #arr = main.tet[4].tile[rot]
            if not game.col(pos, y, arr):
                for i in arr:
                    screen.blit(onimg, (300 + (pos + i[0]) * 35, 750 -
                                        (y + i[1]) * 35))
                y -= 1
            else:
                if y + 1 >= 20:
                    game.alive = 0
Ejemplo n.º 2
0
 def move(self, direction):
     #print "spider.move(" + str(direction) + ")"
     main.move(direction)
Ejemplo n.º 3
0
    ['D', 'E', 'Y', 'H', 'A', 'D'],
    ['C', 'B', 'Z', 'Y', 'J', 'K'],
    ['D', 'B', 'C', 'A', 'M', 'N'],
    ['F', 'G', 'G', 'R', 'S', 'R'],
    ['V', 'X', 'H', 'A', 'S', 'S']
], "d") == 1:
        completed += 1
    else:
        methodsNotWorking.append("letter_counter")

    if m.hacker_speak("programming is fun") == "pr0gr4mm1ng 15 fun":
        completed += 1
    else:
        methodsNotWorking.append("hacker_speak")

    if m.move("hello") == "ifmmp":
        completed += 1
    else:
        methodsNotWorking.append("move")

    if m.is_legitimate([
[0, 0, 0, 0, 0, 0, 0, 0], 
[0, 1, 1, 1, 1, 1, 0, 0], 
[0, 1, 1, 1, 1, 1, 0, 0], 
[0, 1, 1, 0, 0, 1, 0, 0], 
[0, 1, 1, 1, 1, 1, 0, 0], 
[0, 0, 0, 0, 0, 0, 0, 0]
]) == True:
        completed += 1
    else:
        methodsNotWorking.append("is_legitimate")
Ejemplo n.º 4
0
 def test_moving_north_from_north_west_max(self):
     curr_x_axis = 4
     curr_y_axis = 4
     self.assertEqual(move("NORTH", curr_x_axis, curr_y_axis), False,
                      "Should be False")
Ejemplo n.º 5
0
 def test_moving_east_from_north_east_max(self):
     curr_x_axis = 4
     curr_y_axis = 0
     self.assertEqual(move("EAST", curr_x_axis, curr_y_axis), False,
                      "Should be False")
Ejemplo n.º 6
0
 def test_moving_west_from_north_west_max(self):
     curr_x_axis = 4
     curr_y_axis = 4
     self.assertEqual(move("WEST", curr_x_axis, curr_y_axis), True,
                      "Should be True")
Ejemplo n.º 7
0
 def test_moving_south_from_origin(self):
     curr_x_axis = 0
     curr_y_axis = 0
     self.assertEqual(move("SOUTH", curr_x_axis, curr_y_axis), False,
                      "Should be False")
Ejemplo n.º 8
0
 def test_moving_north_from_origin(self):
     curr_x_axis = 0
     curr_y_axis = 0
     self.assertEqual(move("NORTH", curr_x_axis, curr_y_axis), True,
                      "Should be true")