盲盒转盘优化-重构-调试
This commit is contained in:
@@ -392,6 +392,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
*/
|
||||
private function buildAliasTable($gifts)
|
||||
{
|
||||
print_r($gifts);die;
|
||||
$n = count($gifts);
|
||||
if ($n === 0) return null;
|
||||
|
||||
@@ -407,6 +408,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
|
||||
// 归一化概率并填充索引映射
|
||||
foreach ($gifts as $i => $gift) {
|
||||
if ($gift['remaining_number'] <= 0) continue;
|
||||
$indexMap[$i] = $gift;
|
||||
$prob[$i] = $gift['remaining_number'] * $n / $totalRemaining;
|
||||
if ($prob[$i] < 1.0) {
|
||||
|
||||
Reference in New Issue
Block a user