How to Program Connect 4 in Python! (part 1) - Basic Structure & Game Loop

preview_player
Показать описание
This is the first part of a few part series on how to program connect 4 in python 3 and pygame. In this video I show you how to store the board state, and build a simple command line interface for dropping pieces. The next video will show you how to write a function to check for wins. Then after that the final video will build graphics for your game.

Part 2:

Full Game Source Code:

INSTALLATION LINKS:

Link to setup Python 3 and Sublime text:

Link to setup SublimeREPL:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PYTHON TUTORIAL SERIES:

-------------------------
Follow me on social media!

-------------------------

Learn data skills with hands-on exercises & tutorials at Datacamp!

*I use affiliate links on the products that I recommend. I may earn a purchase commission or a referral bonus from the usage of these links.
Рекомендации по теме
Комментарии
Автор

Thanks for covering this material from multiple perspectives. I appreciate keeping "AI" out of the first video, and even sticking with text-mode with showing under the hood, and only at the end introducing the graphical presentation.

Also - it's good that you've since fixed your recording levels. I went from this video (volume adjusted) then went to your Channel and almost blew my speakers lol

thisisreallyme
Автор

Thanks for this really good explanation. One tiny bit you could do even better is to show the program code at the left side and the running program at the right side of the screen. This would allow the viewers to pause the video and see both the code and its effects at the same time.

RolandIllig
Автор

GREAT series, and thank you thank you thank you for revising each Description so there's both a Forward and Backwards link in the text. (So many never do this!)

I especially like that you implement as a pure text game first, before going to graphics.

thisisreallyme
Автор

Hi! Very good tutorial! Though it would have helped if you would have maybe made the volume louder...

himankgupta
Автор

astounding content Keith Galli. I broke that thumbs up on your video. Keep on up the exceptional work.

KeyserTheRedBeard
Автор

very nice video, the way you struct your program is very natural, i mean a lot of people just following their paperwork, or source code, top to the bottom, which is very hard to understand and follow. hope see more tutorials from you. thank you

xerexsimpleprogramming
Автор

How do I create the same board without using numpy?

ikilos
Автор

Great Tutorial... Greetings from Mexico.

guadalupetiendalopez
Автор

Hi do you have any idea to change the turn in a function instead? I tried putting turn = 1, then turn += 1 and turn = % 2 in my move function but it does not change to turn 2 and player 2.

jisunghan
Автор

Hi. Great tutorials. Thanks for making them. Can this also be done in Replit for students working on Chromebooks?

WUHSMS
Автор

thank you so much for this video its helped a lot. your explanation is very clear and good.you are the best. a saver.

kaverirv
Автор

for the get_next_open_row function it can be implemented like this:

def get_next_open_row(board, col):
for row in reversed(range(ROW_COUNT)):
if board[row][col] == 0:
return row
This checks from the bottom up instead of the top down.

mejiab
Автор

hey are you using 2D arrays to make this connect 4 game?

haidersarmad
Автор

Hi do you have any idea how to program an AI for the game??For example, it will look for all potential moves that lead to a win itself or block a direct move for the player to win

ngguanzhi
Автор

thanks for this videos, very good, can you make a tutorial on color lines game? im trying to write it long time, still no luck.

mensiuscho
Автор

Hi do you know why numpty doesn't work with Sublime REPL?

chocolatefountainfarm
Автор

does row have to equal anything cuz I'm getting the error row is undifined
row = ?

adatderrt
Автор

Does selection = input(...) work with atom? or regular python console?

asleeperj
Автор

Hey man, are you the same Keith that the one that program python scripts for MODO?

CentboyMidnight
Автор

How do you make the inputs to pass(drop) to the bottom row of the board

jackolson
welcome to shbcf.ru