Could you help me implement AI on my tic tac toe game | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

Could you help me implement AI on my tic tac toe game

I've created a very simple tic tac toe works perfectly for 2p in C++, I was wondering if someone could help me implement it with the minimax algorithm. I'd really like you to recommend a c++ totutial on AI. Tic Tac Toe Code: https://code.sololearn.com/ckyl0hVh73TV/#cpp

25th Jul 2019, 12:30 AM
Cout
Cout - avatar
13 Answers
+ 4
Prometheus 🇸🇬 I am pretty sure that I could start as well and not have the ai start because if I would of start then it wouldn't work
25th Jul 2019, 1:16 AM
Cout
Cout - avatar
+ 3
https://code.sololearn.com/WejZMx2Qg3GR/?ref=app Check this impossible-to-win AI I made
25th Jul 2019, 1:09 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
Prometheus 🇸🇬 don't get me wrong I appreciate the fact that you are trying to help me but it doesn't really work
25th Jul 2019, 1:17 AM
Cout
Cout - avatar
+ 2
Prometheus 🇸🇬 I am using C++ and I am pretty sure you are not using it you are just doing all the possibilities the computer has to start
25th Jul 2019, 1:11 AM
Cout
Cout - avatar
+ 2
You can use this AI structure: 1. If there is a chance to win, use it. 2. If you can prevent your enemy from winning, do that. 3. If you can make a cross in the middle do it, if not, take a cross in the corners and if these are full too, use the sides. Now have fun coding!
26th Jul 2019, 11:16 AM
T. Feix
T. Feix - avatar
+ 2
You have to implement it in a c++ program that’s the challenge. Read the lines. Convert them into a function, this is a structure.
26th Jul 2019, 2:12 PM
T. Feix
T. Feix - avatar
+ 2
Oh, ok 😅. I thought you needed to have a plan.
26th Jul 2019, 2:22 PM
T. Feix
T. Feix - avatar
+ 1
You check the algo
25th Jul 2019, 1:14 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
That's like half of the work done. The other half is left for you. For that you need to do what I did: Consider all possible games.
25th Jul 2019, 1:31 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
0
Prometheus 🇸🇬 Yeah this is what I was talking about I don't think that it should work like that is it really the minimax algorithm? And it's really not half of the work it's not the same style of code or not even the language
25th Jul 2019, 1:33 AM
Cout
Cout - avatar
0
T. Feix What algorithm are you talking about because it's easier said than done
26th Jul 2019, 11:18 AM
Cout
Cout - avatar
0
T. Feix Dude I know my options the problem is how do it do it that's why I need the algorithm
26th Jul 2019, 2:13 PM
Cout
Cout - avatar
- 8
هيلاوو
25th Jul 2019, 11:02 PM
كيان المجروح