My current project is to write a connect 4 program. It will have an inbuilt computer that plays you, and the end goal is to have it play a friend of mine’s computer and see who is the better programmer! In my code, I have a function that detects lines of two, then three and ultimately, four. You will notice a huge comment in my computer: this is because I had a method but realised that I had already written a function to do just that. Now I create an imaginary board, and then say “If they place their counter there, have they won? If so, put your counter there and if not select an attack”. The board is a two dimensional array so we can’t just copy it, we have to copy each element of it as if we used board.copy()
then it would copy only the top list so the x would become unique but crucially the y would not. You might notice my current attack algorithm is to guess randomly – it is a work in progress!