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

Questions tagged [algorithm]

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.

0
votes
0answers
17 views

Facial Recognition in Unity3D (C#) [on hold]

I'm new to Unity3D and game dev. Currently, I'm working on a game which would require facial recognition (not detection). The image of the face would have to be captured in real-time through a web ...
0
votes
1answer
15 views

Score multiplier based on lowest time

I'm making a score system that will be based on several factors, how many collectibles you have obtained, how few hits you have taken, etc. I want to add in a multiplier based on how quickly the ...
1
vote
2answers
156 views

How could a NPC find items that appear randomly?

My main question is basically: What is the algorithm that CPU players use in smash bros to find items like the smash ball? I am trying to make a small ai character that will "look around" and once an ...
0
votes
1answer
41 views

Unity3D: activeSelf issues

I've been trying to script some basic AI for a Unity Roll-A-Ball game, which involves two balls collecting cubes for points (one controlled by the player and the other controlled by AI. Everything ...
1
vote
0answers
23 views

Team matchmaking based on ELO score

I'm looking for a very simple way to put up 2 teams out of unspecified amount of players. So its not actually a standard matchmaking since it only creates one match out of the whole pool of queued ...
1
vote
1answer
208 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
187 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
172 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
18 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
17 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
25 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
53 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
123 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
29 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
231 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
247 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
64 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
70 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
90 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
121 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
109 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
35 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
81 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
891 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
21 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
130 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
26 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
226 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
106 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
73 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
297 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
16 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
488 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
106 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
119 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
88 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
15 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
202 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
34 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
211 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
231 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
66 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
49 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
262 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
169 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
81 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
84 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
55 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 ...