Hey this is connect 4 program with Minimax algorithm using NegaMax algorithm and I don't know actually if I implemented it correctly ... The problem is I don't know how to evaluate neutral moves please check it out and tell me how to implement it better
I made it run and it beat me. I never claimed that I was good at connect 4.
But you have successfully created a program that is smarter then me :)
I did have a little problem running it though. INFINITE wasnt defined and you didnt include <string>, and in function getValue() n wasn't initialized which resulted in a run time error. did you run it on Linux? or maybe an IDE that includes those automatically for you, and auto initializes variables?
this line is very dangerousfloat temp = -(100*NegaMax(1)+( (100*EVA)/PlayOut));
you see when this line of code is called PlayOut is 0; which means that you devide by 0. That would be the case but NegaMax() function is evaluated first and changes PlayOut to not be zero. However how can you be so sure that NegaMax() will be called before the devision? It might just be that a different compiler or a new version of the same, or given some optimization flags, the devision will be evaluated before the NegaMax() function. Basically this should be split into 2 lines of code, with perhaps checking for devision by 0
Anyways, an improvement could be a more file oriented design, using object oriented programming. If you would like I am going to be working on a tutorial for a chess program sometime in the future. It will be posted on my site www.proswaggrammer.com its under construction.
If you want to continue to develop AI algorithms. Then you should pick up a book for AI programming/data mining/statistics. Its a very hot and promising programming field, used heavily in advertising campaigns, and statistical predictions, and image processing.
If you want to continue to develop more complex video games on C++, then you should start learning new programming technologies such as SDL/SFML/OpenGL look for tutorials online, there are a lot of very complicated algorithms, (MinMax, shortest path), that video games use. And lots of design patterns that create a good game environment. A simple game can easily exceed 10,000 lines of code. And as you now know, it will be impossible to create without a good design of code. However this field is the MOST difficult path to succeed in, you will become a very good programmer though.
If you want to however just have some fun on modern devices(IPhones,Galaxies). Just try some Java or C# for those stuff. I personally am not attracted to that way.
I did have a little problem running it though. INFINITE wasnt defined and you didnt include <string>, and in function getValue() n wasn't initialized which resulted in a run time error. did you run it on Linux? or maybe an IDE that includes those automatically for you, and auto initializes variables?
INFINITE is defined in math.h library but any ways you're right :D I'll define it or I will just put a huge number ..
and about GetValue function its already initialized or I maybe didn't get what you mean :D sry still beginner
1 2 3 4
int winning();
int GetValue(int t);
int AIManager();
int NegaMax(int Depth);
this line is very dangerous float temp = -(100*NegaMax(1)+( (100*EVA)/PlayOut));
you see when this line of code is called PlayOut is 0; which means that you devide by 0
you are absolutely right :D I even had some bugs I never knew the cause .... NegaMax is evaluated first cuz temp = NegaMax().... so its evaluated first and NegaMax changes the Values of PlayOut and EVA but in some cases the value of PlayOut become 0 at the end of the board ... I should check first whether PlayOut is zero or not
unfortunately I know nothing about object oriented programming I'm still beginner .. but I will learn :D
If you want to continue to develop more complex video games on C++
yeah I want to .. I will learn first more about C++ cuz I'm not fully acquainted with it then I'll start with OpenGl
C++ is a great language, and object oriented programming is very important. However for beginners it might be very intimidating learning object oriented programming rules. Truth is that you only really need a small portion of these rules :). If you understand how to make classes/constructors/destructors/inheriting/and polymorphism. Then you will be able to make most designs out there.
however only knowing classes and their constructors will be plenty sufficient for programming games.
OpenGL is a VERY advanced library, famously known for being very hard to begin in, you need many math skills. good luck with that :)