Thank you man! I struggled with this thing for a long time and now this damn thing works
@PunmasterSTP2 жыл бұрын
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 Жыл бұрын
Glad you enjoyed it!
@Bill-s6j2w10 ай бұрын
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.
@PunmasterSTP10 ай бұрын
@@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_you2 жыл бұрын
a quick bitwise test for cell life: alive = (cell | neighbors) == 3; because 0b00 | 0b11 == 0b11 0b01 | 0b11 == 0b11 0b01 | 0b10 == 0b11
@TheBuilder2 жыл бұрын
Do you mind posting an example using these bitwise tests?
@anonymousperson42025 күн бұрын
Why copy a whole array instead of just swapping the addresses the function takes in? Wouldn’t that be faster and more efficient?
@TrioGamesStudio Жыл бұрын
Thank you so much, it works !
@TheBuilder Жыл бұрын
Glad it helped
@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 Жыл бұрын
VS code is telling you that or the compiler?
@naman7906 Жыл бұрын
@@TheBuilder Actually at the terminal. The VS code detects the library just fine
@TheBuilder Жыл бұрын
you need to configure your vs code to recognize your library file location
@qwertywasd751 Жыл бұрын
what changes would I have to make if i wanted to check the edges like a torus?
@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-s6j2w10 ай бұрын
wow, what a super helpful response @@TheBuilder
@anonymousperson42025 күн бұрын
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 Жыл бұрын
Hey I need SDL2/SDL.h header file can you please share that link if possible?
@TheBuilder Жыл бұрын
check the official documentation
@mohammedelgammal721111 ай бұрын
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 Жыл бұрын
where are you running this code?
@TheBuilder Жыл бұрын
at 17:15 through my terminal
@meeravali.kocherla Жыл бұрын
@@TheBuilder what editor you are using
@TheBuilder Жыл бұрын
@@meeravali.kocherla vim
@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 Жыл бұрын
make sure the function definition matches the one I have, also make sure you're compiling your code using the c++20 standard
@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 Жыл бұрын
@@AquaDragon6629 Make sure you #include
@Bill-s6j2w10 ай бұрын
this is what happens when a "tutorial" is incomplete.
@Bill-s6j2w10 ай бұрын
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
@TheBuilder10 ай бұрын
Glad you enjoyed it 😀 remember to subscribe for more 👍