mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Simplified / Shortened move script
This commit is contained in:
@@ -61,18 +61,13 @@ def move(board):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
end = int(input("TO WHERE? "))
|
end = int(input("TO WHERE? "))
|
||||||
if not (board[end] == 'O'):
|
|
||||||
return False
|
|
||||||
difference = abs(end - start)
|
difference = abs(end - start)
|
||||||
if difference != 2 and difference != 18:
|
|
||||||
return False
|
|
||||||
center = (end + start) / 2
|
center = (end + start) / 2
|
||||||
if not board[center] == '!':
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
if (difference == 2 or difference == 18) and board[end] == 'O' and board[center] == '!':
|
||||||
board[start] = 'O'
|
board[start] = 'O'
|
||||||
board[center] = 'O'
|
board[center] = 'O'
|
||||||
board[end] = '!'
|
board[end] == '!'
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user