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

1
vote
2answers
177 views

Tile-based board game collision mechanism algorithm

I am looking to see ideas for an algorithm which will handle collisions for some battle-ship tile-based board game. A little about the game The game is pretty simple. Basically there is a board, ...
4
votes
3answers
680 views

Space nebula cloud generation?

I found a cool kickstarter project called "Skywanders". It's an minecraft like space game with a lego like building system and pretty cool graphics. One thing I noticed are the "nebula clouds". They ...
1
vote
1answer
57 views

Good item distribution for 2d scroller game

I have made a scroller game where player moves to the right of the screen. I add a new uniform ground block about every 5 seconds. I was wondering how often should I put bonus items. Currently I put ...
0
votes
2answers
695 views
1
vote
0answers
324 views

Triangulating a 3D mesh from a set of data points

I'm trying to implement the Bowyer-Watson point insertion version of the Delaunay triangulation algorithm, but in 3D. I previously implemented the 2D version without problems, but when transitioning ...
2
votes
2answers
146 views

Add action to GameObject

So I'm creating a Unity project that has a bunch of buttons (like hundreds) that each do a different thing when pressed. This is a 3D project and these buttons are also 3D. I already know how to ...
2
votes
1answer
291 views

What algorithm should I use to laid out pre-made rooms into a level?

I want to have a semi-procedural level, where rooms are pre-made but the way they're connected are proc-gen. The connections need to really exist - you can walk between rooms in hallways - not just ...
1
vote
2answers
2k views

How to detect matches in match-3 game?

