Skip to content

Post round actions - #17

Open
corygehr wants to merge 5 commits into
masterfrom
post-round-actions
Open

Post round actions#17
corygehr wants to merge 5 commits into
masterfrom
post-round-actions

Conversation

@corygehr

@corygehr corygehr commented Jun 1, 2016

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

corygehr commented Apr 17, 2017 via email

Copy link
Copy Markdown
Collaborator Author

@corygehr

Copy link
Copy Markdown
Collaborator Author

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

@davidswelt

davidswelt commented Mar 29, 2018 via email

Copy link
Copy Markdown
Owner

…hich would have caused game-crashing exceptions before collecting scores
@corygehr

Copy link
Copy Markdown
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

davidswelt commented Mar 29, 2018 via email

Copy link
Copy Markdown
Owner

@corygehr

Copy link
Copy Markdown
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