Closed vincentjguo closed 4 years ago
increase its search depth
that just makes it slower at being stupid
verify your algorithm? is it the correct algorithm?
probably not, i just realized today that i flipped the AI and player so the AI chose the worst possible option
this is what happens when you code 200 lines without looking back
isn't there a way to invert the scores?
multiply by -1 but i fixed it, it's fine now. But there are still some problems with it
Is the AI functional right now? Can I call a function that gives me a decision?
you still need to process it, it will return an arraylist with a list of scores for each position. I can create a function that can process it.
Hmmmmm This appears for both Normal and Hard (depths of 3 and 4)
It's really slow. There's very noticeable lag and I have a fairly powerful machine (Ryzen 5 4500U).
(I'm red)
is this on master?
oh by the way the AI has to go first, the player parameter must always be 1
It's in the ai-gui testing branch
On Jun 1 2020, at 7:56 pm, Vincent Guo notifications@github.com wrote:
is this on master? — You are receiving this because you commented. Reply to this email directly, view it on GitHub (https://github.com/potatoeggy/connectfour/issues/29#issuecomment-637187113), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AGADGXV3DHJLNRV6X5KN44LRUQ54LANCNFSM4NQFEJVA).It's
ok
right now the identifiers used for players are 1 for player 1, and -1 for player 2
On Jun 1 2020, at 7:58 pm, Vincent Guo notifications@github.com wrote:
ok — You are receiving this because you commented. Reply to this email directly, view it on GitHub (https://github.com/potatoeggy/connectfour/issues/29#issuecomment-637187528), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AGADGXTHKBBT7LKH4JH3I6TRUQ6CDANCNFSM4NQFEJVA).
I have it as player1/AI is 1 and player 2 is 2
Damn it we should have coordinated this better
What's the player parameter used for in AI ?
On Jun 1 2020, at 8:01 pm, Vincent Guo notifications@github.com wrote:
Damn it we should have coordinated this better — You are receiving this because you commented. Reply to this email directly, view it on GitHub (https://github.com/potatoeggy/connectfour/issues/29#issuecomment-637188368), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AGADGXXQUH6WIKWVVG75HFDRUQ6NHANCNFSM4NQFEJVA).
So basically every time a score is generated, it could either be negative or positive or 0. Negative means P2 has an advantage, positive means the AI has an advantage and 0 is a tie. The AI uses a minimizer and maximizer to figure out what is the best possible move for each side, hence the name minimax as it tries to minimize its losses and maximize its wins. The player parameter basically tells the AI whose turn it is and use the corresponding min/max.
If you want the AI to go second, call the function after the player moves
AI is still stupid
Fixed in 661f221c7042fe30b738282bf45d7855ab7dba75
???
Normal difficulty (depth 4)
is the ai red?
They're both AIs
Also, the AI tries to make groups of threes even if a group of four would go outside the board
that... shouldn't happen
Can you send the code you used to make the AI fight each other? It would help a lot with debugging
One more question, what's the issue with this?
I just set both dropdowns to computer
the issue is that the ai is dumb and kinda slow. It seems to take exponentially longer after every turn even against humans.
here's the relevant code chunk in MainWindow
:
while (win.gameWindow.isVisible() && !win.gameWindow.isGameOver()) { // do not run timer when game is not ongoing
if (win.gameWindow.getLock()) { // if event thread is waiting for ai calculation
win.moveTimerInternal = win.moveTimerFull;
win.gameWindow.setTimer(win.moveTimerInternal);
int col = AI.bestColumn(win.gameWindow.getBoard(), win.gameWindow.getDifficulty()); // calculate in different thread so we don't hang the main event thread
win.gameWindow.toggleLock(); // disable lock
win.gameWindow.toggleAllButtons();
win.gameWindow.sendClick(col); // send click
responseTimer = 0;
i assume that's because of the win checking thing method I used. I kinda just said screw time constraints and looped through every single token to find a win. Really bad method but it works
Yeah, even in normal difficulty it starts to take tens of seconds after just 20 or so chips.
ya AB pruning would help, but I should also find a way to optimize the win checking thing
try optimising by only checking if the last piece placed gives a win
Yes I tried doing that but the algo is made in a way where only at depth 0 could scoreGen/winchecking be called. So if at any other depth there is a win, it won't find it
Im probably going to make a visited array, and for every 4 tokens in every direction call winchecking again. This would reduce the time to check for a win by 4.
AI is less stupid as of 66958ad
"Stupid" is subjective, anyway, and there isn't any concrete issue that we can determine we've fixed or not. Smaller, more clear issues can be used in the future. Closing due to vagueness.
Yep this was just an issue for me to rage about my stupidity lul.
helphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelphelp I need to raise the AI's IQ but how