Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strategyMove() type integration #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion code/prisonersDilemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def getVisibleHistory(history, player, turn):

def strategyMove(move):
if type(move) is str:
defects = ["defect","tell truth"]
defects = ["defect","tell truth", "D"]
return 0 if (move in defects) else 1
elif type(move) is bool:
Copy link

@duckboycool duckboycool May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check isn't necessary since bools are converted into 0 or 1 by the else anyway. (And also the numpy array type is int, so it will be converted to an int there.)

return 1 if (move) else 0
else:
# Coerce all moves to be 0 or 1 so strategies can safely assume 0/1's only
return int(bool(move))
Expand Down