Skip to content

Instantly share code, notes, and snippets.

@craine
craine / titanicdroppandas2.py
Created Apr 11, 2020
Titanic Drop Pandas 2
View titanicdroppandas2.py
titanic.drop(columns=['sex'])
View titanicdrop1.py
titanic.drop(['pclass'], axis=1)
View DogClass
isHuman = 0
for images in human_files_short:
if face_detector(images) == True:
isHuman +=1
@craine
craine / minalpha.py
Created Oct 14, 2017
Minimax and Alpha get moves
View minalpha.py
'''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 == []:
View Tournament errors1
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)
View alphabeta5
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
View alphabeta4
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
View alphabeta3
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.
View 7 error
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 Sep 29, 2017
alphabeta
View 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())
You can’t perform that action at this time.