vendredi 22 janvier 2016

java - Algorithm for generating random path on 2d array

I'm trying to write an algorithm that will generate a random path on a 2d array from (0, 0) to (maplength-1, maplength-1), but not a path that looks like this:

R R O O O
O R R R O
O O O R R
O O O O R
O O O O R

But I want to generate a random path with random directions, such as:

____\
XX/_/
XX|XX
/_/XX
\____

Where _, |, /, and \ are paths, and X is not.

Basically my algorithm is suppose to do the second thing but I don't even know where to start! I never wrote something like this and don't know what to do.

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire