Last active
March 26, 2023 17:04
-
-
Save antigones/979c319fa403a3f1bb3524741e8e8916 to your computer and use it in GitHub Desktop.
Actions
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
def move(self, state, what, where_from, where_to): | |
state[where_from].remove(what) | |
state[where_to].add(what) | |
def get_next_state(self, starting_state, action): | |
next_state = copy.deepcopy(starting_state) | |
if action == 'MOVE_PLAYER_FROM_LEFT_TO_BOAT': | |
if '⛵' in next_state[0]: | |
self.move(next_state, '⛵' ,0 , 1) | |
if action == 'MOVE_PLAYER_FROM_RIGHT_TO_BOAT': | |
if '⛵' in next_state[2]: | |
self.move(next_state, '⛵', 2, 1) | |
if action == 'MOVE_PLAYER_FROM_BOAT_TO_LEFT': | |
if len(next_state[1]) == 1 and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1, 0) | |
if action == 'MOVE_PLAYER_FROM_BOAT_TO_RIGHT': | |
if len(next_state[1]) == 1 and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1, 2) | |
if action == 'MOVE_GOAT_FROM_LEFT_TO_BOAT': | |
if '🐐' in next_state[0] and '⛵' in next_state[0]: | |
self.move(next_state, '⛵', 0, 1) | |
self.move(next_state, '🐐', 0, 1) | |
if action == 'MOVE_WOLF_FROM_LEFT_TO_BOAT': | |
if '🐺' in next_state[0] and '⛵' in next_state[0]: | |
self.move(next_state, '⛵', 0, 1) | |
self.move(next_state, '🐺', 0, 1) | |
if action == 'MOVE_CABBAGE_FROM_LEFT_TO_BOAT': | |
if '🥦' in next_state[0] and '⛵' in next_state[0]: | |
self.move(next_state, '⛵', 0, 1) | |
self.move(next_state, '🥦', 0, 1) | |
if action == 'MOVE_GOAT_FROM_BOAT_TO_LEFT': | |
if '🐐' in next_state[1] and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1 ,0) | |
self.move(next_state, '🐐', 1, 0) | |
if action == 'MOVE_WOLF_FROM_BOAT_TO_LEFT': | |
if '🐺' in next_state[1] and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1, 0) | |
self.move(next_state, '🐺', 1, 0) | |
if action == 'MOVE_CABBAGE_FROM_BOAT_TO_LEFT': | |
if '🥦' in next_state[1] and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1, 0) | |
self.move(next_state, '🥦', 1, 0) | |
if action == 'MOVE_GOAT_FROM_BOAT_TO_RIGHT': | |
if '🐐' in next_state[1] and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1, 2) | |
self.move(next_state, '🐐', 1, 2) | |
if action == 'MOVE_WOLF_FROM_BOAT_TO_RIGHT': | |
if '🐺' in next_state[1] and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1, 2) | |
self.move(next_state, '🐺', 1, 2) | |
if action == 'MOVE_CABBAGE_FROM_BOAT_TO_RIGHT': | |
if '🥦' in next_state[1] and '⛵' in next_state[1]: | |
self.move(next_state, '⛵', 1, 2) | |
self.move(next_state, '🥦', 1, 2) | |
if action == 'MOVE_GOAT_FROM_RIGHT_TO_BOAT': | |
if '🐐' in next_state[2] and '⛵' in next_state[2]: | |
self.move(next_state, '⛵', 2, 1) | |
self.move(next_state, '🐐', 2, 1) | |
if action == 'MOVE_WOLF_FROM_RIGHT_TO_BOAT': | |
if '🐺' in next_state[2] and '⛵' in next_state[2]: | |
self.move(next_state, '⛵', 2, 1) | |
self.move(next_state, '🐺', 2, 1) | |
if action == 'MOVE_CABBAGE_FROM_RIGHT_TO_BOAT': | |
if '🥦' in next_state[2] and '⛵' in next_state[2]: | |
self.move(next_state, '⛵', 2, 1) | |
self.move(next_state, '🥦', 2, 1) | |
return next_state |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment