I'm a Bioinformatics student and I have to create a battleship game using R with these instructions:
Create a function that: • Creates a 20 by 20 matrix of 0 values • Places in a random position inside the matrix one vector of size 6 and represents it with six consecutive "1" values. This vector will be our ship • Receives two vectors of six values as inputs. X and Y. Both vectors store six values between 1 and 20 and represent coordinates in the matrix • The function returns a vector with six values depending if the coordinates have hit or miss our ship. Example=("hit", "miss", "miss", "miss", "miss", "hit") Make the number of ships in the matrix a parameter given by the user and export the matrix to a text file.
I find difficult to create multiples random vectors.
Aucun commentaire:
Enregistrer un commentaire