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

Smarter AI #3

Open
slovnicki opened this issue Nov 6, 2020 · 7 comments
Open

Smarter AI #3

slovnicki opened this issue Nov 6, 2020 · 7 comments
Labels
discussion Open to discussion enhancement New feature or request

Comments

@slovnicki
Copy link
Collaborator

No description provided.

@slovnicki slovnicki added the enhancement New feature or request label Nov 6, 2020
@slovnicki slovnicki changed the title smart AI Smart AI Nov 6, 2020
@joeyda3rd
Copy link
Contributor

Do you think just a legacy type AI where they just know the rules and value moves? Or do we want to try and ML train an AI?

@slovnicki
Copy link
Collaborator Author

I want to try ML at some point, but as I recall when I built this game last time, very simple "AI" who just knows how to win and, let's say, prefers to send you to already won grids to play in, is sufficient for being a non-trivial opponent.

I was thinking of 4 AIs:

  • random (makes just random moves)
  • easy (just knows how to win, the rest of moves are random)
  • medium (knows how to win and makes some decision on where to send you)
  • trained ML model

First 3 can be made without any ML, just some ifs.

I'm gonna make the random AI these days, to show how it connects to the GameBloc, and then the other 2 can be made very similarly.

In essence, the AI class will have a function Square makeMove(Grid grid) that accepts the Grid representing the current state of the game board so any checks about the board can be done as pleased. It returns a chosen Square.

I think I'll also create some more branches for ai implementations

@blopez24
Copy link

blopez24 commented Nov 27, 2020

You may want to look into using a Minimax Algorithm.
We can create 3 heuristic/evaluation functions for easy/medium/impossible AI levels.

I recently created this for connect four school project.

@slovnicki
Copy link
Collaborator Author

slovnicki commented Nov 27, 2020

Thanks @blopez24
I think @dmorawetz had the similar idea so maybe we could start exploring the minimax soon. I made a ai/minimax branch for it so we can develop that there.

I'm just not sure will the minimax be able to handle that much branching, even with alpha-beta pruning.

@blopez24
Copy link

I believe so.

@blopez24
Copy link

It definitely needs a max_depth parameter.
For my connect four project, it was a 6 x 7 board and I used minimax w/ alpha-beta pruning. It was able to go to a depth of 7 w/ a time of ~ 1 second. A depth of 6 was less than 1 seconds.

@dmorawetz
Copy link

@blopez24 I had exactly the same thought. What bugs me though is the restriction of the inner grid you are allowed to play next. It's not just a bigger grid, but an extra restriction. I can't wrap my head around this.

@slovnicki slovnicki changed the title Smart AI Smarter AI Nov 28, 2020
@slovnicki slovnicki added the discussion Open to discussion label Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Open to discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants