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 are used for calculation, data processing, and automated reasoning. More precisely, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function.

1
vote
1answer
200 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 ...
4
votes
2answers
157 views

How to implement n-body in an Entity Component System

Recently I've been throwing problems at Entity Component Systems to see how far I can push the paradigm. One problem in particular I struggle with, which is writing an elegant implementation of the n-...
5
votes
1answer
155 views

How to randomly create a fair maze for a multiplayer game?

I am creating a 2d multiplayer RTS game which happens inside a maze. I have used Growing Tree algorithm to randomly generate the maze. I thought that the maze would be fair for each team as long as ...
0
votes
0answers
16 views

Duplicate packets and termination of packets in multiplayer game

I'm making a multiplayer game (lazertag) with real hardware. After hours of research, I'm choosing the UDP instead of the TCP protocol to exchange data. Because of how unreliable UDP is and because ...
1
vote
0answers
13 views

Handling game message packet loss at low speed and at a microcontroller level

I read this: How do I handle packet loss in a client-server network model? ...But I'm looking for more advice. Currently I'm implementing my own lazertag vests. I'm programming hardware (8051 ...
0
votes
1answer
22 views

Getting an object to move in another objects direction

I have a player and an enemy, both have x and y values, and I want to move the enemy to the player and have them 'touch' over time in a speed that I can determine, I tried calculating the angle ...
-1
votes
1answer
32 views

Java 2d array to generate grid - java.lang.ArrayIndexOutOfBoundsException: length=4; index=-1

I am creating a Hashi Puzzle game (Islands and Bridges) I am generating a 2d grid with Islands that can be connected using bridges, I am also running a DFS algorithm to check if the map is solvable I ...
3
votes
1answer
77 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 ...
0
votes
0answers
27 views

Instancing Meshes With Overdraw Algorith

I am working on a Game Engine(DX11) and we are at a point where we are starting to cull, and order our objects in the scene for rendering order. However, since we want to instance the same mesh, ...
1
vote
5answers
229 views

How can I select an enemy to act next, biased toward smaller enemies?

Suppose there are X number of enemies in the game. They all have to attack one by one. Each enemy is picked randomly, and can be of Y size. How can we attain biased randomness in such a way that ...
1
vote
1answer
157 views

Welzl Algorithm to find the Smallest Bounding Sphere

I'm implementing Welzl's Algorithm to find the Smallest Bounding Sphere. In brief, the algorithm works by maintaining: a set of points to contain in the sphere (inside its interior, or on its ...
1
vote
1answer
61 views

How to find sequences of consecutive cards of the same suit in a hand, including wild cards? (Indian Rummy)

I have a hand of 13 cards (chosen from 2 standard decks of 52 cards + 4 jokers, so it's possible for the same card to appear multiple times). I want to search this deck to find sequences according to ...
1
vote
1answer
62 views

Physics - How to calculate the next position of a ball rolling against a slope?

For a small C/C++ game project, I want to add some physics on a ball, to allow it to roll against the slopes of a 3d world, in the same way as the example visible in the image below: However I have ...
1
vote
1answer
66 views

Looking for a square-to-hex pixel coords algorithm

So as the headline suggests, I am looking for an algorithm/algorithms used for square-to-hex and hex-to-square pixel coordinates convertion. I have an image which looks kinda "interpolated", meaning ...
0
votes
1answer
119 views

Can you use A* to make a unit move nonspecifically?

A* is typically used to calculate the best way to move towards something, and it's quite flexible when it comes to threats, extra movement costs, and 'refuelling' on the way to something. However, if ...
5
votes
1answer
99 views

Ordered dithering between “discrete” colors?

I want to achieve color dithering between discrete colors like this: As you can see, there is no gradient, or technically there is, but very discrete as it's only a 3 color image (right bar). So I ...
0
votes
0answers
32 views

AStar Scores Explain Question. What is GScore?

I Tried to create AStar Algorithm and i'm already finished but i didnte work cause of this line : ...
0
votes
0answers
19 views

Algorithm for tile loading order

I'm working on an Android app (you could call it a "game") that loads meshes (= kind of tiles) depending on your line of sight. Basically I'm generating the ground in a void world in which you are a ...
0
votes
1answer
79 views

Implementing a score system similar to Moon Patrol

I am working on an Android game scenario inspired by Moon Patrol. My beta version is available for beta test from https://play.google.com/store/apps/details?id=dev.android.buggy In my case, I got ...
8
votes
3answers
862 views

What are good algorithms to generate borders / state areas on 2d star maps?

I'm trying to generate a fairly large two-dimensional star map that shows different factions / states, each owning one or more star systems. I'd like to automatically create borders / areas for the ...
0
votes
0answers
20 views

Failing to apply Max Rectangle algorithm

After asking this question, I have few problems trying to implement Max Rectangle Algorithm that is described here on page 19. I have a hard time implementing this, do you have leads or advices on ...
1
vote
1answer
112 views

Algorithm to generate random shapes that fill up a rectangle?

The final result can be like this I've thought up several approaches: Generate random curved lines to "cut" the rectangle (or generate random dots and form the line from the dots) Break the ...
0
votes
0answers
23 views

Algorithm for 'grid based occlusion'

I am working on a project within which I have a 3d grid-aligned world. On the 'faces' connecting grid cells (whether XY, XZ, or YZ plane), there is the possibility for an occluder (wall/floor/etc.) to ...
3
votes
2answers
192 views

Two Army Battle Simulator

I'm currently developing a small game project on unity (with purpose of learning C#) where each player controls a base and can build buildings, do research, build units, pretty much the basis. I ...
1
vote
0answers
67 views

How is terrain editing implemented like a sculpt tool?

Some creativity/sandbox games have a terrain editing feature. When thinking of a terrain, I'm thinking of a grid of vertices. The elevation of each vertex is then determined by a heightmap (image). ...
0
votes
1answer
57 views

Acceleration in Unity

I am trying to emulate acceleration and deceleration in Unity. I have written to code to generate a track in Unity and place an object at a specific location on the track based on time. The result ...
2
votes
2answers
276 views

How can I generate the smallest enclosing sphere from a mesh?

I have a polygon which is defined by a set of vertices and I need the smallest sphere encompassing the mesh. The spheres are defined by a position vector (x,y,z) and a radius. Is there an algorithm ...
0
votes
0answers
12 views

(Houdini) Twist control for bones on curve using parallel transport algorithm (Rigging)

Hopefully you guys use Houdini and some math genius can help me. I have a curve where I used the parallel transport algorithm to transport the normal along the curve and then I use this curve as a ...
2
votes
1answer
257 views

How to make ghosts AI chase Pac-Man in Java

I'm beginner at Java and I want to make ghosts chase Pac-Man in game. I read some algorithm like A* or Dijkstra but I don't know how to implement them in my game. Please help me.
1
vote
1answer
97 views

efficient 2D light source

I wanted to add a light source for a project I'm working on, and luckily I had some code based on this article: http://ncase.me/sight-and-light/, but when I ran the code after carefully transplanting ...
0
votes
1answer
91 views

Removing duplicate vertices on a mesh

I have a set of vertices and another set of indices. Sometimes I find that I have duplicate vertices in my mesh. I tried at first to check if two identical vertices were in the array of vertices but ...
0
votes
1answer
86 views

How to get a reflex edge on a non-convex mesh

I am trying to implement a convex decomposition and I need to find the convex vertex on a mesh. Is there a algorithm that I can use to find the convex vertex on a mesh.
0
votes
0answers
12 views

How to compute volume of intersection of non-axis-aligned cuboids in 3D?

Given two cuboids in 3D space (8 vertex coordinates each) that are arbitrarily oriented, how can we find the volume of overlap between them in the fastest manner?
0
votes
1answer
176 views

Algorithm to solve a battle in a card game

I am trying to write a solver for a sort of card game. I mainly do that for fun, and also to be able to learn a bit about the different types of algorithms I could use for this problem. The rules of ...
0
votes
1answer
33 views

algorithm for combining smaller tiles to balance the bigger ones

I have a field of tiles - basically each tile is a country that has some kind of sovereign. The tiles - countries - have different weight. For now I use some numerical value but in the future the ...
1
vote
1answer
175 views

Tic Tac Toe Victory State Detection [closed]

Below is the code I'm using to check if the board state has a tic tac toe style victory state. The board is always square and is made of an array of objects that keep track of their own completion ...
3
votes
1answer
216 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, ...
1
vote
2answers
56 views

Deleting an item in the game world: detecting if an item supports other items

I'm writing a 3D construction module similar to the how you build houses in the Sims. Users are able to build walls and floors (which also act as ceilings) on multiple floors (layers). This question ...
0
votes
2answers
65 views

Detect minimum speed of a dynamic node in 3d space

I have a 3d dynamic node with speed & acceleration vectors. It has maximum speed (magnitude) and minimum speed such as if it exceeds maximum or goes below minimum, it stops accelerating and the ...
4
votes
1answer
46 views

Navigate multiple Units on a grid through a tight space with different directions

I just started learning about pathfinding algorithms. Assume we have this scenario: Blue and Green can move only on those tiles. They can also talk to each other. Blue wants to go through the tunnel ...
2
votes
1answer
212 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 ...
3
votes
1answer
167 views

Redistributing sprites in procedural generation according to player movement

I am making space arcade with procedurally generated background consisted of nebulas and stars sprites, which spawn on Awake() in certain borders around player. Mobile phones have limited capacity ...
0
votes
1answer
76 views

How can I generate random levels like in “Square it!” game?

In this game, you have a 2d field with some free squares and two colored squares which you can move but only together (they'll move only if the spot is still "free"). And you have to fill whole free ...
1
vote
0answers
69 views

Wall collision and sweep and prune algorithm

I am documenting myself on collision detection algorithms. If I understand well, "sweep and prune" algorithm using frame coherence is powerful to detect object vs object collisions (almost as 0(n)). ...
0
votes
1answer
51 views

Generate random number biased to an input value

I've got enemies with a difficulty rating from 0 to 1. I want to generate a random reward that tends to increase as the difficulty rating rises, but still be possible to have a value anywhere in the ...
1
vote
0answers
215 views

Has there been any research done on ideal values for loot drop tables?

I doubt many people want to grind for an item that has a 0.00001% chance to drop from a boss that takes 30 minutes to kill. I'd imagine there are certain factors that play into how rare an item should ...
0
votes
0answers
41 views

dcitonary memory efficiency - unity

I'm trying to implement a word validator in unity for a word game, but every implementation I've tried so far has used too much memory. The least expensive attempt so far with adequate performance was ...
1
vote
1answer
84 views

Dynamic Tilemap size changer

I have started coding this project using the library SFML a few months ago. I have implemented a random map generation everytime I load the game thanks to Biome and the Perlin noise Algorithm. I ...
1
vote
1answer
191 views

Algorithm for fitting geometrical 2d shapes like in the android game Six! (or Tetris)?

In the game Six!, there's a perfectly rectangular tower of geometrical 2d shapes, that you destroy on tap to reach the ground with your player. The easy way would be to design the levels by hand. ...
1
vote
2answers
78 views

Voronoi graph - traversing from vertex to vertex

I'm working on a Unity Project in C# I've built a 3D Voronoi Diagram using the csDelaunay library from PouletFrit and using the X and Y values from a 2D diagram to instead setup some Vector3's with ...