added first draft litris
This commit is contained in:
37
litris.py
37
litris.py
@@ -59,15 +59,15 @@ class Litris(GameBase):
|
||||
def assess_playfield_and_make_move(self):
|
||||
|
||||
current_letter = self.stone_id()
|
||||
#current_letter = 'D'
|
||||
print("current_letter: ", current_letter)
|
||||
if current_letter is None:
|
||||
cv.waitKey(50)
|
||||
return
|
||||
|
||||
current_tetromino = Tetromino.create(current_letter)
|
||||
opt = Optimizer.get_optimal_drop(self.field, current_tetromino)
|
||||
rotation = opt['tetromino_rotation']
|
||||
if current_letter == 'D' and (rotation == 1 or rotation == 3):
|
||||
if rotation == 3:
|
||||
rotation = 1
|
||||
elif rotation == 1:
|
||||
rotation = 3
|
||||
column = opt['tetromino_column']
|
||||
print("Rota:", rotation)
|
||||
print("column:", column)
|
||||
@@ -139,7 +139,7 @@ class Litris(GameBase):
|
||||
self.keyboard.press(Key.down)
|
||||
self.keyboard.release(Key.down)
|
||||
print("direction pressed: drop down")
|
||||
cv.waitKey(100)
|
||||
cv.waitKey(50)
|
||||
fail_counter = fail_counter + 1
|
||||
cv.waitKey(50)
|
||||
|
||||
@@ -152,7 +152,7 @@ class Litris(GameBase):
|
||||
print("direction pressed: down")
|
||||
cv.waitKey(120)
|
||||
|
||||
if rotation == 1:
|
||||
if rotation == 3:
|
||||
self.keyboard.press('e')
|
||||
self.keyboard.release('e')
|
||||
print("rotation 1 pressed: e")
|
||||
@@ -161,17 +161,24 @@ class Litris(GameBase):
|
||||
self.keyboard.press('e')
|
||||
self.keyboard.release('e')
|
||||
print("rotation 2 pressed: e 1")
|
||||
cv.waitKey(40)
|
||||
cv.waitKey(30)
|
||||
self.keyboard.press('e')
|
||||
self.keyboard.release('e')
|
||||
print("rotation 2 pressed: e 2")
|
||||
cv.waitKey(40)
|
||||
elif rotation == 3:
|
||||
self.keyboard.press('q')
|
||||
self.keyboard.release('q')
|
||||
print("rotation 3 pressed: q 1")
|
||||
cv.waitKey(40)
|
||||
|
||||
cv.waitKey(30)
|
||||
elif rotation == 1:
|
||||
self.keyboard.press('e')
|
||||
self.keyboard.release('e')
|
||||
print("rotation 3 pressed: e 1")
|
||||
cv.waitKey(20)
|
||||
self.keyboard.press('e')
|
||||
self.keyboard.release('e')
|
||||
print("rotation 3 pressed: e 2")
|
||||
cv.waitKey(20)
|
||||
self.keyboard.press('e')
|
||||
self.keyboard.release('e')
|
||||
print("rotation 3 pressed: e 3")
|
||||
cv.waitKey(20)
|
||||
|
||||
if col_movement < 0:
|
||||
for i in range(0, col_movement, - 1):
|
||||
|
||||
Reference in New Issue
Block a user