加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 ppspssss 于 2025-3-4 16:08 编辑
由于此贴为之前电脑有的草稿存档,被我找到出来,但注释的是没有存档,因而没注释 (原贴2024.9.24)
抽卡思想草稿.txt (只是草稿不是脚本)
1 in 1 = 1/2 = 0.5 1 in 20 = 1/20 = 0.05 1 in 100 = 1/100 = 0.01 乘 100 50 5 1 100 + 50 + 1 = 151 抽到105,什么都抽不到? 乘 100 00 50 00 5 00 1 00 $卡池数组 = [ ["1in2"的卡,2],["1in20"的卡,20],["1in3"的卡,100] ] "1in2"的卡范围 = 1/2 = 0.5 "1in20"的卡范围 = 1/20 = 0.05 "1in100"的卡范围 = 1/100 = 0.01 乘 100 00 50 00 5 00 1 00 rand = 10000 + 500 + 100 = 100600 rand 1~5000 = 1, rand 5001~5500 = 2, rand 5501~5600 = 3 $加起来的rand = 0 for i in 0...$卡池数组.size $加起来的rand += ((1/$卡池数组[i][2] ) * 100) end #for "1in2"的卡 1~5000 , "1in20"的卡 5001~5500 , "1in100"的卡 5501~5600 for i in 0...$卡池数组.size for i2 in 0...i 指定数值 += $卡池数组[i][2] end#for i2 $续渐增加的rand数组[i] = 指定数值 end #for i ii = 0 if 0+1 <= $续渐增加的rand数组[ii] ii+=1 elsif $续渐增加的rand数组[ii-1]+1 <= $续渐增加的rand数组[ii] ii+=1 elsif $续渐增加的rand数组[ii-1]+1 <= $续渐增加的rand数组[ii] elsif self = i = 0 需要i2 = 0 i-1 + self i = 1 需要i2 = 0 1 i-1 + i-2 + self i = 2 需要i2 = 0 1 2
1 in 1 = 1/2 = 0.5
1 in 20 = 1/20 = 0.05
1 in 100 = 1/100 = 0.01
乘 100
50
5
1
100 + 50 + 1 = 151
抽到105,什么都抽不到?
乘 100 00
50 00
5 00
1 00
$卡池数组 = [ ["1in2"的卡,2],["1in20"的卡,20],["1in3"的卡,100] ]
"1in2"的卡范围 = 1/2 = 0.5
"1in20"的卡范围 = 1/20 = 0.05
"1in100"的卡范围 = 1/100 = 0.01
乘 100 00
50 00
5 00
1 00
rand = 10000 + 500 + 100 = 100600
rand 1~5000 = 1, rand 5001~5500 = 2, rand 5501~5600 = 3
$加起来的rand = 0
for i in 0...$卡池数组.size
$加起来的rand += ((1/$卡池数组[i][2] ) * 100)
end #for
"1in2"的卡 1~5000 , "1in20"的卡 5001~5500 , "1in100"的卡 5501~5600
for i in 0...$卡池数组.size
for i2 in 0...i
指定数值 += $卡池数组[i][2]
end#for i2
$续渐增加的rand数组[i] = 指定数值
end #for i
ii = 0
if 0+1 <= $续渐增加的rand数组[ii]
ii+=1
elsif $续渐增加的rand数组[ii-1]+1 <= $续渐增加的rand数组[ii]
ii+=1
elsif $续渐增加的rand数组[ii-1]+1 <= $续渐增加的rand数组[ii]
elsif
self = i = 0 需要i2 = 0
i-1 + self i = 1 需要i2 = 0 1
i-1 + i-2 + self i = 2 需要i2 = 0 1 2
原来是模仿roblox动漫抽卡的模拟器,由于那游戏改版变化太多现在很多不一样了 , 所以没什么参考用途 , 也许现在可看看国外其他人写rng的脚本 (我觉得现在不怎么rng游戏流行了吧)
大慨就是挂机抽卡, 奖池越大抽的卡慨率不一样,标示并非实际慨率 ,数字越大代表抽中卡越难,奖池越大抽到想要指定卡也更难,
衍生改进 : 修改奖池卡包, 比如分开几个奖池,可以切换奖池1,奖池2, 指定一个抽而不是全部
加入幸运值:幸运值越大,抽到好卡慨率增大,抽到最差的卡慨率逐渐减少至抽不到为止, 然后到排倒数第2的卡减慨率,加的慨率平均分摊到难抽到的卡
慨率升级卡品质:如1/1000变成金卡,1/10000变成彩虹卡,属性也会相应增加, 如1in 1234的卡会变成 1in 1234000的金卡
脚本(可自行测试看print出来)
#__END__ $卡池数组 = [ ["1in2的卡",2],["1in20的卡",20],["1in100的卡",100] ] $加起来的rand = 0 $续渐增加的rand数组 =[] for i in 0...$卡池数组.size $加起来的rand += ((1.0/$卡池数组[i][1] ) * 10000).to_i #所有随机数加起来的值(非数组) #p $加起来的rand end #for #p $加起来的rand #5600 for i in 0...$卡池数组.size #数组型三个点 指定数值 = 0 for i2 in 0..i #0,1,1,2,2,2 指定数值 += ((1.0/$卡池数组[i2][1] ) * 10000).to_i # p i,i2,指定数值 end#for i2 $续渐增加的rand数组[i] = 指定数值 #压入增加的值 end #for i #p $续渐增加的rand数组 #[5000,5500,5600] rand_get = rand($加起来的rand)+1 for i in 0...$续渐增加的rand数组.size if i ==0 #第一个数组情况下需要等于0,因为没有上一个数组 if rand_get >= 1 and rand_get <= $续渐增加的rand数组[i] p "抽到#{$卡池数组[i][0]}" #抽到该东西 end#if rand_get elsif i >=1 # if rand_get >= ($续渐增加的rand数组[i-1])+1 and rand_get <= $续渐增加的rand数组[i] p "抽到#{$卡池数组[i][0]}" #抽到该东西 end#if rand_get end #if i ==0 end#for
#__END__
$卡池数组 = [ ["1in2的卡",2],["1in20的卡",20],["1in100的卡",100] ]
$加起来的rand = 0
$续渐增加的rand数组 =[]
for i in 0...$卡池数组.size
$加起来的rand += ((1.0/$卡池数组[i][1] ) * 10000).to_i
#所有随机数加起来的值(非数组)
#p $加起来的rand
end #for
#p $加起来的rand #5600
for i in 0...$卡池数组.size #数组型三个点
指定数值 = 0
for i2 in 0..i
#0,1,1,2,2,2
指定数值 += ((1.0/$卡池数组[i2][1] ) * 10000).to_i
# p i,i2,指定数值
end#for i2
$续渐增加的rand数组[i] = 指定数值
#压入增加的值
end #for i
#p $续渐增加的rand数组 #[5000,5500,5600]
rand_get = rand($加起来的rand)+1
for i in 0...$续渐增加的rand数组.size
if i ==0 #第一个数组情况下需要等于0,因为没有上一个数组
if rand_get >= 1 and rand_get <= $续渐增加的rand数组[i]
p "抽到#{$卡池数组[i][0]}"
#抽到该东西
end#if rand_get
elsif i >=1 #
if rand_get >= ($续渐增加的rand数组[i-1])+1 and rand_get <= $续渐增加的rand数组[i]
p "抽到#{$卡池数组[i][0]}"
#抽到该东西
end#if rand_get
end #if i ==0
end#for
|