Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Algorithms or methods to produce events or behavior that is random in nature.

-1
votes
1answer
61 views

Are there any formulas/algorithms that could allow level to decide how many dice can be used for a roll?

See, I'm trying to work on an cRPG system and I want a formula or algorithm I guess, where the level affects how many dice can be rolled for any action (in addition to a default number of dice and ...
1
vote
1answer
203 views

How simulate a random distribution?

I'm working on a battle algorithm for a text-based game and I stumble when it comes to randomly distributing attacks on a set of units. E.G, 100 archers shoot 100 targets at the same time. I thought ...
0
votes
1answer
70 views

Bullet Spray RNG

So I have a Nuclear-Throne like weapon system in my game, and I'm working on bullet spray. Originally, there was equal odds that the bullet sprayed at any angle within the spray range. That felt ...
2
votes
1answer
129 views

Figuring out damage distribution

My problem - Each round, each of the 5 champions get to strike each of the 99 monsters once; however, their attacks are such that one third of each champion's attacks are ineffective, causing 0 ...
28
votes
6answers
6k views

How do I create a weighted collection and then pick a random element from it?

I have a loot box that I want to fill with a random item. But I want each item to have a different chance of being picked. For example: 5% chance of 10 gold 20% chance of sword 45% chance of shield ...
3
votes
1answer
101 views

Creating random path in grid

I need to find a path with required length in the NxN matrix without loops and deadlocks. For example: We Have a grid 7x7 (49 blocks in total) with START (orange) point. We need to build random ...
2
votes
1answer
86 views

Logic for npc/customer for cafe simulator game

I need help for logic or pseudo code on how to implement a rules/formula for customer in how they choose drinks(& the toppings). I have more than 10 types of customer and I want to set preferences ...
0
votes
2answers
192 views

How can Perlin Noise be modified to not tile?

In vanilla perlin noise, the texture repeats after 256 coordinates, due to the way it picks a gradient vector. In games that require an infinite procedural world, however, this is not an acceptable ...
2
votes
3answers
338 views

How to use Moving Average to avoid lucky streaks in RNG

I spent the last week reading about Luck Mitigation and what a dev can do to avoid extreme cases where the player's psychology will be messed up. I came up to this question How do I avoid “too” lucky ...
0
votes
3answers
101 views

What are the differences between random encounters and permanent mobile enemies?

Random Encounter: A player has a 10% chance to encounter an enemy. while moving through a 5x5 grid. Permanent Mobile Enemies: There is one enemy that constantly moves through the 5x5 grid and only ...
0
votes
2answers
137 views

Random NPCs - possible yet? [closed]

Traditionally, non-unique game mobs and NPCs are of the cookie-cutter type. Seen one, seen 'em all, and you instantly know their behavior, stats and strong/weak points. Games however become ever ...
0
votes
3answers
65 views

Help generating clues in a treasure finding game

I am a high school student creating a small game in unity for fun and would greatly appreciate your opinions on this game mechanic. I have a treasure finding game that takes place in a randomly ...
3
votes
1answer
225 views

Procedural Star Generator

