Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [random]

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

3
votes
2answers
119 views

How can I create a random deck of 7 cards every time they are all used?

I'm trying to create a Tetris like game in C# (Unity) and I've run into quite a problem on how I can generate 7 cards (tetrominoes) of which none are the same and when I run out of cards, I regenerate ...
0
votes
0answers
37 views

How can I change the parameters of the random events for each game entity?

I'm trying to write an easy-to-use random event system that has certain conditions and effects in Unity. It's a simulation game that contains multiple Person, City, Country, Faction elements. I have ...
0
votes
1answer
61 views

Random range issues

i tried to make a random spawn system, but when i tried to start it, it spawns more than 1 prefab, which is not intended as i wanted to spawn only one by one. tried some method to prevent from ...
2
votes
1answer
73 views

Calculate a random position inside a 2D area excluding a subset

Given this area - - - - - X X - - X X - - - - - I have a GameObject size 4x4 and inside another GameObject size 2x2. I know how to calculate a random position ...
0
votes
0answers
22 views

Optimal way to select a random item from a list based on its chance to appear in Unity [duplicate]

I am creating a random object spawning script in Unity with c#, and am wondering what the ideal way to do this task would be. So I have a list of 31 objects or so, of my special class type. Each one ...
0
votes
1answer
39 views

How to store information about a simulated sport match in a browser game?

There is a browser game called Soccerstar where users play in a soccer team and compete in matches against other teams. Matches are scheduled at specific times of the day and played automatically and ...
2
votes
3answers
204 views

Are dice-rolls for damage calculation bad design for a tactic focused game?

I'm trying to come up with a combat system for a turn-based RPG that is inspired by pen & paper RPGs, but with more importance on positioning and strategy. I feel like in games where a good ...
0
votes
2answers
67 views

Weighted random events with conditions

I'm building a system for distributing ingame events for a strategy game. The game is heavily driven by the events and each country/player should receive one or more per time unit. The algorithm is ...
1
vote
2answers
34 views

Spawn chance, modulated by probability weighted by progress

I've been struggling with this for over a day now. What seemed a simple task, has just wrecked me. I hope someone here can help me figure out what I'm missing. Please, please help me :) The ...
1
vote
0answers
39 views

how can this random scene code run well when it is reloaded?

I have a code for random scenes, the scenes that I have are 10 randomized scenes, but when I reload the scene there is only one scene. ...
-1
votes
1answer
68 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
217 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
80 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
144 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 ...
32
votes
6answers
8k 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
503 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
100 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
248 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 ...
4
votes
3answers
434 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
117 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
157 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
71 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
275 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
2answers
358 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
85 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
412 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
71 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
192 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
324 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
62 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
107 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
229 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
257 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
89 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. ...
2
votes
4answers
1k 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
724 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 ...
-3
votes
1answer
357 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
150 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
143 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
199 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
vote
1answer
321 views

Why are the randomly generated numbers 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
93 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 ...
1
vote
2answers
962 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. ...
1
vote
1answer
78 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
1k 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
418 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
214 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
2k 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
300 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
480 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 ...