m |
m |
||
| Line 60: | Line 60: | ||
Shadow Era does not implement its own card shuffling technique; instead, it relies on the built-in randomization techniques provided by Unity, specifically through the `UnityEngine.Random` class. You can read [https://docs.unity3d.com/Manual/class-Random.html more information in the Unity Website] about this class. This is the [https://docs.unity3d.com/Manual/UnityManual.html Unity User Manual 2022.3]<br> | Shadow Era does not implement its own card shuffling technique; instead, it relies on the built-in randomization techniques provided by Unity, specifically through the `UnityEngine.Random` class. You can read [https://docs.unity3d.com/Manual/class-Random.html more information in the Unity Website] about this class. This is the [https://docs.unity3d.com/Manual/UnityManual.html Unity User Manual 2022.3]<br> | ||
<br> | <br> | ||
| − | #'''Random Number Generation Algorithm'''<br>Unity uses a pseudo-random number generation (PRNG) algorithm based on the [https://en.wikipedia.org/wiki/Mersenne_Twister Mersenne Twister]. This type of algorithm is recognized for its ability to produce a sequence of numbers that mimics randomness, with a long period and good distribution.<br><br> | + | #'''Random Number Generation Algorithm'''<br>Unity uses a pseudo-random number generation ([https://en.wikipedia.org/wiki/Pseudorandom_number_generator PRNG]) algorithm based on the [https://en.wikipedia.org/wiki/Mersenne_Twister Mersenne Twister]. This type of algorithm is recognized for its ability to produce a sequence of numbers that mimics randomness, with a long period and good distribution.<br><br> |
#'''State Control'''<br>With `Random.State`, Unity allows developers to [https://docs.unity3d.com/ScriptReference/Random-state.html save and restore] the state of the random number generator. This ensures that card shuffling can be reproduced if necessary, which is useful for debugging and testing.<br><br> | #'''State Control'''<br>With `Random.State`, Unity allows developers to [https://docs.unity3d.com/ScriptReference/Random-state.html save and restore] the state of the random number generator. This ensures that card shuffling can be reproduced if necessary, which is useful for debugging and testing.<br><br> | ||
#'''Ease of Use'''<br>The use of methods like `Random.Range` allows developers to [https://docs.unity3d.com/ScriptReference/Random.html quickly obtain random values within specific ranges], thereby facilitating the implementation of game logic.<br><br> | #'''Ease of Use'''<br>The use of methods like `Random.Range` allows developers to [https://docs.unity3d.com/ScriptReference/Random.html quickly obtain random values within specific ranges], thereby facilitating the implementation of game logic.<br><br> | ||
#'''Applications in Games'''<br>Many games developed in Unity ([https://en.wikipedia.org/wiki/Hollow_Knight Hollow Knight] & [https://en.wikipedia.org/wiki/Among_Us Among Us]) use this method for crucial mechanics such as card drawing, enemy placement, and other random elements. This would demonstrate its robustness and effectiveness in real game scenarios. | #'''Applications in Games'''<br>Many games developed in Unity ([https://en.wikipedia.org/wiki/Hollow_Knight Hollow Knight] & [https://en.wikipedia.org/wiki/Among_Us Among Us]) use this method for crucial mechanics such as card drawing, enemy placement, and other random elements. This would demonstrate its robustness and effectiveness in real game scenarios. | ||

| |
|
|---|---|
|
|
| | |
| |
| | |
| This code is a collection of all the functions involved in the shuffle mechanic, though it doesn't exist as a single block in any one file. | |
//1. GameModel.GetRandomSynced(int minInclusive, int maxExclusive) public static int GetRandomSynced(int minInclusive, int maxExclusive) { Random.State state = Random.state; Random.InitState(num); int result = Random.Range(minInclusive, maxExclusive); Random.state = state; return result; } //2. UnityEngine.Random.Range(int min, int max) int randomValue = UnityEngine.Random.Range(min, max); //3. GameManager.SomeMethod() public void SomeMethod() { return text + "rand=" + UnityEngine.Random.Range(0, 99999) + "\\n"; } //4. Gameplay.ExecuteGameplay() public void ExecuteGameplay() { int curEnvironment = UnityEngine.Random.Range(0, 4); } //5. GameState.ActivateGameState() public void ActivateGameState() { GameModel.SetCurSide(Random.Range(0, 2)); } | |

Shadow Era does not implement its own card shuffling technique; instead, it relies on the built-in randomization techniques provided by Unity, specifically through the `UnityEngine.Random` class. You can read more information in the Unity Website about this class. This is the Unity User Manual 2022.3