Connect 4 – Week 6 (26.09 – 02.10)


This week we made a presentation to show all the groups and teachers our progress. In this presentation we showed a few versions of some components and why we needed to change them.

This week, we also set up Johannes’ Rasperry Pi B+ with Rasperry Pi OS. We used the lite version without desktop environment, because this isn’t needed as we only want to run few python scripts. We enabled ssh access so we can use the terminal without having a keyboard or mouse attached to the Rasperry. After some more basic configuration like keyboard layout, passwords, hostname, internet connection – we also installed some packages over apt-get:
– samba server (file access via Windows file share possible with that)
– git
– python 3 with pip
– i2c stuff (for the display, that will get connected via i2c)
With pip we also already downloaded some python packages:
– rpi-ws281x-python (library for led stripes)
– RPi.GPIO (basic connection via gpios, needed for photoresistors later)
– numpy (for our algorithm software)
– rpi-lcd
Next week is up to try some basic python programs with the hardware components that we already have on the rasperry pi and also our connect 4 software demo (without the KI yet).
About the software demo is to say that it checks also now if somebody won. This works with checking the complete 2×2 matrix / array if there are four times the same numbers side by side. The player coins have has the number “1” and the computer coins “-1” (you can change the value because we declared a global variable for that – no magic numbers…).

Array of the gameboard, with “0” equals empty, “1” player coin and “-1” computer coins.

So there are few for loops that goes over the matrix for checking the amount of same numbers side by side. For horizontal, vertical, diagonal positive and diagonal negative and if there are four side by side it returns True.

The code for the check of win, you hand over your game board and which coin you want to check for win.

Fabian worked on the algorithm this week, with the literature we are on a good way to get a really good working strong KI for the game.

We also made some components for the coin pusher part of the machine. We made some brackets to hold the servo motor for pushing the coin into the game. The profile for guiding the pusher part was also made.

, ,

Leave a Reply