Python Simulation Tutorial - Conway's Game of Life

preview_player
Показать описание
Today, I am going to show you how to create the famous simulation known as "Conway's Game of Life", a cellular automation devised by John Horton Conway in 1970. We are going to build it in Python using Pygame in less than 1 hour!

🎓 *Premium Courses*

🎓 *Free Courses*

🎞 *Video Resources*

⏳ *Timestamps*
00:00 | Overview
01:34 | Taipy
02:37 | Rules Visuals
03:34 | Pygame Install
04:10 | Constants and Setup
06:50 | Writing the Main Loop
09:36 | Drawing The Grid
19:26 | Adding Cells
22:12 | Handling Other Keypresses
26:59 | Updating The Grid

🔗 *Socials*

*Support*

🔖 *Tags*
-Tech with Tim
- Python Programing
- Simulation Tutorial

*Hashtags*
#python
#techwithtim
#pythontutorial
Рекомендации по теме
Комментарии
Автор

I was waiting for you to make Conway's game of life and finally, here it is. Great video! :D

StreakyFly
Автор

Conway's Game of Life has always fascinated me.

Gonna work through this in the morning. Thanks for this tutorial.

I was able to follow the logic, and it mostly matched the pseudo code I had blocked out. Now I just have to learn more pygame.

bp-obic
Автор

What a concept!
I had been breaking my head to understand the concept & this happens finally. Thank you Tim

esrxa
Автор

fantastic, just the thing i was looking for: python implementation of Conway's Life with clickable nodes

void_presence
Автор

i really like these kind of video please make more of these video i am looking forward for that thank you once again....👏🏻🙌🏻👏🏻

westudy
Автор

Great video. Slight correction as 39+1 can never be > 40 in your example grid. Plus added a wrap-around:

def get_neighbors(pos):
x, y = pos
neighbors = []
for dx in [-1, 0, 1]:
if x + dx < 0:
x += GRID_WIDTH
elif x + dx == GRID_WIDTH:
x -= GRID_WIDTH
for dy in [-1, 0, 1]:
if y + dy < 0:
y += GRID_HEIGHT
elif y + dy == GRID_HEIGHT:
y -= GRID_HEIGHT
if dx == 0 and dy == 0:
continue

neighbors.append((x + dx, y + dy))

return neighbors

crescent
Автор

thank you for the tutorial works perfectly fine !

eNitx
Автор

It is working perfectly well! Thank you Tim.
However, please note that on line 21 of the code, you should invert GRID_WIDTH and GRID_HEIGHT for correct random position generation, especially for different screen width and height.

NicolasFleury-wwut
Автор

Very interesting - great code as usual. Thanks !

paulthomas
Автор

Didn't realise set() data structure and methods were so useful.

BsktImp
Автор

Hii, really useful video... like always :)

pathapativarshitha
Автор

Thanks bro, otherwise I ran into a bunch of bugs when developing the game "life" on my game engine.

programm_mister
Автор

Hi tim, I want to simulate how an object of certain pounds would react on the different planets with different gravity.. kindly make a video if possible.. regards:)

MrMysterious
Автор

I had to recreate this in Java for school. Sucked. lol

foqsi_
Автор

heloo sir can u create a digitmatch that can predict the last number randomly for example entry spot 12345 the last is 5 then the last exit result lexit spot
is 5 also can u make it this sir?

Digital_Anime_Creator
Автор

can you make a tutorial on reflex or pynecone

miichanshi
Автор

Hey. I followed the tutorial and everything works until I try to run the simulation. I get the error "not enough values to unpack (expected 2, got 1)" at line 58 (x, y = pos in the get_neighbors function)
Any idea why this happens and how to fix it?

thiccbum
Автор

How Can i make simulation like Project jdm and math Floyd can you make a video or tell me where to start

Carhell
Автор

Hi. What PyCharm theme are you using here?

elenasavchenkova
Автор

Does anyone please have a version of this code with ezgraphics?

jerryedept