ibcarpet
一个地毯扩展模组。将
JoaCarpet 的疯狂行为
功能移植到新版 Minecraft。
疯狂行为(Insane behavior)用于通过让用户控制随机数生成器来测试物品实体的随机性,从而强制生成极小概率的数值,无需等待数小时。
目前,此扩展支持以下操作中的物品实体随机性控制:
- 破坏矿车
- 活塞破坏方块
- 破坏容器(箱子、发射器、漏斗)
- 投掷随机性(发射器、合成器、投掷器)
- 投射物
用法
要开始使用 IBCarpet(Insane Behaviors Carpet):/carpet insaneBehaviors true。如果要将所有内容关闭,请将 true 替换为 false。
默认情况下,ibcarpet 使用极端值为 0.5 的三峰分布。本模组提供的分布可以通过 /carpet ibDistribution <distributionName> 进行配置。分布控制着随机数的选取方式。请阅读下方的分布说明以了解何时使用哪种分布。
分布
三角形分布
这是大多数 Minecraft 默认物品实体位置和速度随机性所使用的随机数生成器。IBCarpet 将这些三角形分布的随机数替换为用户可以自由修改以满足需求的自定义随机数。IBCarpet 替换的一些随机数来自均匀分布而非三角形分布,但这并不影响 IBCarpet 的整体用途。
以下是 Minecraft 三角形分布随机数的当前实现:
default double triangle(final double mean, final double spread) {
return mean + spread * (this.nextDouble() - this.nextDouble());
}
this.nextDouble() 在 [0, 1) 范围内均匀生成一个数字。mean 和 spread 通常是常量,它们不是我们在理解如何使用 IBCarpet 时需要担心的内容。
this.nextDouble() - this.nextDouble() 构成了三角形分布的形状。如果我们多次运行此代码并将输出收集到一个直方图中,其中 Y 轴表示 X 轴上该范围内的数字被选中的概率,它将看起来像这样:

其形状像一个三角形,峰值位于 0,随着随机数生成器生成的数值接近 -1 和 1,频率逐渐降低。这正是我们在原版 Minecraft 中看到的行为。例如,发射器向随机方向投放物品,但偶尔会有一个或几个物品比其余物品飞得更远。这是由于 Minecraft 的随机数生成器从三角形分布中选取数值;它模拟了正态分布(钟形曲线),其中远离中心的值极不可能发生,但在足够长的时间内终究会发生。
这就是为什么疯狂行为对许多技术玩家有用。与其花费很长时间测试/等待捕捉极小概率事件,这个地毯扩展允许玩家更快地捕捉这些事件。
均匀分布

在此分布内,所有数字被选中的可能性相等。这在长时间测试设计时非常有用。给定足够的时间,均匀分布很可能会捕捉到所有边缘情况。
双峰分布

此分布与三角形分布完全相反,三角形分布中极不可能的事件在双峰分布中很可能发生。这对于仅测试非常罕见的边缘情况非常有用。
此分布的极端程度可以使用 /carpet ibBimodalExtremeness <value> 进行配置。value 可以是 0 到 1 之间的数字,但不能正好是 1。0 表示均匀分布,越接近 1 的值意味着“非常极端的边缘”。默认极端值为 0.5。
三峰分布

此分布类似于双峰分布,但围绕 -1、0 和 1 的值更有可能发生,而不仅仅是围绕 -1 和 1 的值。双峰分布在覆盖轴向极端值方面表现不佳。例如,当物品从发射器中被投掷出来时,它会在 X 和 Z 轴上选择一个随机的速度向量。双峰分布只能同时增加 X 和 Z 到极端值的概率,而不能一次只增加一个轴。这意味着,在这种情况下,如果双峰分布具有极高的极端值,它仅适用于测试对角线投掷的物品,这可能会错过当物品沿世界轴平行移动时发生的一些边缘情况。
此分布的极端程度可以使用 /carpet ibTrimodalExtremeness <value> 进行配置。value 可以是 0 到 1 之间的数字,但不能是 1。0 表示均匀分布,越接近 1 的值意味着“非常极端的边缘和中心”。默认极端值为 0.5。请注意,此值对其分布的改变程度不如双峰极端值对其分布的改变程度大。
离散分布

与其他分布不同,离散分布(discrete distribution)不是连续的。它基于一个预定义的可能数值集合随机选取数字。可以使用 /carpet ibDiscreteCuts <value> 来配置这个数值集合。与其解释 IBCarpet 中如何生成离散随机数,不如直接展示其规律:
以下是该规律:
- Cut = 0,可能的数值为
[0, 1]
- Cut = 1,可能的数值为
[0, 0.5, 1]
- Cut = 2,可能的数值为
[0, 0.333..., 0.666..., 1]
- Cut = 3,可能的数值为
[0, 0.25, 0.5, 0.75, 1]
这些可能的数值就像是将蛋糕均匀切片。随着切割次数(cuts)的增加,每个切点之间的间隔会变窄。最终从这组可能的数值中选取一个值作为生成的结果。当切割次数趋近于无穷大时,分布将变为均匀分布。
离散分布非常有用,可以快速测试大多数边界情况(edge cases)。由于可能的数值数量有限,因此很容易生成极端值。请记住,离散分布可以帮助玩家快速生成许多重要且独特的极端值,但它并不能涵盖所有可能性。
与其他分布不同,此分布的范围是 [-1, 1](包含端点),而不是 (-1, 1)(不包含端点)。
默认的切割次数为 4。离散分布取代了原始 JoaCarpet 扩展中用于生成随机数的系统方法。
与 JoaCarpet 的区别
JoaCarpet 生成的随机数类似于离散分布。然而,主要有两点区别:离散分布是独立的(之前的生成不会影响当前的生成),而 JoaCarpet 不是无记忆的(它有一个计数器,记录随机函数被调用的次数)。JoaCarpet 的方法是从最极端的数值开始:0 和 1。当计数器达到 1 时,它会重置,并自动增加切割次数,以便下一次迭代遍历 0、0.5 和 1。这种方法的一个主要问题是,它需要用户手动输入来重置计数器,并且该计数器在所有物品实体随机化事件中是共享的。如果你有多个投掷器执行相同的操作,其中一些投掷器可能永远不会触及边界情况。在让 JoaCarpet 的疯狂行为运行数小时后,你可能会遇到投掷器基本上在同一位置分发物品的情况。这是因为“切割”值变得过大,导致每次分发物品之间的增量几乎为 0。
ibcarpet
A carpet extension mod. A port of
JoaCarpet's insane behavior
feature to the newer version of Minecraft.
Insane behavior is used to test item entity RNG by giving user control over the
random number generator to forcibly generate highly unlikely numbers without
waiting for hours.
Currently, this extension supports item entity RNG controls over the following actions:
- Breaking minecart
- Piston breaking blocks
- Breaking containers (chest, dropper, hopper)
- Dispense RNG (dispenser, crafter, dropper)
- Projectile
Usage
To start using IBCarpet (Insane Behaviors Carpet): /carpet insaneBehaviors true. Put false instead of true if you want to turn everything off.
By default, ibcarpet uses the trimodal distribution with an extremeness value of
0.5. The distributions provided by this mod can be configured using /carpet ibDistribution <distributionName>. Distributions controls how random numbers
are picked. Read the distribution description below to understand when to use
what.
Distributions
Triangle Distribution
This is the random number generator used by most of Minecraft's default item
entity position and velocity RNG. IBCarpet replaces these triangle distribution
random numbers with custom ones where the users can freely modify to fit their
needs. Some of the RNG replaced by IBCarpet are from a uniform distribution
instead of triangle distribution, but it does not affect the overall purpose of
IBCarpet at all.
Here's the current implementation of Minecraft's triangle distribution RNG:
default double triangle(final double mean, final double spread) {
return mean + spread * (this.nextDouble() - this.nextDouble());
}
this.nextDouble() generates a number within [0, 1) uniformly. mean and
spread are constants most of the time, and they are not something we need to
worry about for understanding how to use IBCarpet.
this.nextDouble() - this.nextDouble() is what gives the shape of the triangle
distribution. If we run this a bunch of times and collect the outputs into a
histogram where the Y-axis is the probability of numbers within that range on
the X-axis getting picked, it will look like this:

The shape looks like a triangle where the peak is at 0, and the frequency
decreases as the RNG generates numbers closer to -1 and 1. This is exactly the
behavior we see in vanilla Minecraft. For example, a dropper dispenses items into
random directions, but from time to time, there will be one or a few items that
travels further than the rest. This is due to Minecraft's RNG picking
numbers from a triangle distribution; it mimics a normal distribution (bell
curve) where values further from the center are highly unlikely to happen, but
will happen eventually given enough time.
This is the reason why insane behaviors is useful to a lot of technical
players. Instead of testing/waiting for a really long time to catch highly
unlikely events, this carpet extension allows players to catch those events
much faster.
Uniform Distribution

All numbers are equally likely to be picked inside of this distribution. This
is useful when testing a design for a long period of time. Uniform distribution
will most likely catch all edge cases when given enough time.
Bimodal Distribution

This distribution is the complete opposite of triangle distribution, where all
the unlikely events from the triangle distribution are likely to happen in
the bimodal distribution. This is useful to test only the very rare edge cases.
The extremeness of this distribution can be configured using /carpet ibBimodalExtremeness <value>. value can be a number between 0 and 1, but
can't be exactly 1. 0 means uniform distribution and values closer to 1
means "very extreme edges." The default extremeness value is 0.5.
Trimodal Distribution

This distribution is similar to bimodal, but values around -1, 0, and 1 are
more likely to happen instead of just values around -1 and 1. Bimodal
distribution is not great at covering axis-aligned extremes. For example, when
an item is dispensed from a dropper, it will pick a random velocity vector in
the X and Z axes. Bimodal can only increase the probability of both X and Z to
an extreme, it cannot increase only one axis at a time. This means, in this
case, if bimodal has a high extreme value, it's only useful for testing items
being dispensed diagonally, which can miss some edge cases that happen when
items travel parallel to the world axes.
The extremeness of this distribution can be configured using /carpet ibTrimodalExtremeness <value>. value can be a number between 0 and 1, but
can't be 1. 0 means uniform distribution and values closer to 1 means "very
extreme edges and center." The default extremeness value is 0.5. Note that
this value does not change the distribution as much as the bimodal extremeness
value to its distribution.
Discrete Distribution

Unlike the other distributions, discrete distribution is not continuous. It
picks number randomly based on a pre-determined set of possible numbers. This
set of numbers can be configured using /carpet ibDiscreteCuts <value>. It's
better to show the pattern than explaining how discrete random numbers are
generated in IBCarpet.
Here's the pattern:
- Cut = 0, possible numbers are
[0, 1]
- Cut = 1, possible numbers are
[0, 0.5, 1]
- Cut = 2, possible numbers are
[0, 0.333..., 0.666..., 1]
- Cut = 3, possible numbers are
[0, 0.25, 0.5, 0.75, 1]
The possible numbers are like evenly slicing up a cake. The space between each
cut becomes thinner as the number of cuts increases. A value is picked from
this set of possible numbers as the generated number. As the number of cuts
approaches infinity, the distribution becomes uniform.
Discrete distribution is useful to test most of the possible edge cases very
quickly. Since it has a limited amount of possible numbers, it's very easy to
generate extreme values. Please do remember that discrete distribution can help
players to quickly generate many important and unique extreme values, but it
does not cover all possibilities.
Unlike other distributions, this one has a range of [-1, 1] (inclusive)
instead of (-1, 1) (exclusive).
The default number of cuts is 4. Discrete distribution supersedes the
systematic method of generating random numbers used in the original JoaCarpet
extension.
Differences between JoaCarpet
JoaCarpet generates random number similar to the discrete distribution. However,
two main differences are that discrete distribution is independent (previous
generation does not affect the current generation) and JoaCarpet is not
memoryless (has a counter that remembers how many times random has been
called). JoaCarpet's approach is to start off with the most extreme numbers: 0
and 1. When the counter reaches 1, it resets, and automatically increase the
number of cuts so that the next iteration will loop through 0, 0.5, and 1. One
major issue with this approach is that it requires manual user input to reset
the counter and the counter are shared between all item entity randomlization
events. If you have multiple droppers doing the same thing, some of the
droppers might never hit the edge cases. After leaving JoaCarpet insane
behavior running for hours, you can encounter dropper basically dispensing
items at the same location. This is because the "cuts" value is getting way too
big so the increment step between each item dispense is almost 0.
评论 0
登录后参与评分
还没有评论,来抢沙发吧