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

Post round actions #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Post round actions #17

wants to merge 5 commits into from

Conversation

corygehr
Copy link
Collaborator

@corygehr corygehr commented Jun 1, 2016

Adds the ability for a player to perform additional actions after the end of a round (ex. save data to a file, output results, etc.). Useful for applying machine learning to a player.

Not sure if you'll want to create a wrapper for this function to prevent crashing/timeouts from a player who fails to implement it properly. I attempted to do this, but with how callPlayerFunction() works it'll throw a NullPointerException since it's checking if the player has been disqualified (and at the point where I've called the function, the gameboard object has already been destroyed).

Cory Gehr and others added 2 commits May 30, 2016 14:12
…anup actions after a round has ended

Implement roundEnding() after a round has ended
Fix erroneous call to roundEnding()
@davidswelt
Copy link
Owner

Maybe this should be called before the gameboard object is gone, because the player might want to do something with it. That would take care of the issue with calling via callPlayerFunction(), which I think is a good idea (because students' code cannot be allowed to crash the tournament).

@corygehr
Copy link
Collaborator Author

corygehr commented Apr 17, 2017 via email

@corygehr
Copy link
Collaborator Author

@davidswelt Took me about a year but it should be good!

@davidswelt
Copy link
Owner

davidswelt commented Mar 29, 2018 via email

…hich would have caused game-crashing exceptions before collecting scores
@corygehr
Copy link
Collaborator Author

I seem to have forgotten to call this via callPlayerFunction(). Unfortunately, this means it's started throwing NullPointerException again in some cases, namely, when the player is no longer on the GameBoard and the round is ending.

This is thrown because when a player has been removed from the game, its internal 'gb' object is set to null (presumably because it's no longer needed - the player isn't on the board anymore). This is problematic because you're calling isDisqualified() any time callPlayerFunction() is invoked which references that object.

I mitigated this in my most recent commit by storing the scenario number locally in setGameBoard() and referencing it where needed instead of gb.scenario.requested. It seems to be working, both in a single round and multiple rounds with random scenarios.

Do you see any problems with this? Since these are private variables I believe I've caught any situation this would change, but I wanted you to be aware in case I missed something else.

@davidswelt
Copy link
Owner

davidswelt commented Mar 29, 2018 via email

@corygehr
Copy link
Collaborator Author

@davidswelt I agree. You still can access the GameBoard in roundEnding() if you've created a property for it in a Player implementation and populated it via getGameBoard(). Based on the included basic players this seems to be an implied practice to follow, but it does cause an issue if you try calling getGameBoard() in roundEnding() for a player that's already been removed from the game. You already check if gb is null in that function to ensure players aren't calling it from their constructor though so it wouldn't cause additional problems.

The GameBoard object causing the NullPointerException is within Player.java itself and that's where it's set to null when a player is removed from the board. It doesn't impact a GameBoard in inheriting classes so you can still use the GameBoard is desired.

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.

2 participants