# 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.

940 questions
164 views

### midpoint displacement algorithm in sdl

I am trying to implement moving random hills in SDL. I am using midpoint displacement algorithm to create some random terrain and I have also accomplished to move the terrain too. But the problem is ...
103 views

### Is there a way to make this better? [closed]

So was experimenting in making a rotating ring puzzle like the one to get into the mechanical age in Myst. I came up with a solution that will rotate the rings and when the button is released it ...
205 views

### AI: Turn-Based Movement with 2 actions per Unit

I am currently building a turnbased tactics game. The Board is a small (about 4*6) tiled grid. The AI plans all moves of its units, each unit can move 2 times move and attack or attack at least ...
305 views

### How to fill a canvas with triangles that are seemingly random?

Given a canvas say, 1000 X 1000 unit. I would like to fill the canvas with triangles. The triangles can be of any type right angle, equilateral...etc. To avoid big chunks of triangles lets say all ...
96 views

### Automatic audio segmentation and find the most energetic segments

What algorithm can be used for audio segmentation? I want to divide song to segments and find the most energetic segments (begin and end in seconds). It is needed for the rhythm-game. Examples: ...
188 views

### C++ Data structure pattern preferability?

So im looking at ways of handling large amounts of data in situations such as an entity manager or particle system. So i have concluded to use an object pool, and there are two things that I could do ...
336 views

### Java, spawn algorithm that gets harder each level

I am currently in the process of making my 3rd Java game (everything I have learned is from YouTube videos, so I may be doing some things wrong) named "Blocked". But I have run into a problem: how do ...
72 views

### Algorithm to propagate internal Physics force in a structure of building

Scenario: A floating structure composes of many nodes (or in more visual meaning - a cubic block). Every node is snapped to the same 3D grid. (similar to a minecraft castle) There are external ...
192 views

### How to constraint random spawn points to a road? [closed]

I have a terrain and a road. I would like for spawn points to randomly appear on the road, and not outside on the terrain. How to assign the spawn points to only be between the road and in random ...
104 views

### How can I make cars drive navigate an intersection without colliding?

I'm trying to create a 2D game with a traffic intersection: My car game-objects need to pass through the intersection without colliding with each other, and without stopping, if possible. How can I ...
1k views

### How do I calculate paths for objects with limited acceleration?

For example, say I have a car and a car has a specific minimum turning radius and I want to drive that car from point a to point b, but the car isn't facing point b. How do I compute a path to point ...
1k views

### 2D infinite grid data structure

I'm currently developing a game, and I'm in a process of experimenting with various data structures to support my game model and simulation. Here are some of the requirements: Grid structure where ...
253 views

### Depth of Field Blur - Weighted sampling?

I've been studying Intel's fantastic article titled "An investigation of fast real-time GPU-based image blur algorithms" (here), where-in they state that Gaussian blur would need to be customized for ...
911 views

### Procedural generation of evenly distributed random points (2d)

I am coming here because I've have a performance problem with my current implementation of an algorithm. I am the idea of Voronoi diagrams to distribute patches on an infinte 2d layer. For a Voronoi ...
404 views

### How do you handle loss aversion in probability-based games?

The psychological phenomenon of loss aversion refers to how players feel losses twice as powerfully as victories. For example, Bite Fight's PvP is a simulation based on probabilities related on ...
52 views

### Defining camera/view space

Im working on expanding my camera class, but having trouble defining camera/view space in the manner of this diagram: What Im trying to achieve is to define the camera as a true object much like a ...
578 views

### How to create a believable swimming fish animated Sprite in 2d?

I want to create a fishing game in which fish needs to be swam across in the ocean. I put static fish which just progresses across ocean but it does not look very realistic and interesting to attract ...
127 views

### Circular fighter motion algorithm

Is there an algorithm to make ships take semi-circular patterns? I need something like the below image: Big Blue- Command Ship Small blues - fighters Red lines - path of movement I want the fighters ...
269 views

### Locust Swarm algorithm for path finding (devour and move on)

I need to model a locust swarm that devour food stacks and move on to next stacks. I searched for articles and found few articles. These papers is about optimization applications but I want to convert ...
152 views

### Dynamic Mesh Generation Algorithm

I was recently given an assignment to generate a mesh from code, in Unity. At runtime, the player will click at random positions on the screen. An array will store all these points. There must be ...
463 views

### How do I correctly shift arrays on a Tetris line clear?

I'm writing a Tetris clone in C++ and I am at the last stage, I need to delete a row when it is full. Once a piece falls it is stored in a boolean array grid[20][10]...
765 views

### Isometric scene in SpriteKit

I tried play with spritekit in isometric grid. But i can't understand how to fix level. ...
267 views

### Pathfinding to unknown destination point

Usually you need path finding algorithms to find one or the best path between two points. Do you know if path finding algorithm where you don't know the destination point exists? I have a graph made ...
1k views

### Fastest way to neutralize scale in the transform matrix?

Let's assume we have 4x4 3D transformation matrix, that is the result of scale, rotation, and translation transforms. How to set its scale to (1,1,1) in the fastest way? Assume also that the matrix is ...
116 views

