2022 Developer Survey is open! Take survey.

Questions tagged [random]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
36 views

Random value is chosen 2-3 times, then after that it's always 1

...
user avatar
0 votes
1 answer
34 views

array of classes then give each class different properties, class selection random

So iam trying to practice java with a text based adventure game. This code gives out an enemy of an array(random) and then gives it a Randoam health between 0 and 100. What I want to do is give each ...
user avatar
  • 15
0 votes
1 answer
139 views

Spawn crops/3D game objects randomly on a mesh/plane surface

I am stuck on a problem that might be quite simple yet it's getting on my nerves. I want to spawn crops on different plane shapes like in the attached screenshot. So far my progress is that I am able ...
user avatar
3 votes
2 answers
191 views

Should in-game events (raids) be announced?

Many survival games such as Rimworld will announce when significant events happen in-game. For example, when a raid, a disaster or a significant event occurs, the game will send a notification and ...
user avatar
0 votes
0 answers
71 views

How do I generate random worlds like Yoda Stories and Indiana Jones? [duplicate]

Hello I'm working on an adventure/RPG in C with solvable puzzles in the vein of Indiana Jones and His Desktop Adventures and Yoda Stories. I'm trying to generate a random world from maps pre-made in ...
user avatar
0 votes
0 answers
42 views

How to assign a new value to a global variable in GML

I have a variable called global.goldchance = irandom(99);. I use it to get a random number from 0 to 99. However, I need to be able to run it again so that the ...
user avatar
0 votes
1 answer
60 views

How to lerp between diferent spot angles

I have this code that Change spot angle randomly between 'minAngle' and 'maxAngle' each 'interval' seconds: ...
user avatar
1 vote
0 answers
69 views

how to raycast against a mesh instead of the object in unity

So I am trying to make random map generation for a game, and right now I am trying to use a raycast to get the height of the spot where a prefab will be generated, I am using a terrain and generating ...
user avatar
-1 votes
1 answer
680 views

How to make random spawn objects in unity 3D

I created an infinte runner game. I need to make random spawning obstacles ON 3D. How do I randomly spawn prefabs on the X axis using a C# script?
user avatar
0 votes
1 answer
74 views

Slots - Reel with a predefined symbol positions or make each symbol change independently on the others

I'm making a slot machine game and I need some advice on how to implement the spinning reels or how it's usually done. Right now, I'm thinking about two different approaches that would make sense - if ...
user avatar
0 votes
1 answer
102 views

Deriving multiple properties from a single random seed

I'm interested in designing a game with a randomly-generated world. I'd like the world to be generated from a seed value, so that players could share these seeds among each other and play in the same ...
user avatar
1 vote
1 answer
81 views

RNG random numbers/preset payout rate contradiction

Taking a casino slot machine for example: How can the probability of a payout TRULY be random with a preset payout rate? If a casino has slots programmed to a specific rate or percentage of payout, ...
user avatar
  • 11
0 votes
1 answer
51 views

Random Spawning Traffic at Pace Fitting "Frogger"-style Gameplay

In my game level, you have to cross a busy road to buy something and then cross back again. The general gameplay mechanics are now set up and playable. But I wanted to know if this routine I used to ...
user avatar
5 votes
2 answers
2k views

Can you show rng code running in real time in a game?

First off, I know almost nothing about game development/rng but I will learn. So apologies for sounding uninformed. I want to make a sandbox ios game with several activities to do within, one of which ...
user avatar
0 votes
1 answer
80 views

Why is Random.Range(0,3) generating only 0, 1 or 2 when 3 is supposed to be inclusive?

I'm currently having trouble getting my head around how Random.Range() and Array[].Length are working in the script below. ...
user avatar
1 vote
0 answers
763 views

How to randomly change the color of a Shader Graph Material for only a specified GameObject, with C# script?

I'm working on a game, in Unity3D, where the player picks up trash from Trash cans, and dumps the trash from the Trash cans into a Trash Truck. The world of the game itself is randomly generated, with ...
user avatar
2 votes
1 answer
511 views

Given a 2D array, how do I generate a random path of fixed length from a random point at length 0 to a random point at max length?

I'm trying to generate a random path on a 2D grid given that: The width and height of the grid are given The length of the path to generate is given The path can't move "back" The path ...
user avatar
1 vote
1 answer
209 views

How do I generate platforms in a specific position in godot?

I am making a rogue-like game in Godot. Currently, I am stuck with the world generation. I know how to add children, but I am wondering if there is a way to add those children in a specific position. ...
user avatar
0 votes
1 answer
86 views

Preferred way of calculating run chances in Game of Cricket

For modelling a simple game of cricket, Considering a batsman has a single attribute rating. I can go about deciding run chances by weighted probabilities. ...
user avatar
1 vote
0 answers
72 views

How to create a random, warped 2D grid?

How do you create a random grid where the lines aren't orthogonal (and cells aren't a perfect square), but are warped? Here's an example of what I mean: (Credit: screenshot taken from a video by ...
user avatar
  • 113
2 votes
1 answer
535 views

How can I create a persistent seed for each chunk of an infinite procedural world?

I'm coding a chunk-based 2D game. I generate chunks as the player explores the world. Chunks follow a procedural generation algorithm (with only one biome implemented at the minute, but I'll ...
user avatar
0 votes
1 answer
152 views

Random.range giving me the same value at the same time

I created a random direction in x and y-axis at where to move, then my problem is when I tried to randomize it sometimes I get the same value at the same time on both x and y-axis. How do I not let ...
user avatar
  • 91
0 votes
1 answer
87 views

How can I make an instantiation random?

I'm trying to do it so when I have an instantiated an item upon the game starting, it is random as to whether it actually instantiates or not. Here's the code I have so far: ...
user avatar
0 votes
1 answer
87 views

Random enemy generation algorithm help

I've been working on a program for my friends to use for a homebrewed roleplay system that we all use for our campaigns that can generate random enemy statlines with certain constraints. The program ...
user avatar
2 votes
3 answers
670 views

If and why is randomness a bad thing in competitive games?

AFAIK it is a consensus within esports that randomness should be reduced? League of Legends has little RNG, Dota has more but both games employ rng smoothing algorithms (details for Dota, LoL). The ...
user avatar
  • 867
0 votes
0 answers
131 views

Random world Points in GLSL for tree placement

I'm doing tree placement in the geometry shader in GLSL. I've made a seeded random vec3 function based on gold noise that looks like this: ...
user avatar
  • 186
0 votes
2 answers
590 views

C++ Generate random float values between a range

In my current situation I have a game world, in that game world I want to place loads of tree models. It is a waste of time for me to actually explicitly define the x y and z values of each tree model,...
user avatar
3 votes
1 answer
294 views

How to generate random waves for a bullet hell game that feel balanced and natural

My game consists of 'waves' of objects called 'spawners', which once every certain amount of time (their firetime), move to a new place on the screen and spawn an enemy. Each wave has 4 important ...
user avatar
0 votes
2 answers
505 views

Random point on a square floor

I have a flat 10x10 surface (floor) made out of cubes of 1x1x1. I am spawning objects from the "sky" and I want them to fall on random points of the surface without exceeding the surface limits. Is ...
user avatar
  • 103
0 votes
1 answer
341 views

Is it possible to find a seed based on 10,000 generated random numbers?

I'm currently entertaining an idea I've had about procedurally generating a world. I would like the entire world to be procedurally generated on the fly. So when a chunk is loaded, it uses a seeded ...
user avatar
  • 123
1 vote
2 answers
165 views

How can I make my race game fair with all players and keep it climatic?

I'm making a minigame where up to 5 players have to race against AI or another player(the "enemy"). The race consists of prompts, the current player is asked to press a key in a given amount of time ...
user avatar
  • 111
1 vote
1 answer
1k views

Saving predesigned tilemap "rooms" and access them in script in Unity3D?

I'm working on a top-down rogue-like in Unity3D, and I already have some kind of dungeon generation. The next feature I'd like to implement, is to predesign some kind of "event rooms" (i.e. boss ...
user avatar
  • 626
2 votes
1 answer
91 views

Quick way to approximate a truncated gaussian distribution?

I'm doing some procgen stuff and I need a truncated gaussian distribution. Basically, I need a way to get the same thing as this: ...
user avatar
  • 296
4 votes
1 answer
389 views

How to create characters randomly with a given skill and weighted abilites

I am trying to create random characters in my game. Each character has 33 abilities and one of 6 jobs. For each job you need to skill/increase other abilities. I am calculating an overall skill (...
user avatar
0 votes
1 answer
80 views

How do I add a random number of points to my score stored in Player Preferences?

My problem is the value I get from Random.Range is not stored, but I get another value instead. In level 1 I press the "claim" button to store a randomly-chosen score In level 2 I retrieve the level ...
user avatar
3 votes
2 answers
513 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 ...
user avatar
0 votes
0 answers
103 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 ...
user avatar
0 votes
1 answer
77 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 ...
user avatar
2 votes
1 answer
441 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 ...
user avatar
0 votes
0 answers
67 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 ...
user avatar
  • 45
0 votes
1 answer
55 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 ...
user avatar
  • 109
2 votes
3 answers
604 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 ...
user avatar
  • 133
0 votes
2 answers
276 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 ...
user avatar
1 vote
2 answers
90 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 ...
user avatar
1 vote
0 answers
43 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. ...
user avatar
-1 votes
1 answer
78 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 ...
user avatar
1 vote
1 answer
254 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 ...
user avatar
  • 11
0 votes
1 answer
122 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 ...
user avatar
3 votes
1 answer
177 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 ...
user avatar
  • 33
43 votes
8 answers
33k 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 ...
user avatar
  • 5,171

1
2 3 4 5 6