I want to develop a procedural galaxy / starfield generator. A rather simple approach would be to use some pseudo-random algorithm to repeatedly create a star and its properties (such as position, ...
4
votes
1answer
193 views

How to randomly rotate a D20 Dice in Unity?

I'm working on a Dice Application in Unity that involves randomly rotating a dice model on instantiation and then dropping it. But in order for this application to be useful I need to guarantee that ...
0
votes
1answer
80 views

Map growing algorithm

I'm quite new to programming games and I'm currently working on a group project in university on creating one. In the game we've got a set of squares (cities, other entities) which are placed on the ...
2
votes
1answer
243 views

Random 2d terrain algorithm for map generator

I'm new to game development and I need some advice. I'm building a web based 2d random map generator and I wonder which algorithms there are to create such random terrains in a simple matrix as seen ...
1
vote
1answer
56 views

Random Sobol 3D Cell in Unity

There is a blueprint in UE4 for making Sobol random 3D cell. It places random objects inside cell structure. How to make this in Unity? For example, if I make a sphere prefab I would need to generate ...
0
votes
1answer
122 views

Checkers games with computer random movement

Im studying Java OOP, and I have to make first assignment about making checkers board game. I have to get input from user if he plays, and than when his turn is over the computer will play. Computer's ...
1
vote
2answers
158 views

Procedural dungeon algorithms for a more open dungeon

I'm working on a game that I want dungeon generating in, but I plan on having ranged weapons in it, so I want it a bit more open. I'd like to avoid corridors and I don't want to use a grid of custom ...
1
vote
1answer
51 views

Prioritizing prefabs in array for procedural generation

I am trying to create procedural space background with a bunch of sprites of nebulas and stars. I have made few prefabs with different types of sprites attached to them. I have created an array ...
0
votes
1answer
75 views

Intuitively, why is 3.5 the average (mean) roll of a six-sided die?

Every page I could find on the web that answers this question explains it with Expected Value statistic probability math. $$(1 * \frac 16) + (2 * \frac 16) + (3 * \frac16) + (4 * \frac16) + (5 * \...
1
vote
2answers
182 views

How can I generate a random 2D surface

I'm trying to build an old game (Lander) where you try to land a spaceship on a flat platform. But I have no idea how to generate a random surface. Something like in the picture would be nice. Edit: ...
4
votes
2answers
186 views

Messy results from simple cellular automata algorithm?

I wrote something that will first randomly populate a square a with grass tiles, and then from there it will calculate tile types from each tile's surrounding tiles. My ultimate goal is generate a ...
2
votes
2answers
73 views

Using seeds for rng. A reliable way of saving bandwidth?

Imagine a server-client game application. While running, the server is constantly generating numbers for various random events and sending them over the network to inform the clients of the result. ...
1
vote
4answers
470 views

How can I spawn items based on probabilities?

I'm working on a game where I want to choose which object to spawn based on probabilities. Assuming the decision to spawn the object has been done by some other process, I'd like the object with the ...
6
votes
3answers
373 views

Generate cave like Terrain in 2D

I want to create 2D Terrain randomly. It should look like a connected Cave (Shown below). What is the best method or Algorithm to get similar results? The important part is the open area(green) and ...
0
votes
0answers
63 views

Algorithms on Random Level Generation with Predefined Objects and Constraints

Let's say I'm developing a game where a city is generated and buildings are placed in a random manner. Methods to generate the roads are easy to find, it is akin to creating a maze but I can't think ...
-3
votes
1answer
219 views

Game maker studio 2 Random spawn locations are not random [duplicate]

This is a redo of another question I asked. First I want to clarify that I am indeed using drag and drop. So saying something like "maybe switching to gml will fix your problem" is appreciated, but ...
-1
votes
1answer
106 views

GameMaker Studio 2 random isnt random [duplicate]

I'm making a game where things randomly generate. It used to work, but now all the sudden they keep spawning in the same area every time. does anybody know a fix?
0
votes
1answer
118 views

Random tile-based floor plan generation with enclosed rooms

I've been working on a project for a while which takes a grid of n*n tiles (starting at n=16 and with n increasing by 4 every so often for new floors), and fills it with rooms of random rectangular ...
0
votes
1answer
87 views

Create rotation in random direction from existing rotation

I am working on a game in Unity, and I currently have a game object (object A) located at the origin. I have a child of this game object (object B), that is 10 units back on the z-axis. When I rotate ...
-1
votes
1answer
206 views

Game maker studio 2 — Randomly generated numbers are not random

I'm trying to make a game where the damage you deal is rolled by a dice. It all works. However, it keeps on giving the same values in a row so it isn't entirely random ...
0
votes
1answer
88 views

What is the best practice for calculating a succesful action?

Say for example in my game a player is able to kill an NPC, and there is an x% chance of an item dropping. When calculating if the item actually dropped or not, what is the best way to calculate a ...
0
votes
2answers
411 views

Random Direction Vector Relative To Current Direction

I have a 2D vector where the x and y values are randomly generated using a range between -1 and 1 respectively. I use this as the direction to move an object in which works great. ...
0
votes
0answers
53 views

Play animator from a random places in Unity

Here is my code so far: ...
1
vote
1answer
77 views

Split a grid into shapes that can be moved back from 4 directions

Basically I have 4 grids Left, Right, Top, Bottom. Player can choose each of them and move all the blocks on that grid to the Middle grid to fulfill it, like tetris from 4 directions: ...
-5
votes
1answer
370 views

Unity Random.Range when using Int, doesnt seem random at all?

I have a simple script that should cycle through 4 music tracks and select the next one to be played. nextSong = Random.Range(0, 3); I've run my game ...
0
votes
1answer
332 views

Creating a random lottery system

I would like the game to give all 16 characters (15 NPC + 1 player) a number: 1-16. This number stays the same no matter what and is unique only to that character so two characters cannot have the ...
6
votes
1answer
192 views

How to make sure that the set of randomly spawning obstacles is passable?

Prompt Suppose we have a little mini-game where you have to avoid incoming obstacles by moving the blob up and down at a constant speed. The blob's x coordinate is fixed and the obstacles will spawn ...
16
votes
3answers
1k views

Is Unity 2017 random number generator deterministic across platforms given the same initial seed?

Is unity engines random number generator deterministic across platforms given the same initial seed or should I implement my own? I know there have been some modifications to the random number ...
4
votes
2answers
204 views

Split a grid into random paths

I need an algorithm to split a grid into randomly generated paths where: A path is a list of cells connected at most to two adjacent cells. Paths have a minimum and maximum length. All cells in the ...
2
votes
2answers
326 views

Pseudo random number generation in compute shader

Using a C# script in Unity3D to control a HLSL compute shader, I'm trying to generate pseudo random numbers on the gpu. Following along with GPU Gems 3 Hybrid Tausworthe method and another thread ...
4
votes
1answer
169 views

How to devise an algorithm for a person being on a walk?

The game is an isometric RPG. The map is tile based. I'm creating a town for this game. And I want one of the characters to roam the town randomly, because she is on a walk with her children. I ...
0
votes
2answers
441 views
1
vote
1answer
464 views

Circles within circle (PUBG safe zone)

I'm attempting to do something that resembles the safe zone in PUBG (PLAYERUNKNOWN'S BATTLEGROUNDS), a circular area on the map that shrinks over time. On map screen: ...
2
votes
1answer
121 views

Determine the startposition for Perlin worms

I want to implement Perlin worms for the level generation of my 2D game and I was wondering, which options exist to find the startposition for the worms. My idea was to randomly start zero to X (...
0
votes
1answer
237 views

Game Maker Language's random function always giving the same result

I'd like to create a Snake game, and for that, I'd like to position the sweet which makes the snake bigger in a random position. For that, I use this code in the create event of the object bonbon : <...
1
vote
1answer
805 views

How do i create a random planet generator and use it on Unity? [closed]

For example : https://managore.itch.io/planetarium Something like this, create random sprite circles who at least are realistic looking, as far as realism can be pixel, I don't think this can be ...
-1
votes
1answer
68 views

One dimensional, bi-directional terrain generation

I'm developing one-dimensional terrain generation in my game. I give the program a seed and based on that I need to be able to walk forwards and backwards on a line that is drawn between a series of ...
2
votes
2answers
447 views

Limitation on irandom() of game maker?

I have three objects. All of them in the create event contain an action each (execute a piece of code): obj_r01 => r01=0; obj_r02 => ...