Skip to content

Commit

Permalink
added verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ja3537 committed Oct 18, 2022
1 parent acc5637 commit 7a776ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@
help = "set number of shuffles per deck for this mission"
)
parser.add_argument(
"-null_rate",
"--null_rate",
"-nr",
default = 0,
help = "set the probablility (between 0 and 1) of giving agent a random deck instead of a message"
)
parser.add_argument(
"--verbose",
"-v",
default = False,
action="store_true",
help = "verbose mode includes encrypted and shuffled decks in output"

)
#TODO: timeout, null interleaving rate, printing results, set shuffle number n, random shuffle numbers


Expand Down
15 changes: 10 additions & 5 deletions mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class Mission:
def __init__(self, args):
self.seed = args.seed
self.verbose = args.verbose
self.rng = np.random.default_rng(self.seed)
#self.agent = args.agent[0]
self.agent = default_agent()
Expand All @@ -27,6 +28,7 @@ def __init__(self, args):
i = i + 1

self.encoded_decks = []
self.shuffled_decks = []
self.decoded = [None]*len(self.messages)
self.scores = [None]*len(self.messages)
self.total_score = 0
Expand All @@ -46,21 +48,21 @@ def execute_mission(self):
for i in range(len(self.encoded_decks)): #shuffling stage
d = self.encoded_decks[i]
if cards.valid_deck(d):
self.encoded_decks[i] = self.s(self.n, d)
self.shuffled_decks.append(self.s(self.n, d))



for i in self.messages_index:
e_deck = self.encoded_decks[i]
if cards.valid_deck(e_deck):
decoded_m = self.agent.decode(self.encoded_decks[i])
s_deck = self.shuffled_decks[i]
if cards.valid_deck(s_deck):
decoded_m = self.agent.decode(s_deck)
score = self.score_message(self.messages[i], decoded_m)
self.decoded[i] = decoded_m
else:
score = 0
self.decoded[i] = "invalid deck: {}".format(e_deck)
self.scores[i] = score
self.total_score = self.total_score + score
self.total_score += score


self.make_output_file()
Expand All @@ -86,6 +88,9 @@ def make_output_file(self):
with open(self.output, 'w+') as f:
for i in range(len(self.messages)):
f.write(self.messages[i] + '\n')
if(self.verbose):
f.write('encoded deck: ' + str(self.encoded_decks[i]) + '\n')
f.write('shuffled deck: ' + str(self.shuffled_decks[i]) + '\n')
f.write(self.decoded[i] + '\n')
f.write(str(self.scores[i]) + '\n')
f.write('\n')
Expand Down

0 comments on commit 7a776ca

Please sign in to comment.