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

Dev #99

Merged
merged 17 commits into from
Oct 25, 2024
Merged

Dev #99

merged 17 commits into from
Oct 25, 2024

Conversation

strakam
Copy link
Owner

@strakam strakam commented Oct 24, 2024

let me know what u think (ignore all files except client file and maybe observation)

Closes #94

revolko and others added 15 commits October 19, 2024 01:13
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
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
@strakam strakam requested a review from revolko October 24, 2024 12:03
# 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)))
Copy link
Collaborator

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.

Copy link
Owner Author

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?

Copy link
Owner Author

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

Copy link
Collaborator

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.

@strakam strakam force-pushed the dev branch 2 times, most recently from 2722089 to fb3d416 Compare October 25, 2024 10:09
@strakam strakam marked this pull request as ready for review October 25, 2024 10:10
@strakam strakam merged commit 48b608d into master Oct 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow agent deployment to real generals.io!
2 participants