Driving Question: Can I code and develop an AI opponent for Connect 4?
Answer: Yes! I successfully programmed a digital game of Connect 4 and an AI opponent for it. To reach this outcome, I had done substantial research to understand AI development. Then, I programmed my Connect 4 game and integrated an AI opponent into it with Python. This process required a lot of testing and debugging to be completed.
Justification essay (emphasizes the development process = project journal)
(Intro that breifs the point of the essay and the evidence I will provide)
To support my answer to the driving question, the main evidence that proves that I built a Connect 4 Ai opponent is my weekly project journal that recounted every step of the development prosses. This includes an entry that has a video recording of me running the program. You can find this video in the Week 17 Final deliverable, labeled as “FINAL RECORDING, RUNNING CODE.” This video and the entire project journal proves that the program I had made for my SSP reached the goal set by my driving question because it, one, looks, plays, and was engineered to be indistinguishable to the real Connect 4 board game, and, two, it contains a functional AI opponent that was programmed and proven by several tests to win or lose against the player while putting up a reasonable challenge. If you look back to my driving question, creating a digital Connect 4 game and then an AI opponent to put inside it was the goal outlined in the question, and as you will see why in the following, I did exactly that. Thus, it will be understood how my answer to the driving question is completely justified.
(My steps and efforts to build the project that justify how it addresses the driving question)
Firstly, my final deliverable and week 9 to week 13 of the project journal show that my Connect 4 program is and functions exactly like the original board game since it mirrors all of Connect 4’s basic elements. For for instance, durring week 9, when I began programming the User Interface of the Connect 4 platform, I planned it so that, just like the original connect 4 game, you'd play on a blue, 6 by 7 grid with red and yellow pieces in the shape of disks. I learned how to program this with Python in weeks 10 to 11 thanks to the Youtube video, "Python for beginners - learn python in 1 hour" by Mark Hamedami. Furthermore, just like in the original, my version of the game is turn based and is won when 4 disks are lined up in a continuous row within the blue, 6 by 7 grid. I programed this game mechanic after developing the game's User Interface and watching "How to get started with Machine Learning & Ai" by the youtube channel Tech with Tim. Programing the parameters for the game's win condition, 4 disks in a row, was done by incorporating functions that were defined by boolean expressions and by integrating APIs in weeks 12 to 13. Again, most of these skills were developed by watching "Python for beginners - learn python in 1 hour" by Mark Hamedami. From these similarities with the original board game, it is clear that what I had digitally developed for my SSP is functionally and visually indistinguishable to the real life Connect 4 board game. Besides the fact that my version is on a computer, the player is always red and always has the first turn, and my game has an AI opponent that is always yellow, there are no other incongruences between the original and the version of Connect 4 I had created. My point here is that the demonstration video and my developmental process show that my programed digital game of Connect 4 shares enough of the core components of the original so as to be immediately recognizable as Connect 4 instead of some other game or trademark. Therefore, it is irrefutable that what I developed can be called anything but a game of Connect 4, which is what my driving question askes for.
Secondly, Weeks 14 to 17 of my project journal which includes my Final Deliverable will demonstrate that my AI model is a successful opponent by being able to win and lose Connect 4 while putting up a reasonable challenge. What this means is that my AI has the ability to respond to moves that a player makes with moves that put it in a strategic advantage. This is a characteristic that my AI has as a result of me incorporating the Mini max search algorithm into the cornerstone of its source code during week 14 to 15 of the project. For some background, a search algorithm is a program that drives the decision making process of an Ai, and a Mini max algorithm is a search algorithm that looks ahead at potential board states in the future to end a game with the most favorable outcome for the Ai. In the initial stages of my project, spanning weeks 1 through 8, I extensively researched various algorithms and ultimately chose to implement the Mini-max algorithm, drawing inspiration from my research in CS50Ai. As my project progressed into its final development phase, encompassing weeks 14 to 17, I seamlessly integrated the Mini-max algorithm into my program and commenced rigorous testing procedures. In the context of my digital Connect 4 game project, the Mini-max AI model basically forms my AI opponent, so It is important to understand how it works. Again, a Mini-max algorithm is one of many problem-solving, adversarial thought processes that an AI programmer can bake into their AI. Mini-max works by considering possible configurations a game board can take from the current state that the game board is in. Then, after designating a winning game board under the numerical figure “1”, a tied game board under the numerical figure “0.5”, and a losing game board under the numerical figure “0”, the AI under a Mini-max algorithm will make moves that follow the possible game board configurations that it sees will result in the ending game board with the highest numerical figure, either a “1” or a “0.5”, which is either a win or a tie. Therefore, under these parameters set by the Mini-max model, my AI, like I sort of said before, always attempts to respond to moves that the player makes with moves that will bring it closer to the winning scenario, and throughout my demonstration video of my program in Week 17’s Final Deliverable, you actually see this pattern in the AI’s actions. Because of this pattern, the video shows the AI actually beating me in Connect 4 during one round. It is mainly because of the Minimax algorithm's combative nature, which is baked into its design, as I explained earlier, that my AI opponent is able to win and lose at Connect 4 while providing a reasonable challenge, thus fulfilling the condition set by my driving question. All in all, the theoretical evidence of how the minimax algorithm makes my Ai inclined to try to beat the player and all of the demonstration evidence of how my product ended up with a functioning Connect 4 Ai opponent is shown in my project journal’s week 14 to week 17 entries. Thus, there is ample evidence supporting that my AI model is indeed a successful opponent by being able to win and lose Connect 4 while putting up a reasonable challenge.
(The project that resulted from my efforts)
In conclusion, after building the first half of my project, the Connect 4 game supported by weeks 9 to 13 in the project journal, and then the second half of my project, the Artificial Intelligence opponent supported by weeks 14 to 17 in the project journal, I had my completed product. At first glance, it looked like your ordinary computer Connect 4 game. However, once you booted up the program and placed down your first disc as red with the computer mouse, a yellow disk is automatically placed in response, now making it your turn. The yellow disk that was 'magically' placed was controlled and guided by the AI opponent who decided its move through the minimax algorithm. In the end, that process continues until either you or the AI opponent wins. Again, in weeks 9 to 13, I made sure everything, including the win condition is the same as in the real Connect 4 (4 disks in a row). Also, when the player wins, the game stops and says 'red wins.' If the AI opponent wins, it says 'yellow wins.' Afterward, the game resets to be played again. That is the entirety of the program I developed, and as explained before, it is exactly what the driving question asked for, 'AI opponent for Connect 4.' I successfully developed an AI opponent using the adversarial AI model Minimax, and I programmed a Connect 4 game for the AI to play in.