500年了,我又回来了,嗨嗨嗨
话不多说,我先介绍一下抽奖
我们这现在有好几种办法来弄抽奖机
一共有5种,其中一种不发(防抄袭)
所以还剩4种
第一种:实体方块复制法
第二种:红石机械(排除)
第三种:计分板随机法
第四种:随机实体抽奖法
所以我觉的第四种很L
我用第三种吧awa
前言:在服务器功能组件的设计过程中,我们不可避免的要通过scoreboard生成随机进而实现抽奖/强化等功能。传统的随机(即每tick+1)非常容易被玩家卡bug,实现“100%强化成功”,此类行为会极大破坏服务器运行环境,干扰服务器正常运营。因此伪随机的生成与实现具有极高的应用价值与实际意义。
实现:经过极为漫长的尝试与数论证明,我发现如下函数可能具有一定随机性
以下基于【随机生成0到19中的伪随机】进行叙述
f(t)=[3*f(t-1)+1]% m
g(t)=f(t)%20
其中m为常数,t表示ticks为自变量,g(t)为输出的结果
于是我通过python对m进行筛选
经过多次筛选,最终采用m=1361进行伪随机的生成
即
f(t)=[3*f(t-1)+1]% 1361
g(t)=f(t)%20
首先创建几个计分板
/scoreboard objectives add roll dummy
由于取随机数
为了让他更好显示所以
/scoreboard objectives setdisplay sidebar roll
然后设置分数
/scoreboard players set random roll 0
/scoreboard players set processing roll 0
/scoreboard players set 1 roll 1
/scoreboard players set 3 roll 3
/scoreboard players set 20 roll 20
/scoreboard players set 1361 roll 1361
注意想要有名字为random实体
然后还要给玩家标签
利用除余的原理
例如10%3=1
那么我们需要取a~b之间的数值
那么这里运用lcg的随机数算法,线性同余
seed*time%(max-min+1)+min
就可以实现随机数
/scoreboard players operation processing roll *= 3 roll
/scoreboard players operation processing roll += 1 roll
/scoreboard players operation processing roll %= 1361 roll
/scoreboard players operation random roll = processing roll
/scoreboard players operation random roll %= 20 roll
最终 生成的random即为高度伪随机(随机范围0~19)
然后
/execute @e[name=random,score_roll_min=1,score_roll=1] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=2,score_roll=2] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=3,score_roll=3] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=4,score_roll=4] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=5,score_roll=5] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=6,score_roll=6] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=7,score_roll=7] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=8,score_roll=8] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=9,score_roll=9] ~ ~ ~ give @p[tag=cj] 东西
剩下的照着写,就像这样就行了
然后清除玩家标签
飞行指令
其实也很简单
(之前写了一个帖子被人拿走了,还被嘲讽了一句bushi)
其实做公益也不是很好
做的不好也会被说的
我觉的先不要玩家触发
先弄出上升和下降
由于我的世界1.12.2版本没有
缓降
所以我们只能使用这个版本的特性
按T输入
/effect @a 25 1 248 true
你就会发现你不会上升
而是下降
利用这一特点我们就可以
做出抬头上飞
低头下降
好了
以上就是原理的所讲
其他性质还需要自己去
开发
祝你好运

话不多说,我先介绍一下抽奖
我们这现在有好几种办法来弄抽奖机
一共有5种,其中一种不发(防抄袭)
所以还剩4种
第一种:实体方块复制法
第二种:红石机械(排除)
第三种:计分板随机法
第四种:随机实体抽奖法
所以我觉的第四种很L
我用第三种吧awa
前言:在服务器功能组件的设计过程中,我们不可避免的要通过scoreboard生成随机进而实现抽奖/强化等功能。传统的随机(即每tick+1)非常容易被玩家卡bug,实现“100%强化成功”,此类行为会极大破坏服务器运行环境,干扰服务器正常运营。因此伪随机的生成与实现具有极高的应用价值与实际意义。
实现:经过极为漫长的尝试与数论证明,我发现如下函数可能具有一定随机性
以下基于【随机生成0到19中的伪随机】进行叙述
f(t)=[3*f(t-1)+1]% m
g(t)=f(t)%20
其中m为常数,t表示ticks为自变量,g(t)为输出的结果
于是我通过python对m进行筛选
经过多次筛选,最终采用m=1361进行伪随机的生成
即
f(t)=[3*f(t-1)+1]% 1361
g(t)=f(t)%20
首先创建几个计分板
/scoreboard objectives add roll dummy
由于取随机数
为了让他更好显示所以
/scoreboard objectives setdisplay sidebar roll
然后设置分数
/scoreboard players set random roll 0
/scoreboard players set processing roll 0
/scoreboard players set 1 roll 1
/scoreboard players set 3 roll 3
/scoreboard players set 20 roll 20
/scoreboard players set 1361 roll 1361
注意想要有名字为random实体
然后还要给玩家标签
利用除余的原理
例如10%3=1
那么我们需要取a~b之间的数值
那么这里运用lcg的随机数算法,线性同余
seed*time%(max-min+1)+min
就可以实现随机数
/scoreboard players operation processing roll *= 3 roll
/scoreboard players operation processing roll += 1 roll
/scoreboard players operation processing roll %= 1361 roll
/scoreboard players operation random roll = processing roll
/scoreboard players operation random roll %= 20 roll
最终 生成的random即为高度伪随机(随机范围0~19)
然后
/execute @e[name=random,score_roll_min=1,score_roll=1] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=2,score_roll=2] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=3,score_roll=3] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=4,score_roll=4] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=5,score_roll=5] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=6,score_roll=6] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=7,score_roll=7] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=8,score_roll=8] ~ ~ ~ give @p[tag=cj] 东西
/execute @e[name=random,score_roll_min=9,score_roll=9] ~ ~ ~ give @p[tag=cj] 东西
剩下的照着写,就像这样就行了
然后清除玩家标签
飞行指令
其实也很简单
(之前写了一个帖子被人拿走了,还被嘲讽了一句bushi)
其实做公益也不是很好
做的不好也会被说的
我觉的先不要玩家触发
先弄出上升和下降
由于我的世界1.12.2版本没有
缓降
所以我们只能使用这个版本的特性
按T输入
/effect @a 25 1 248 true
你就会发现你不会上升
而是下降
利用这一特点我们就可以
做出抬头上飞
低头下降
好了
以上就是原理的所讲
其他性质还需要自己去
开发
祝你好运