### How to find grid cells not seen by an object

I am writing a VB.NET program. I have a grid view which is made of multiple small cells called grid cell. On the grid view, I have placed an obstacle (red box) and an observer (blue box). My task ...
240 views

### Image-Space coherence of the z-buffer algorithm

I'm reading Hierarchical z-Buffer Visibility by Ned Greene et al. and they state that traditional Z buffering makes reasonably good use of image-space coherence in the course of scan conversion. I ...
592 views

### Dijkstra's Algorithm - Infinite loop

While running Dijkstra's Algorithm to assign a direction to every tile and when an object land on the tile, follow the direction to a goal. I encountered an infinite loop (or I think it is). The ...
1k views

### Forward A-star pathfinding vs Reverse A-star pathfinding

Under what condition does doing Forward path finding or Reverse pathfinding get better result? Most tutorials for open grid tower defence games says to pathfind from the Goal to the monster. Why is it ...
951 views

### Finding dead ends in maze

I am creating a maze type puzzle game where there is a grid and the user can create their own maze but I need help in writing an algorithm which finds the following things: How many dead ends are ...
68 views

### Why is my bullet disappearing after I release the shoot button?

I'm making a game using DirectXTK for my university project. When I press space bullet moves forward like I wanted, but when I let go it stops my bullet from moving. How do I keep the bullet moving ...
195 views

### Increasing chance of good loot after multiple tries

I'm looking for a way to make chances of getting better loot increase the more you've looted. I do not want it to be possible to get a rare item the first 5 times and not being able to get an epic ...
412 views

### How do I generate random mountains in a sidescroller?

So I'm trying to make a simplified Terraria style world using Perlin noise. I got that working and the terrain is randomized. However the terrain always looks like like a weird cosines curve. Hills ...
576 views

### Why do KD trees put the median split exactly on a point?

I've understood that KD tree split points using the median while cycling on each axis. I've also understood that at each node traversal, a nearest search must use a sphere to store to nearest neighbor ...
89 views

### Programatically placing musical notes on a stave

I'm trying to program a musical stave and have come against the problem of where to place a note, given its index. The index of a note is defined from a model created from the table in the following: ...
93 views

### Efficiently calculating best nearest sphere from a point in 3D space

I have a point in 3D space and a number of spheres (anywhere from 0 to thousands) at random locations in said space. Each sphere has a property that falls off in a smooth gradient from the centre to ...
270 views

### Flowing GPU compute water

I have a civil engineering background and perform hydraulic and hydrologic analysis' regularly. They sell degrees for that sort of thing, but it's really not rocket science. I recently got it in my ...
62 views

### What are vornoi diagrams used for in game development [closed]

I see vornoi diagrams talked about from time to time in the context of game development and graphics, and have seen them used a bit in procedural textures as well as talked about in relation to path ...
81 views

### Calculate total area of a composition of images

I'm trying to calculate the total area of a game object composed of several images. For each image, I know: Width, Height X, Y Rotation ScaleX, ScaleY OriginX, OriginY Where OriginX/Y are floats ...
630 views

### Creating a Roguelike game in C

I'm trying to create a simple rogue-like game in ncurses in a C program. The idea here is that, I'd parse a file like this: ...
269 views

### Map generation, issues with midpoint displacement algorithm

I'm trying to generate an endless 2d terrain. So the terrain isn't random per say as the random function I'm using is a hash based on an X,Y coordinate. ...
469 views

### Swept AABB Collision and Response Problems

I am working on a simple 2D game, and I am having problems with collision detection and response. I am using code adapted from this article: http://www.gamedev.net/page/resources/_/technical/game-...
535 views

### What's the best way to deal with platformer tile collisions?

I am starting with game development and creating a basic platformer game. I already have searched a lot and found some ways to implement the platformer aspect to the game, like apply a gravity, ...
690 views

### Finding cells within range on hexagonal grid

First up - I know I'm being super-dense here. With that out of the way, I'm trying to write a C# implementation of this algorithm: ...
170 views

### Recognize pattern in 3D building environment

I'm currently developing 3rd person building game (as bacheleor thesis). I need to recognize constructed patterns co I can mark corresponding structure as some building (so player can start using that ...
160 views

### Help with drawing a polygon with N sides [closed]

I am at university on my games development, and I have been given work to fill in an empty pixel plotter program using the methods they have supplied for it to teach us the algorithms used in 2 ...
258 views

### Random equidistant points like a tree branch (JS)

I'm working on an algorithm to generate a "graph" like array of points in my game world. See Image Below: Here is what i'm working on so far, which will generate the black line.. but this may not be ...
949 views

### How to do placeable electricity cables that work like the ones in “Prison Architect”

I would like to know one (of the probably many) ways to code a (sort of) Prison-Architect-ish electricity cable building system. Here's a picture of what I mean: ...
993 views

### understanding spatial hash function behaviour and Knuth for int64

I implemented open-indexing sparse 2D spatial HashMap, and I'm quite satisified with performance ( ~30-70 CPU cycles to get object at particular location for size ~16 Milion objects ). However, I ...