Skip to content

Instantly share code, notes, and snippets.

@craine
craine / titanicdroppandas2.py
Created April 11, 2020 00:27
Titanic Drop Pandas 2
titanic.drop(columns=['sex'])
@craine
craine / titanicdrop1.py
Created April 11, 2020 00:24
Titanic pandas
titanic.drop(['pclass'], axis=1)
isHuman = 0
for images in human_files_short:
if face_detector(images) == True:
isHuman +=1
@craine
craine / minalpha.py
Created October 14, 2017 20:32
Minimax and Alpha get moves
'''MINIMAX GET MOVES:'''
self.time_left = time_left
# Initialize the best move so that this function returns something
# in case the search fails due to timeout
'''best_move = (1, 1)'''
legal_moves = game.get_legal_moves()
if legal_moves == []:
Traceback (most recent call last):
This script evaluates the performance of the custom_score evaluation
File "/Users/charliecraine/Documents/GitHub/AIND-Isolation-master/tournament.py", line 157, in <module>
function against a baseline agent using alpha-beta search and iterative
main()
deepening (ID) called `AB_Improved`. The three `AB_Custom` agents use
ID and alpha-beta search with the custom_score functions defined in
File "/Users/charliecraine/Documents/GitHub/AIND-Isolation-master/tournament.py", line 153, in main
game_agent.py.
play_matches(cpu_agents, test_agents, NUM_MATCHES)
class AlphaBetaPlayer(IsolationPlayer):
"""Game-playing agent that chooses a move using iterative deepening minimax
search with alpha-beta pruning. You must finish and test this player to
make sure it returns a good move before the search time limit expires.
"""
def get_move(self, game, time_left):
"""Search for the best move from the available legal moves and return a
result before the time limit expires.
Modify the get_move() method from the MinimaxPlayer class to implement
class AlphaBetaPlayer(IsolationPlayer):
"""Game-playing agent that chooses a move using iterative deepening minimax
search with alpha-beta pruning. You must finish and test this player to
make sure it returns a good move before the search time limit expires.
"""
def get_move(self, game, time_left):
"""Search for the best move from the available legal moves and return a
result before the time limit expires.
Modify the get_move() method from the MinimaxPlayer class to implement
class AlphaBetaPlayer(IsolationPlayer):
"""Game-playing agent that chooses a move using iterative deepening minimax
search with alpha-beta pruning. You must finish and test this player to
make sure it returns a good move before the search time limit expires.
"""
def get_move(self, game, time_left):
"""Search for the best move from the available legal moves and return a
result before the time limit expires.
Failed Test: 7. Test functionality of AlphaBetaPlayer.alphabeta()
----------------------------------------------------------------------
AssertionError: False is not true : Your AlphaBetaAgent.alphabeta function returned a move that was not the optimal move for the given heurisitc. Make sure that you choose the first branch with the max score at the top level; branches searched later that return the same max score may only be returning an upper bound.
Expected Best Move:
(5, 5)
Your Selection: (7, 5)
Test Case Details:
------------------
Heuristic: open_move_score
@craine
craine / alphabeta
Last active September 29, 2017 14:53
alphabeta
class AlphaBetaPlayer(IsolationPlayer):
self.time_left = time_left
def terminal_test(self, game):
if self.time_left() < self.TIMER_THRESHOLD:
raise SearchTimeout()
return not bool(game.get_legal_moves())