I'm trying to generate a random number from 0 to 3 for each direction - n, e, s, w. Whatever the previous direction was in the recursive function can't be used again, and I'm trying to figure out the best way to do that. I'd also like to avoid using mutables. Below is what I have so far and it will work but I'm sure there is a better way to do this...
open System
let width = Console.WindowWidth
let height = Console.WindowHeight
let (map: int[,]) = Array2D.zeroCreate width height
let random = Random()
let main x y d =
let mutable nd = random.Next(4)
while nd = d do
nd <- random.Next(4)
Aucun commentaire:
Enregistrer un commentaire