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.

learn more… | top users | synonyms

2
votes
1answer
228 views

How do I avoid pathfinding characters getting stuck in corners?

I used A* pathfinding to return a list of Tiles to get from an enemy to the player. After that, I wasn't sure how to actually move the enemy. What I ended up doing was get the first Tile in the path. ...
0
votes
0answers
25 views

How to reduce n^2 complexity when checking for collisions and attacks? [duplicate]

I have a snake clone game, but each element can attack enemies and enemies may attack elements in snake. They all have range of attack, and what I do is every time my update loop triggers (60 times ...
0
votes
1answer
342 views

Hearthstone suggest a card algorithm [closed]

Does anyone have an insight of the suggest a card algorithm in hearthstone deckbuilding? I would like to try to see it that same suggestion can be applied in MtG, having for example to choose your ...
3
votes
1answer
72 views

Field of view determination with partially opaque cells

I'm currently implementing the field of view of a player in a 2D-grid based game. I've chosen a standard ray tracing algorithm because he really fits the features needed in my game. However, the ...
2
votes
0answers
81 views

Astar optimalization (A*) [closed]

So I have written own implementation of AStar (A*) algorithm to find paths around my 2d tile based map. My problem is that if I call it each frame (I need to do it) and I'm searching path from corner ...
3
votes
2answers
268 views

How simulate the return effect of the wheel of fortune needle

I am trying to create a spinning wheel which slows down after a specific time. I managed to simulate the slowdown of the wheel but I need also to put a needle which go up and down with an angle of ...
0
votes
0answers
34 views

How to combine vertex, normal, UVW arrays optimally?

In Unity, meshes have multiple arrays for various vertex components (Normal, Position, UV coord, etc), and triangles consist of three indices that define the (same) offset into each array to build the ...
13
votes
2answers
582 views

How can I generate a lightning bolt effect?

Is there an algorithm to generate a lightning bolt? I would like an algorithm that generates a list of segment or point objects specifying where the bolt will land. The method would need a start ...
4
votes
1answer
105 views

Pathfinding avoid a list of polygon

i'm working on a 2D RTS project, no tile-based map. I have a problem on building map data structure & algorithm for that. I already think of a naive algorithm to solve that. Of course it's very ...
7
votes
3answers
283 views

How can I add and subtract convex polygons?

I have two 2D convex polygons overlapping each other. I am looking for an algorithm to subtract and add them. The result must be a single concave polygon or (even better) a set of biggest convex ones ...
-1
votes
1answer
273 views

Tower Defense Search Enemies Efficiently

I had a problem with the build of a TD. I got a slow - non efficient search for towers find targets to shoot. PD: enemies[] got all the active & non-active enemies (death and alive) ->Im using ...
0
votes
0answers
48 views

Java Angle Math: Calculate how near the player looks to an entity [duplicate]

I am programming a Minecraft Bukkit plugin and need a way to calculate an input number from 0 to 360 for displaying a custom compass / radar. So if the player directly looks at the object (shouldn't ...
3
votes
1answer
185 views

How to create a grid based on random shapes?

How to create a "grid" using actionscript like the image below? Basically you have an area of 1100x615 which should be filled with shapes that could be rotated and scaled... Collision detection ...
0
votes
4answers
316 views

Carve river beds into existing 3d procedural generated terrain

Ok, I've read many threads around about procedural terrain generation with rivers and roads but they suggest approaches from zero to result. I'd like to know if exists an algorithm to apply to an ...
3
votes
1answer
238 views

Verify which bubble is connected to top using DFS

I am working on a bubble shooter game in this game i have implemented searching using DFS as suggested in this link, and this is working fine. Update Here is my code for DFS ...
1
vote
1answer
151 views

Angular velocity from 2D Collision

I have been working on a 2D physics engine for my A Level computing project and I am having trouble calculating the angular velocity from a collision. I have managed to workout each objects linear ...
2
votes
3answers
159 views

How control probability of win-lose in tile-matching games?

In a random puzzle game, such as a match-three game, how can you control the probability of a winnable starting condition?
1
vote
1answer
161 views

Scanning a 2D tile map and detecting regions?

I have access to all points/tiles on the map with top-right most point being (0,0). Simplest way to traverse the map would be using for loops, one nested within the other to traverse the x axis, and ...
2
votes
1answer
56 views

How can I cut a graph representing 2D positions into two sub-graphs?

I have a graph where each node is associated with a 2D position. I would like to use a finite line to "cut" this graph into two halves, as shown below: Note that the cutting line does have a ...
2
votes
1answer
307 views

Match-3 algorithm to fill empty space left from removing matches

I am currently creating a match 3 game. I am at the point where I have objects dropping down in the column when only one item is removed. So if an item is removed, the above item moves into its old ...
5
votes
3answers
149 views

Pathfinding Search for Path of Specific Length

I am creating a roguelike. This question applies to random map generation. First, I generate areas using a BSP algorithm, where I randomly divide the map into areas. Then, I generate a graph of the ...
4
votes
2answers
173 views

Exists a dedicated non-O(n²) Algorithm for avoiding to have overlapping elements?

I am generating positions in a random fashion. In the game world, instantiated elements have a radius, and shouldn't overlap. The problem is that they will overlap because I use a usual random ...
4
votes
2answers
305 views

How can I adapt “random walk” generation to very large maps?

The random (or drunkard's) walk is a great, simple algorithm that can generate very organic-looking maps, such as this: Unfortunately it seems to have poor scalability, making it unsuitable for ...
12
votes
1answer
659 views

How does the Simple Stupid Funnel Algorithm work?

Working with the funneling algorithm shown on Digesting Duck I'm not sure how the detection of the funnel works. Can someone explain the method clearly to me or suggest an alternative way of ...
2
votes
2answers
111 views

Calculation: Is a sphere/square/plane visible from a certain point?

I'm searching for a way to detect if a form (shape can be changed if algorithm requires it) is visible from a single point in a 3D tile-based world. This should be used as some kind of wall-hack ...
1
vote
1answer
328 views

Pipe connection game algorithm - Java/Andengine

I am creating a game based on Pipe Dream/Pipe Mania using java/andengine for android. I have a square grid of tiles each representing a type of pipe. The player needs to swap tiles to connect the ...
1
vote
3answers
163 views

Simulating (Human) Needs? [closed]

How can I simulate the vegetation (of a human being)? To simulate Hunger for example, I use some kind of saturation based system now. Means that every food-object saturates differently and the ...
1
vote
3answers
283 views

In a semi-infinite procedural (chunk based) map, how do you handle objects larger than a single chunk?

I'll use an example to try and be more specific. Assume this is for a 2D top-down game. Chunks in this are made up of 32x32 tiles. If procedural buildings were to be generated based on some kind of ...
3
votes
3answers
391 views

Algorithm for game difficulty/pacing curve generation in single player RPG

I'm looking at this article about pacing in entertainment and games. It suggests that all good entertainment roughly follows a pacing/engagement curve like Star Wars(below). I'm interested in how I ...
0
votes
1answer
96 views

Tennis game algorithm and maths

Tennis courts are real dimensions and game is 3D Ball has position (x,y,z), speed(vx,vy,vz) and acceleration (ax,ay,az) Game has 30 fps and on each update (1/30sec) it has these properties vx +=ax; ...
3
votes
1answer
415 views

How can I optimize this flood fill algorithm?

I'm creating a sprite and animation editor like this one. I'm having performance issues with my flood-fill algorithm. Basically, I open an image with the different modules that are part of a frame of ...
10
votes
1answer
1k views

How do Raymarch shaders work?

I have been looking at shaders found here shadertoy.com and most of the cool ones have noise and raymarch in common. I do not understand the source code at all but I really want to. How do these ...
1
vote
2answers
251 views

Filling in gaps in a grid

I have a set of terrain sprites available to represent terrain: Flat North-South Straight Cliff (x 2 allowing for slope direction either way) West-East Straight Cliff (x 2 allowing for slope ...
1
vote
1answer
94 views

Where can I find info on grid based algorithms for stateless AI? [closed]

There seems to be an overwhelming amount of info out there on AI of all kinds, and it's kind hard to digest at once. For my testing purposes, I'm creating a "typical stateless AI", as described in ...
1
vote
3answers
222 views

Randomly generating the hallways between a network of rooms [duplicate]

So here's my base map: (It won't necessarily be 5x5, just using this as an example.) It's kinda boring the way it is with all the rooms connected. I want it to be more of a randomly generated ...
1
vote
1answer
318 views

How should I generate the board for a match-3-style game?

I am trying to create a "match 3" game. I'm stuck figuring out a good algorithm to fill up the game board. My game's board is 8x8. EDIT: A few things: The board should always be solvable. for ...
0
votes
1answer
156 views

How to find a free patch of area in a tiled map?

I've been trying to formulate the question and try to find some information on Google, but didn't managed to, so here it is... We've got a nice tropic-themed game that is about to be released soon, ...
0
votes
0answers
36 views

Sprite rotation algorithm [duplicate]

I'm making a game where you have to plot a function to hit certain objectives. I already made the plotting function and the animation to display a tiny missile that travels above the function. My ...
1
vote
3answers
281 views

Why can't my A* implementation find a path out of an open room?

I tried to follow this article with the following example, but in my attempts it always ends up with a dead end. If we take G being 10 in a straight line or 14 in a diagonal, and H the distance in ...
4
votes
5answers
565 views

Goalkeeper Jumping Algorithm?

This may be a "best way to" question, so may be susceptible to opinion-based answers (which is ok for me). But I would also like if there are any tutorials , research papers , etc. I'm trying to make ...
2
votes
3answers
97 views

Divide rectangular image into fixed number of random sized rectangles + 1 fixed size rectangle

I'm trying to divide a rectangular image into a fixed number of smaller rectangular image parts (of random but bounded width / height), with the exception of 1 rectangle which is predefined in ...
1
vote
3answers
229 views

Send info about gun shots via UDP

I am writing a small multiplayer game in C++. But I am confused about how to send info about gun shots to achieve best performance. I am thinking of different ways to do that: Let's say we have a gun ...
8
votes
1answer
243 views

Algorithm to produce 'Lady or Tiger' puzzles?

What my problem is: There is a puzzle by Raymond Smullyan that works something like this: You are in a room with many doors. Behind some of those doors, there are ladies; behind the others, there are ...
0
votes
0answers
21 views

C# 2d array value check [duplicate]

I've managed to create a 2d array, then made it fill up with random numbers, like this: int[,] grid = new int[5, 5] ; Random randomNumber = new Random(); var rowLength = ...
11
votes
3answers
287 views

How to divide hex grid evenly among n players?

I'm making a simple hex-based game, and I want the map to be divided evenly among the players. The map is created randomly, and I want the players to have about equal amount of cells, with relatively ...
4
votes
1answer
258 views

Problem with SAT collision detection overlap checking code

I'm trying to implement a script that detects whether two rotated rectangles collide for my game, using SAT (Separating Axis Theorem). I used the method explained in the following article for my ...
0
votes
1answer
260 views

About the A* algorith(pathfinding)

We have a formula of f=g+h wherein g is the path cost and h is the distance left to the goal. Given that I only want to move my unit in 4 direction (N,S,E,W), my question is: Can we consider h as ...
6
votes
3answers
1k views

A-Star Pathfinding Not Giving Shortest Path

I'm attempting to implement the A* pathfinding algorithm in Java. I thought it was working well, but then I found instances where it doesn't follow the shortest path Green = start, red = target, ...
2
votes
0answers
163 views

Pathfinding with portals? [closed]

I'm not making a game with portals in it (one way or bidirectional). These portals instantly teleport characters from one location to another. How would I implement pathfinding? Here's an animation ...
5
votes
3answers
260 views

Algorithm for creating tree-like network structures

I'm trying to procedurally model tree-like network structures with the following properties: A root with variable number of nodes A variable depth of nodes When graphically laid out, edges or nodes ...