-
Notifications
You must be signed in to change notification settings - Fork 3
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
Issues/268 initial map csv #296
Conversation
…des. The current implementation could cause issues if the node ids don't exactly match the imported player ids (e.g. a player drops out of the waiting room?). Not sure if that could ever happen in the real world though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great! this has already been merged, but here are some suggestions anyway :)
if matrix: | ||
result["columns"] = len(matrix[0]) | ||
else: | ||
result["columns"] = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result["columns"] = len(matrix[0]) if matrix else 0
cell = cell.strip() | ||
player_match = player_regex.match(cell) | ||
if not cell: | ||
# emtpy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the suggestion is here?
item_data["remaining_uses"] = int(id_and_maybe_uses[1]) | ||
result["items"].append(item_data) | ||
|
||
return dict(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm.... result
is already a defaultdict
. Can it be returned without converting it to dict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think a dict
is a clearer and simpler interface (since this is the key return value) than a defaultdict
, so I probably would have made this choice anyway. To me, returning a defaultdict
suggests I will be modifying the result.
|
||
reader = csv.reader(csv_file) | ||
grid_state = matrix2gridworld(list(reader)) | ||
return grid_state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return matrix2gridworld(list(reader))
I'm all for post-merge reviews. |
Adds parsing of CSV files as a way of specifying an initial grid state.
See #268