Conway's Game of Life 👨‍💻 C++ Project

  Рет қаралды 16,945

The Builder

The Builder

Күн бұрын

Пікірлер: 32
@artyomkazakov9414
@artyomkazakov9414 Жыл бұрын
Thank you man! I struggled with this thing for a long time and now this damn thing works
@PunmasterSTP
@PunmasterSTP 2 жыл бұрын
I think it’s amazing to see how widely Conway’s Game of Life has been shared. This was another great video, and thanks for posting it!
@TheBuilder
@TheBuilder Жыл бұрын
Glad you enjoyed it!
@Bill-s6j2w
@Bill-s6j2w 10 ай бұрын
what about it was "great"? It's repetitious, the provided algorithm is awful, no discussion of drawing to screen. there is no way that I would be pointing anyone to this resource as a learning tool.
@PunmasterSTP
@PunmasterSTP 10 ай бұрын
@@Bill-s6j2w Maybe it’s not the best video ever, but I still enjoyed watching it and wanted to leave a comment.
@omg_look_behind_you
@omg_look_behind_you 2 жыл бұрын
a quick bitwise test for cell life: alive = (cell | neighbors) == 3; because 0b00 | 0b11 == 0b11 0b01 | 0b11 == 0b11 0b01 | 0b10 == 0b11
@TheBuilder
@TheBuilder 2 жыл бұрын
Do you mind posting an example using these bitwise tests?
@anonymousperson420
@anonymousperson420 25 күн бұрын
Why copy a whole array instead of just swapping the addresses the function takes in? Wouldn’t that be faster and more efficient?
@TrioGamesStudio
@TrioGamesStudio Жыл бұрын
Thank you so much, it works !
@TheBuilder
@TheBuilder Жыл бұрын
Glad it helped
@naman7906
@naman7906 Жыл бұрын
Hey, I tried running your screen.h header file on the newest version of SDL2 in vs code. It shows SDL2/SDL.h header file not found in the directory even though it is present there included in the path and the SDL2 library works fine for the other project.
@TheBuilder
@TheBuilder Жыл бұрын
VS code is telling you that or the compiler?
@naman7906
@naman7906 Жыл бұрын
@@TheBuilder Actually at the terminal. The VS code detects the library just fine
@TheBuilder
@TheBuilder Жыл бұрын
you need to configure your vs code to recognize your library file location
@qwertywasd751
@qwertywasd751 Жыл бұрын
what changes would I have to make if i wanted to check the edges like a torus?
@TheBuilder
@TheBuilder Жыл бұрын
if you want to wrap the picture to a torus, you'd just generate the texture then apply it to a torus model
@Bill-s6j2w
@Bill-s6j2w 10 ай бұрын
wow, what a super helpful response @@TheBuilder
@anonymousperson420
@anonymousperson420 25 күн бұрын
When working with cell addresses, use modulo. I.E. to get cell neighbor cell-1, use (cell+(width-1))%width, this wraps around by adding the width minus one then modulo. Going to the right is simpler (cell+1)%width. Then repeat for the other axis. This allows wrapping without overflow.
@meeravali.kocherla
@meeravali.kocherla Жыл бұрын
Hey I need SDL2/SDL.h header file can you please share that link if possible?
@TheBuilder
@TheBuilder Жыл бұрын
check the official documentation
@mohammedelgammal7211
@mohammedelgammal7211 11 ай бұрын
Great tutorial! Here is more efficient version without extra memory space SC O(1): void updateScreen(G &screen) { screen.update(); SDL_Delay(100); screen.input(); screen.clearpixels(); } int main() { G screen; int h = 640, w = 480; vector display(h, vector(w, 0)); for (vector &r : display) generate(r.begin(), r.end(), []() -> int { return rand() % 10 % 2; }); while (true) { for (int r = 0; r < h; r++) for (int c = 0; c < w; c++) { int ln = 0; for (int i = r - 1; i = w || (i == r && j == c)) continue; if (display[i][j] == 1 || display[i][j] == 3) ln++; } if (display[r][c] == 0 && ln == 3) display[r][c] = 2; if (display[r][c] == 1) { if (ln < 2 || ln > 3) display[r][c] = 3; screen.drawpixel(r, c); } } updateScreen(screen); for (int r = 0; r < h; r++) for (int c = 0; c < w; c++) { if (display[r][c] == 2) { display[r][c] = 1; screen.drawpixel(r, c); } if (display[r][c] == 3) display[r][c] = 0; } updateScreen(screen); } }
@meeravali.kocherla
@meeravali.kocherla Жыл бұрын
where are you running this code?
@TheBuilder
@TheBuilder Жыл бұрын
at 17:15 through my terminal
@meeravali.kocherla
@meeravali.kocherla Жыл бұрын
@@TheBuilder what editor you are using
@TheBuilder
@TheBuilder Жыл бұрын
@@meeravali.kocherla vim
@AquaDragon6629
@AquaDragon6629 Жыл бұрын
Ok, so i don't know if im being really dumb, or if some super important stuff has been missed out.. but what is game? Every time i try to use game[][] it tells me "no operator "[]" matches these operands" And also, my two arrays for display and swap are both telling me "incomplete type is not allowed" and "local variable is not initialised". Any help?
@TheBuilder
@TheBuilder Жыл бұрын
make sure the function definition matches the one I have, also make sure you're compiling your code using the c++20 standard
@AquaDragon6629
@AquaDragon6629 Жыл бұрын
@@TheBuilder So, my code is exactly the same as yours, and I've updated my compiler to c++20. But I'm still getting the same issues. I can't figure out the issue
@Fidelity_Investments
@Fidelity_Investments Жыл бұрын
@@AquaDragon6629 Make sure you #include
@Bill-s6j2w
@Bill-s6j2w 10 ай бұрын
this is what happens when a "tutorial" is incomplete.
@Bill-s6j2w
@Bill-s6j2w 10 ай бұрын
why is it that all tutorials spend ages going over the same thing again and again when that thing is really not complicated to understand ... for example: don't test an item outside of the array's upper and lower bounds. Why say the same thing so many times: say it once ... we are testing this cell, which has these neighbours. That's all it takes, if anyone cannot understand that then they really should not be trying to code anything, let alone Conway's Game of Life. Also, what an awful "algorithm" for life testing You've spent ages going over the same thing multiple times, which really doesn't advance understanding: and yet the important part (drawing the game to the screen) you've just glossed over with "oh, if you need this it's in a repo somewhere, otherwise, well it's not too difficult" Do you think coding the Game of Life is difficult? so why TRY to teach that and not the part about writing to screen
@TheBuilder
@TheBuilder 10 ай бұрын
Glad you enjoyed it 😀 remember to subscribe for more 👍
Let’s BUILD a COMPUTER in CONWAY's GAME of LIFE ⠠⠵
23:33
Alan Zucconi
Рет қаралды 1 МЛН
Will A Basketball Boat Hold My Weight?
00:30
MrBeast
Рет қаралды 128 МЛН
ЗНАЛИ? ТОЛЬКО ОАЭ 🤫
00:13
Сам себе сушист
Рет қаралды 3,7 МЛН
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 104 МЛН
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 273 М.
Inventing Game of Life (John Conway) - Numberphile
11:05
Numberphile
Рет қаралды 1,1 МЛН
epic conway's game of life
6:33
Rational Animations
Рет қаралды 5 МЛН
Coding Challenge #85: The Game of Life
38:20
The Coding Train
Рет қаралды 689 М.
Coding Challenge #14: Fractal Trees - Recursive
15:53
The Coding Train
Рет қаралды 892 М.
3D Graphics With Draw Pixel - Rotating Cube SDL2 C++ Project
41:09
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Рет қаралды 1,2 МЛН
Refactoring Conway's Game of Life | ArjanCodes Code Roast
31:49
ArjanCodes
Рет қаралды 29 М.
ASMR Programming - Spinning Cube - No Talking
20:45
Servet Gulnaroglu
Рет қаралды 4,1 МЛН
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 826 М.
Will A Basketball Boat Hold My Weight?
00:30
MrBeast
Рет қаралды 128 МЛН