Skip to content

Conversation

@VictorABoye
Copy link
Collaborator

Implemented MCTS, some stuff that should still be checked.

  • Max simulation depth
    • Maybe 20 is too low, but without a limit I ran into a problem where it would take a very long time for the AI to choose
    • We could look into the policies and see if we can modify them

It is now possible to change the BattleAI by chosing one of three options in the settings. This is used in quick battle and battles that start through the map view.

Copy link
Owner

@AlexanderNorup AlexanderNorup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only did a quick code review for styling. Didn't go through the logic thoroughly, but I'll take your word for it that it works. Very nice!

} else if(bestChild.getParentSwitch() != null){
battleSimulation.switchMonster(participantToControl, bestChild.getParentSwitch());
} else {
throw new IllegalStateException("AI found no moves to do");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have the battle simulation catch this exception so it can handle it gracefully.

var possibleActionCount = possibleActions.size();
if(possibleActionCount == 0) return -1;
else{
var rand = new Random();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Does Java seed new Random() correctly? Or would it be better to have one shared Random instance?

You don't have to change it, I'm just wondering. It's probably a microoptimization at worst and meaningless at best. I'm just curious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be seeded with the timestamp or something like it. According to javadoc

This constructor sets the seed of the random number generator to a value very likely to be distinct from any other invocation of this constructor.

IGameViewService selectedView = views.get(currentOption);
gvm.setView(selectedView);
if (selectedView instanceof IBattleView) {
if (selectedView instanceof IBattleView battleView) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feeling of using a feature > Java 8 is just amazing.

@VictorABoye VictorABoye merged commit 927e358 into master Oct 25, 2023
@VictorABoye VictorABoye deleted the vboye/2/mcts branch October 25, 2023 07:10
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.

3 participants