-
Notifications
You must be signed in to change notification settings - Fork 6
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
Dev #99
Conversation
For simplicity I start with synchronous client. There is an option to use asynchronous client, although the implementation is a bit more tricky.
Ignoring mypy type checking for socketio library as it does not define (and does not plan to) typing stubs.
TODO: enable Agent to make moves
The with block is important, thats how the websocket connection is automatically handled. It can be ommited by instiantiating the GeneralsIOClient directly, but it will require manual call for disconnect. For details, see: https://python-socketio.readthedocs.io/en/latest/client.html#creating-a-client-instance
GeneralsIO socket.io client
Will be usefull with map generation as player indexes are used to mark who ones given tile.
The game state saved in `map` and `cities` is initialized to an empty array. I am thinking that the patch method would at the first iteration push new items to an empty array. Although I am not sure whether it is the best approach as patch method should not have an if checking if it is the first time the patch function is called. Maybe we could create init function that would be called on the first update only? Ideally we would initialize the game states to appropriate size, unfortunatelly, sizes are propagated with the first `game_update`. If we used Python list then we don't have this problem as Python slices would handle that for us. Could numpy slice work as well?
.. and make it compatible with observations from simulator and generalsio
generals/remote/generalsio_client.py
Outdated
# convert to index | ||
source_index = source[0] * self.game_state.map[0] + source[1] | ||
destination_index = destination[0] * self.game_state.map[0] + destination[1] | ||
self.emit("attack", (int(source_index), int(destination_index), int(split))) |
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.
that is just a presonal preferrence, but I would decouple sending the message from this method and move it to the _play_game
method --> to have game message be handled in the single class.
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.
single class? you mean function?
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 think i see what you mean and it makes sense, will do that
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.
In a single method, sorry.
2722089
to
fb3d416
Compare
let me know what u think (ignore all files except client file and maybe observation)
Closes #94