// Generate random bloodline and random percentage func rBarP() ([]int, []float64) {…
- User
// Generate random bloodline and random percentage func rBarP() ([]int, []float64) { const total = 100.0 rP := make([]float64, 100) sum := 0.0 for i := range rP { rP[i] = rand.Float64() sum += rP[i] } for i := range rP { rP[i] = r3dp((rP[i] / sum) * total) } rB := make([]int, 100) for i := range rB { rB[i] = i + 1 } return rB, rP } // Find the bloodlineID with the highest bloodline percentage func fhBID(rB []int, percentages []float64) int { hBID := 0 for i := 1; i < len(percentages); i++ { if percentages[i] > percentages[hBID] { hBID = i } } return rB[hBID] } // Generate random NPC func gNPC() []interface{} { // Random bloodlineIDs and bloodline percentages BID, BP := rBarP() maxID := fhBID(BID, BP) tlS, thS, wS, aS := dtlSthSwSaS(fsg1, fsg2, maxID) for i := range BID { out = append(out, BID[i], BP[i]) } out = append(out, maxID) return out I want to change this logic of generating bloodline and percentage. I want to use this logic, (bloodlineIDs 1-100 should all have their percentage as 1.
- Assistant
Got it! You want to change the bloodline percentage generation logic so that each bloodlineID from 1 to 100 has an equal percentage of 1, instead of random floats normalized to sum 100.
Here’s how you can update the function
rBarPto return each bloodlineID with percentage = 1:gofunc rBarP() ([]int, []float64) { const totalBloodlines = 100 rB := make([]int, totalBloodlines) rP := make([]float64, totalBloodlines) for i := 0; i < totalBloodlines; i++ { rB[i] = i + 1 // bloodlineID from 1 to 100 rP[i] = 1.0 // percentage set to 1 } return rB, rP }