Skip to content

Commit

Permalink
Fixed string encoding error for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jyan1999 committed Jan 27, 2024
1 parent 5a054c2 commit cff884c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/overcooked_ai_py/mdp/overcooked_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ def print_state_transition(
if fname is None:
print(output_string)
else:
f = open(fname, "a")
print(output_string, file=f)
f.close()
with open(fname, "a", encoding='utf-8') as f:
print(output_string, file=f)

###################
# BASIC ENV LOGIC #
Expand Down Expand Up @@ -446,9 +445,8 @@ def run_agents(

if dir != None:
fname = dir + "/roll_out_" + str(time.time()) + ".txt"
f = open(fname, "w+")
print(self, file=f)
f.close()
with open(fname, "w+", encoding='utf-8') as f:
print(self, file=f)
while not done:
s_t = self.state

Expand Down
4 changes: 2 additions & 2 deletions testing/overcooked_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,9 +1323,9 @@ def tearDown(self):
shutil.rmtree(self.dummy_dir)

def _assert_files_equal(self, file_1, file_2):
with open(file_1, "r") as f:
with open(file_1, "r", encoding='utf-8') as f:
lines_1 = f.readlines()
with open(file_2, "r") as f:
with open(file_2, "r", encoding="utf-8") as f:
lines_2 = f.readlines()

for line_1, line_2 in zip(lines_1, lines_2):
Expand Down

0 comments on commit cff884c

Please sign in to comment.