Selaa lähdekoodia

fix randomnes

Harry de Boer 10 vuotta sitten
vanhempi
commit
1ad4ab342a
1 muutettua tiedostoa jossa 5 lisäystä ja 12 poistoa
  1. 5 12
      board/board.go

+ 5 - 12
board/board.go

@@ -38,7 +38,7 @@ func New(width, height int) *Board {
 }
 
 func NewPartial(startX, startY, width, height, totalWidth, totalHeight int) *Board {
-	r := rand.New(rand.NewSource(time.Now().UnixNano()))
+	r := rand.New(rand.NewSource(time.Now().UnixNano() + int64(startY+startY)))
 	return newPartial(startX, startY, width, height, totalWidth, totalHeight, r)
 }
 
@@ -47,8 +47,8 @@ func NewRemote(width, height int) *Board {
 
 	log.Printf("Start creating board %v x %v", width, height)
 
-	regionWidth := 16
-	regionHeight := 16
+	const regionWidth = 32
+	const regionHeight = 32
 
 	regionWidthNum := (width + (regionWidth - 1)) / regionWidth
 	regionHeightNum := (height + (regionHeight - 1)) / regionHeight
@@ -85,18 +85,11 @@ func NewRemote(width, height int) *Board {
 
 	answers := 0
 	for regionWidthNum*regionHeightNum > answers {
-
 		result := <-returnChan
-
-		fmt.Printf("Received partial: x=%v, y=%v, width=%v, height=%v\n", result.x, result.y, result.width, result.height)
+		log.Printf("Received partial: x=%v, y=%v, width=%v, height=%v\n", result.x, result.y, result.width, result.height)
 		for ry := 0; ry < result.height; ry++ {
-			i, _ := b.xyToIndex(result.x, result.y + ry)
-			fmt.Printf("index=%v\n", i)
+			i, _ := b.xyToIndex(result.x, result.y+ry)
 			result.boardTile.Read(b.data[i : i+byteIndex(result.width)])
-			for _, v := range b.data[i : i+byteIndex(result.width)] {
-				fmt.Printf("%b ", v)
-			}
-			fmt.Println()
 		}
 		answers++
 	}