Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Game of dicks

Name: Anonymous 2009-12-06 13:11


live() {
 for(int i = 0; i < w; i++) {
 for(int j = 0; j < h; j++) {
  n[i][j] = neighbours(i,j);
  board[i][j] =
   board[i][j]
    ? (n[i][j] == 2 || n[i][j] == 2)
    : (n[i][j] == 3)
 }
 }


motherfuckers, I can't get my game of life working. Help me you assholes. live is meant to do one iteration but it's fucked up somehow.

Name: Anonymous 2009-12-06 13:11

}

Fixed.

Name: Anonymous 2009-12-06 13:12

>>2
fuck off asshole, that was just a typo. The thing is still buggy. How about you tell me why instead of being such a pathetic shitbag.

Name: Anonymous 2009-12-06 13:21

(n[i][j] == 2 || n[i][j] == 2)
( ≖‿≖)

Name: Anonymous 2009-12-06 13:30

I'm going to assume that w, h, and n are defined outside of this function.

"board[i][j] =
"   board[i][j]
"    ? (n[i][j] == 2 || n[i][j] == 2)
"    : (n[i][j] == 3)"
I know what you're trying to do, but I have no clue what you're doing.  I'm assuming that board is boolean, so then why are you assigning the value of 2 or 3 to it?  And what's with that || in the THEN position?

Name: Anonymous 2009-12-06 13:36

>>1
Stop being such a pissy dick and you'll get proper help

This isn't /g/

Name: Anonymous 2009-12-06 13:54

make a new board for each generation, populate it according to the old board, repeat

Name: Anonymous 2009-12-06 13:59

>>7
/prog1/,/prog2/,/prog3/...

Name: Anonymous 2009-12-06 23:02

(n[i][g] == 2 || n[i][g] == 2)

Name: Anonymous 2009-12-07 0:24

>>5
it would be the stupidest ass way to set n[i][j] to 1 if it's 2, if that's the idea

Name: Anonymous 2009-12-07 0:30

( °∀°)We're having an Endless Eight marathon, and later we're going to play Conway's Game of Life!

Name: Anonymous 2009-12-07 0:48

>>11
wat is this. is random, me like.

Name: Anonymous 2009-12-07 1:02

>>12
I'm 12 years old and what is this

Name: Anonymous 2009-12-07 1:03

>>11
Congratulations, you have invented the most boring party ever

Name: Anonymous 2009-12-07 4:10

>>11
Buzz Killington, please log in.

Name: Anonymous 2009-12-07 12:04

>>15
/prog/ - /b/

Name: Anonymous 2009-12-07 12:05

FUNNY HOW IN A DIGITAL WORLD WE STILL RUN OUT OF "PAPER"

Name: Anonymous 2009-12-07 16:26


live() {
 for(int i = 0; i < w; i++) {
 for(int j = 0; j < h; j++) {
  n[i][j] = neighbours(i,j);
  board[i][j] =
   board[i][j]
    ? (n[i][j] == 2 || n[i][j] == 3)
    : (n[i][j] == 3)
 }
 }
}


it stilul doesn't work fuckshits

Name: Anonymous 2009-12-07 16:34

>>18
No shit. Maybe you should stop pretending to be a programmer.

Name: Anonymous 2009-12-07 17:16

Write valid C and I'll help you.  Faggot.

Name: Anonymous 2009-12-07 17:33

>>18
board[i][j] ? (n[i][j] == 2 || n[i][j] == 3) : (n[i][j] == 3)

what the fuck are you doing here? are you sure you fully grasp the ? operator?

Name: Anonymous 2009-12-07 17:49

>>21
I think you don't quite grasp what the code does.

Name: Anonymous 2009-12-07 17:50

>>21
That's not the problem; that's valid. The solution to the actual problem is to split live() into two passes: completely calculate the amount of neighbours each cell has, then calculate if the cells live or die.

I am assuming that neighbours(i,j) looks at the 8 cells surrounding board[i][j]. If you intertwine neighbour cell counting with destructively updating the board, the neighbour counts will be wrong because when neighbours(i,j) accesses the board[i-1][j-1] it will be accessing the new value, when it should be accessing the old value.

Name: Anonymous 2009-12-07 17:59

>>23
The problem is that OP should be using double buffering and not store the neighbour count at any time.

Name: Anonymous 2009-12-07 18:03

DOUBLE BUFFER MY ANUS

Name: Anonymous 2009-12-07 18:08

>>25
That would prevent anal tearing!

Name: Anonymous 2009-12-07 18:33

That would prevent Anal Touring from tearing my anus!

Name: Anonymous 2009-12-07 18:41

Name: Anonymous 2009-12-07 19:49

ITT HELP AN ANUS.

Name: Anonymous 2009-12-08 5:27

HELP AN ANUS.

Name: Anonymous 2009-12-08 5:37

>>25-30
Shut up.

Name: sage 2009-12-08 10:26

>>31,32
Shut up.

Name: Anonymous 2009-12-08 11:15

>>33-1000
This thread has been threadstopped, you can't reply anymore

Name: Anonymous 2009-12-08 11:55

dicks

Name: Anonymous 2009-12-08 14:07

* crickets chirping *

Name: Anonymous 2009-12-08 14:19

This thread has been threadstopped, you can't crickets anymore

Name: Anonymous 2009-12-08 14:36

>>18
I still say your problem must have to do with the initialization of your variables w, h, or the arrays board and n.  Or neighbours(in, int) just doesn't work like you think it does at some point.

>>21
It's like this.  Just remember that board is a boolean array.

if(board[i][j])
{
   board[i][j] = (n[i][j] == 2 || n[i][j] == 3);
}
else
{
   board[i][j] = (n[i][j] == 3);
}

Name: Anonymous 2009-12-08 14:55

EVERYTHING HAS ALREADY BEEN ANSWERED IN >>24 BECAUSE I WROTE IT

Name: Anonymous 2009-12-08 15:23

>>38
ANSWER MY ANUS

Name: Anonymous 2009-12-10 16:05

anyone got a tip this is due today

Name: Sage Master Sage 2009-12-10 16:10

>>40
Tip: Do your own fucking homework.

Name: Anonymous 2009-12-10 16:15

>>1
You didn't explain any other part of the program, so who knows or cares what's wrong.

Name: Anonymous 2009-12-10 16:18

>>24
actually in already answered it in >>7

Name: Anonymous 2009-12-10 17:07

>>43
In >>7 you're implying creating a new board for each generations, so that the memory cost of your solution is O(n). My proposition in >>24 has a memory cost of O(1).

Name: Anonymous 2009-12-10 17:15

>>44
If you discard the boards when you are finished with them, they should be functionally equivalent. Later, if you wanted to, for example, play back the game, then >>7s solution is better. For a simple first go, I'd double buffer, as you suggested.

Don't change these.
Name: Email:
Entire Thread Thread List