AUTHOR

ok seriously, need C++ help. do you know what to d

What would the algorithm look like for this:

Thefind_random_directionFunction [3points> This function has 1 parameter. This parameter should equal 1 if you are currently
on the top row, 2 if you are on the middle row, and 3 if you are on the bottom row.
It returns either 1, 2, or 3, to indicate a move in the up-right, down-right, or right direction, respectively. The choice between the 3 possibilities is random, but only a valid move should be returned.
id this for a school project
Usually when I put in parameters they're something like:

trailblaze(start_row, dem, dem_size, path_kind):

and like start_row is a parameter. I don't understand the first one. Smiley
Hossington quote:
id this for a school project
yeah. Smiley
konami code
hmm.
int iSecret;

/* initialize random seed: */
srand ( time(NULL) );

/* generate secret number: */
iSecret = rand() % 3 + 1;

now just return iSecret and you're done.
yaafi quote:
Usually when I put in parameters they're something like:

trailblaze(start_row, dem, dem_size, path_kind):

and like start_row is a parameter. I don't understand the first one. Smiley
wait, so, the function returns what row it's on, so it's an int returning function? Just trying to gather info here.
well i guess you have to check your current position, as well
FriendZone quote:
well i guess you have to check your current position, as well
I do. But the thing has like 50 rows and columns...


so I don't understand top, middle, bottom. Are all 2-49 rows "middle"?
FriendZone quote:
int iSecret;

/* initialize random seed: */
srand ( time(NULL) );

/* generate secret number: */
iSecret = rand() % 3 + 1;

now just return iSecret and you're done.
So wait...you can get a random seed AND a random number without inputting anything?
yaafi quote:
I do. But the thing has like 50 rows and columns...


so I don't understand top, middle, bottom. Are all 2-49 rows "middle"?
I'd break it into equal sections somehow.
FriendZone quote:
I'd break it into equal sections somehow.
well the problem with the top and bottom rows is the fact i can't move up on the top row/bottom on the bottom row. Smiley
yaafi quote:
So wait...you can get a random seed AND a random number without inputting anything?
Yes. For random number generation(based on system time) *srand time* all you have to do is define parameters

I mean, you can substitute in parameters, I guess like

int iSecret, max;
max = 3;
iSecret = rand() % max + 1;
yaafi quote:
well the problem with the top and bottom rows is the fact i can't move up on the top row/bottom on the bottom row. Smiley
then that's your answer, if you can go up or down, then you're in the middle.
FriendZone quote:
Yes. For random number generation(based on system time) *srand time* all you have to do is define parameters

I mean, you can substitute in parameters, I guess like

int iSecret, max;
max = 3;
iSecret = rand() % max + 1;
c# is just srand.Next(int start, int max);
yaafi quote:
well the problem with the top and bottom rows is the fact i can't move up on the top row/bottom on the bottom row. Smiley
pass in currPosition and if statement the fuck out of it

i mean, with only three possible positions it isn't much of a 'random' thing at all.
FriendZone quote:
Yes. For random number generation(based on system time) *srand time* all you have to do is define parameters

I mean, you can substitute in parameters, I guess like

int iSecret, max;
max = 3;
iSecret = rand() % max + 1;
can you explain isecret to me? is that just a random name you chose?
yaafi quote:
can you explain isecret to me? is that just a random name you chose?
yeah, just a random name i chose.
FriendZone quote:
pass in currPosition and if statement the fuck out of it

i mean, with only three possible positions it isn't much of a 'random' thing at all.
so basically if path_start = array[0>[0>
position = 1

if path_start = array[max>[0>
position = 3

else position = 2


???

Quick reply

Sign in to post a message.
Smileys

Times shown in Eastern Time (ET).