I am working on a match 3 game where the number of matched cells matters (if you match 3 then they just get removed, if you match exactly 4 then something happens, and if you match more than 4 ...
1
vote
2answers
175 views

How do people implement pathfinding movement?

I understand how A* works, but I don't understand how movement is implemented, e.g. creating a list of directions and then going through that list until every direction is empty. How does that work? ...
1
vote
0answers
28 views

Algorithm for clipping convex quadrilaterals

I'm dealing with hardware that uses quads as its polygonal primitive. Not triangles. A triangle can be expressed by setting 2 of the 4 equal to each other for a degenerate quad. For the 3D engine, I'...
5
votes
3answers
1k views

Ray tracing and Z buffering in graphics

I am a high school student taking computer science as a subject, and someone who is very interested in the game development industry. I am currently writing an essay on Raytracing and Z-buffering by ...
0
votes
1answer
74 views

What is the simplest way to calculate energy earned based on time?

A player has 0 energy, and gains 5 every 15 minutes, but has a maximum of 100 energy. How would I be able to both store this in a database, and then recall the data later, to figure out how much ...
2
votes
1answer
899 views

merging box colliders for optimizing

Look at the picture. The figure on the left shows the individual box collders in green. The yellow boxes on the right are the results of the optimization of the original box colliders. What is the ...
6
votes
2answers
199 views

Limiting number of user clicks to reduce micro: best method of implementation?

I'm making a client-server game where the user can select armies and move them from one place to another. In a bid to reduce the advantage of "being able to click faster" I've decided to implement ...
1
vote
0answers
30 views

Creating Smooth Corners when Converting 2D Polylines to 3D Models

Part of my game takes SVG polylines (which are just basically a set of x,y coordinates that define a multi-segment line) and converts them into 3D 'paths' (ie. a line created as a set of faces all ...
2
votes
2answers
262 views

Using a vector to measure an angle relative to the screen / camera

My game is supposed to have an object that changes it sprite depending on which way the mouse faces. programming this has become a challenge, because I want to calculate the angle relative to the ...
8
votes
3answers
3k views

How to optimize pathfinding on a very large dynamic 2d grid?

I have a large 2d tilemap, ranging anywhere from hundreds to thousands in size. The map is formed by 8x8 chunks. I am currently using A* but it isn't quite efficient because I may have as many as a ...
2
votes
1answer
651 views

How does D* pathfinding work?

I would like to understand on a fundamental level the way in which D* pathfinding works. Any code or psuedo-code implementations as well as visualizations would be helpful.
2
votes
1answer
269 views

Is this a suitable “pathfinding” algorithm for a tower defense game?

Note: I put "pathfinding" in quotes because I'm not sure if it's the proper term for this. My goal is to create a 2D tower defense game with HTML5/JavaScript. It's mostly for learning purposes, so I'...
3
votes
2answers
165 views

What algorithm can I use to distribute energy between connected nodes?

I'm creating a game where every user has a network of connected nodes that each have a specific amount of energy. The nodes will try to distribute energy evenly amongst themselves. If a node has more ...
5
votes
2answers
1k views

How can I fill the interior of a closed loop on a tile map?

In my game the player can dynamically modify terrain. The map is stored within a 2D array of prefabricated 3D objects. This is working well for now. The player modifies terrain by selecting what ...
8
votes
0answers
72 views

Is there an algorithm to move vertices along a planar mesh to give an area more vertex without destroying the shape too much?

Currently, I am playing around with a terrain technique called Vector-Field terrain as created and used for the game Halo Wars. I have successfully recreated the technique. However, I'm having ...
1
vote
2answers
66 views

Find points inside a closed area

I have a 2D rectangular grid (100x100) with 3 types of cell (Empty, Base and Outline). I need to find cells inside the territory formed by Base and Outline cells. For example, in this scheme: I need ...
2
votes
1answer
79 views

Numerical differentiation to calculate size of circular buffer

I'm using Allegro 5 to create a software-generated "motion blur" effect for my 2D sprites. I basically just have a boost::circular_buffer of some length which holds "snapshots" of the sprite going ...
4
votes
1answer
585 views

How to convert a premade mesh into voxels so I can use algorithms such as marching cubes

I have a mesh that was created in a 3D program which is the terrain the player will walk on. I want to allow the terrain to be deformable by the player, but for it to be smooth (not like Minecraft). ...
1
vote
1answer
185 views

How to calculate a projection of 360° equirectangular slides?

My goal is to have a light source inside of a transparent sphere that has an equirectangular texture to act as a 360°-slide. I want to get the projection on arbitrary objects as a texture image on ...
1
vote
0answers
205 views

Letting an Pathfinding Algorithm generate movement paths for all possible Connections in a Starsystem-based Universe

First of all I want you to forgive me when I make mistakes in my writing, english isn't my first language, and also: If this is the wrong place to ask, please direct me to the right place then. So, ...
5
votes
1answer
524 views

Train-like movement in a 2D game

I am developing a 2D game using Cocos2d-X in C++ language. In my game, I need to implement train movement. Here is the image about the output I want to achieve: I tried to do the above moment using ...
4
votes
3answers
2k views

How do modern game engines handle many shadow casting lights?

This is a very general question, and not aimed at any particular language or graphics API; I am more interested in the theories & algorithms behind the solutions. I'm reasonably familiar with the ...
1
vote
0answers
73 views

Generating vertices for group of hexagons

I'm working on the map editor of a game, where you can create a grid of hexagons to paint. An example of a grid of radius 6: What I want Once map creation is done, I would like to generate a mesh ...
3
votes
1answer
399 views

Creating a Simple Puzzle resolution Algorithm

I develop a (really) simple puzzle game that asks you to join a point A to a B (enter/exit) using a ball and mechanisms that you can rotate to give the correct direction to the ball in order to join ...
3
votes
2answers
2k views

How does transvoxel algorithm work and how can I implement It?

After wasting over three days of researching on DuckDuckGo/Google, trying to understand transvoxel paper and existing implementation, I come here to clarify the subject for me and made it easier for ...
3
votes
3answers
288 views

Drawing roads on heightmaps

I've been running into walls for the past week or so on my toy project in UE4. My goal is to draw procedural roads on a procedural landscape (eventually getting to intersections and buildings). The ...
4
votes
1answer
145 views

Convert 2d generated level to graph or analyze

Do you have any idea how to extract graph data from this type of procedurally generated level? Well, actually we need to analyze only top level (gray). Background (black) does not matter. What I am ...
0
votes
1answer
141 views

A* Implementation broken?

I tried implementing Wikipedia's version of the A* pathfinding algorithm, but when I run it in Unity the object which the script is applied to does nothing and Unity ends up taking 15% of my CPU. I ...
1
vote
1answer
109 views

Solvable mazes that have contained cells

Is it possible to create a random maze that is solvable and uses a group of cells or single cells that do not depend on the cells around them? I am using a visual language that uses self contained ...
3
votes
1answer
202 views

Triangle Texture Packing Problem

I'm trying to create a texture atlas where each triangle face is laid separately from each other (i.e. it is not typical mesh parameterization). In order to do this, I would have to pack the triangles ...
7
votes
2answers
235 views

Generate random people with demographics

I would like to have random people with preferences generated for an economic strategy game. For simplicity, lets say each person has age(number), home area and its type (city,village,...) and ...
0
votes
1answer
352 views

minimax AI code stuck in a loop

Disclaimer: First time trying to implement a AI using minimax approach (its a turn-based game). There are not many good resources available online to learn AI (specifically minimax in C#) so I am ...
0
votes
1answer
669 views

How can I manage weapon recoil?

I have some trouble to do a Recoil routine. I've a Tank, a turret cannon on it. I want that after shot, turret fast recoil back, than (slowly) get back to start position. This is the code I've ...
3
votes
1answer
780 views

How to smooth jagged pixel edges in Unity?

So I am reading an image from a png file into a 2D sprite. This sprite serves as a "province" in my game. Currently, I am getting this: If you look closely, you will notice that you are seeing the ...
1
vote
1answer
178 views

Path finding: avoid being surrounded by enemies

I'm building a bot that plays a simplified version of Pac-Man. The bot does a pretty good job, but sometimes it chooses a path where it ends up surrounded by enemies. Here is an example: ...
0
votes
1answer
376 views

A* algorithm works silly with heap

I'm trying to use A* and visualised it, but when i add a heap optimization it start looking in incredeble ways sometimes normal(better then next to be sure), somtimes he looks on few columns. Normal ...
1
vote
2answers
2k views

HPA* Pathfinding, building the hierarchical graph is too slow

So I have a graph, roughly grid shaped, that is about 300*300 nodes large. Even at this size, however, traditional a star takes 20 seconds to run in some cases. So I implemented an HPA* algorithm to ...
0
votes
1answer
177 views

Möller-Trumbore false positive result in specific point

I copied code from this whitepaper and i can't figure out while it gives me false-positive intersections. Here's problematic values: Triangle points: (100.0, 100.0, 100.0), (-100.0, 100.0, 100.0), (-...
1
vote
2answers
66 views

What is the best practice to handle event with order?

When you play card games, you always face some abilities and effects will be triggered at the same time. To resolve this, players relies on the rules. For example, if a minion dies, it triggers ...
1
vote
1answer
81 views

Creating an Array of 1s and 0s (with all 1s touching)

I am a novice programmer trying to add an unnecessary and complicated element to a text adventure! ...and I've run into a question I am not sure how to research further (I suspect due to lack ...
0
votes
1answer
54 views

Recognize that user has traced a path of vector points with mouse

How can I check if a player has traced a closed vector shape from an arbitrary starting point all the way around to the beginning? Setup Given are the vector points A through E, which form a closed ...
3
votes
2answers
264 views

Avoid unreachable rooms in duengons

Good evening. Im currently trying to create a Dungeon Generator . First I place randomly some rooms. Right after that I dig in a randomized maze. But sometimes it happens that some rooms or even ...
0
votes
0answers
38 views

How to compute forces on objects

Say I have N bodies that moves and potentially collide. I can then compute the net force as ...