Last active
February 22, 2019 05:55
-
-
Save jittat/a6457feeda48692f6bcdb226db5ffce8 to your computer and use it in GitHub Desktop.
Sokoban template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Box: | |
def __init__(self,r,c,board): | |
pass | |
class Player: | |
def __init__(self,r,c,board): | |
pass | |
def move_up(self): | |
pass | |
def move_down(self): | |
pass | |
def move_left(self): | |
pass | |
def move_right(self): | |
pass | |
class Exit: | |
def __init__(self,r,c,board): | |
pass | |
class Board: | |
def __init__(self, board_lines): | |
self.player = Player(0, 0, self) | |
pass | |
def show_board(self): | |
pass | |
def is_over(self): | |
return False | |
def main(): | |
board = Board(['..#####.', | |
'###...#.', | |
'#*AO..#.', | |
'###.O*#.', | |
'#*##O.#.', | |
'#.#.*.##', | |
'#O.0OO*#', | |
'#...*..#', | |
'########',]) | |
player = board.player | |
step = 0 | |
while not board.is_over(): | |
step += 1 | |
print('Step:', step, 'Current board is:') | |
board.show_board() | |
print('Pick direction L,R,U,D') | |
movement = input() | |
if movement == 'U': | |
player.move_up() | |
elif movement == 'D': | |
player.move_down() | |
elif movement == 'L': | |
player.move_left() | |
elif movement == 'R': | |
player.move_right() | |
print('You use',step,'steps') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment