Pseudo Random Distribution Bool

SkyWing - Code Plugins - Sep 23, 2024

Return a random boolean value based on the input probability and count.Make the random results closer to the expected value.The supported probability precision is 3 decimal places.根据输入的概率和计数返回随机布尔值。使随机结果更接近数学期望值。支持的概率精度为小数点后3位。

  • Supported Platforms
  • Supported Engine Versions
    5.2 - 5.4
  • Download Type
    Engine Plugin
    This product contains a code plugin, complete with pre-built binaries and all its source code that integrates with Unreal Engine, which can be installed to an engine version of your choice then enabled on a per-project basis.

Documentation: Link

中文文档:Link

GitHub:Link

Return a random boolean value based on the input probability and count.Make the random results closer to the expected value.The supported probability precision is 3 decimal places.

This function is used to generate pseudo-random boolean values, commonly employed in gameplay scenarios that require random decision-making.

For example, it can be used to determine if a player triggers a critical hit.With the same 50% critical hit rate, in 100 attacks, there could be a lucky streak of 10 consecutive critical hits or an unfortunate streak of 10 consecutive non-critical hits.

To avoid such lucky and unlucky situations, the Pseudo Random Distribution (PRD) algorithm was introduced.

The PRD algorithm is defined as:

P(N) = C * N

Where N represents the current number of attacks, P(N) represents the critical hit rate for the current attack, and C is the probability increment. If a critical hit occurs during the current attack, N is reset to 1. If no critical hit occurs, N is increased by 1.


根据输入的概率和计数返回随机布尔值。使随机结果更接近数学期望值。支持的概率精度为小数点后3位。

例如,可以用来决定玩家是否触发暴击。同样50%暴击率,在100次攻击中,可能会出现连续10次攻击暴击的幸运情况,或者连续10次攻击不暴击的不幸情况。

为了避免出现这种幸运和不幸情况,Pseudo Random Distribution (PRD) 算法出现了。

PRD算法的为:

P(N) = C * N

N表示当前攻击的次数,P(N)表示当前攻击的暴击率,C为概率增量。如果我们这次攻击产生了暴击,则需要将 N 重置为 1,如果这次攻击没有产生暴击,则 N + 1。

Technical Details

Features:

  •  Calculate Pseudo Random Bool

Code Modules:

  •  PRDBoolBPLibrary,Runtime

Number of Blueprints:1

Number of C++ Classes:2

Network Replicated: No

Supported Development Platforms: Win64, Mac

Supported Target Build Platforms: Win64, Mac

Documentation: Link

中文文档:Link

Example Project: N/A

Important/Additional Notes:N/A