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

4
votes
2answers
697 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: How can I detect that cables are ...
3
votes
2answers
116 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 ...
0
votes
1answer
75 views

Calculating unique ID number from a set of bitmasked tiles

So I write this kind of match3-style game where you as a player need to match tiles with three or more of the same type and I'm thinking what is the best method to recognize the shapes without writing ...
1
vote
1answer
46 views

How to combine dynamic asset reload and texture atlases? (rectangle packing with removal)

Usually texture atlases are built either: as a seperate content pre-processing step or once when the game starts What I want to do is create and update atlases on the fly when: A new texture ...
4
votes
1answer
88 views

How to solve Sweep and prune false positives concerning large floor plane

I am developing a 3d sweep and prune module for a project, and it is producing false positives. The pair generation code is as follows: for (unsigned int i = 0; i < mXExtents.size(); i +=2) ...
3
votes
3answers
67 views

Computing a full revolution for an arbitrary orbit?

I'm making a game in which the goal is to get as many planets as possible to orbit around a star. The user launches planets at any distance away from the sun (as long as it's on-screen), and in any ...
6
votes
1answer
126 views

Minimum number of moves algorithm in Java

I'm looking to implement the minimum number of moves algorithm for the java game I'm developing but I can't quite figure it out. Here's an example picture: There are also some specifications ...
3
votes
0answers
40 views

What algorithms are used for force dispersal between rigid objects attached by joints?

I have in mind a 2d, side-scrolling game which requires the construction of vehicles and/or structures built of conjoined rigid structures, like beams or platforms. These structures will be impacted ...
2
votes
1answer
95 views

How can I remove unnecessary nodes from my path?

How do I remove the unnecessary nodes from the path to make it as short as possible? Idealy I'd like the result path to look like the green line. The red thingy is not walkable. var ...
4
votes
2answers
157 views

Generate Geodesic Sphere from Hex and Pentagons

I have two polygonal meshes, a hexagon and a pentagon (They are tiles in a strategy game). I want to use them to construct a geodesic sphere ...
0
votes
0answers
20 views

Timed Line Drawing

I'm trying to program a remake of the classic Missile Command Atari game from scratch, but I've run into a problem. So I have a function that can draw a line from one point to another. I figured I ...
0
votes
1answer
81 views

Liang-Barsky Line Clipping Algorithm

Is it possible to generalize Liang-Barsky Line Clipping Algorithm for n-dimensional space ?
2
votes
2answers
114 views

How do I find the set of regions that are fully enclosed by a color?

How do I get all areas surrounded by a certain color in a multidimensional array? For example, this map has three regions that are fully enclosed by red tiles. They are highlighted enclosed in pink. ...
3
votes
1answer
120 views

Transparency sorting in 3D world with different render types

I am rendering a world, object, and models from an older game format. The world is presented in a BSP tree so I can quickly iterate through. The opaque surfaces are rendered front to back. Then ...
5
votes
2answers
198 views

Diamond square algorithm

I'm working on generating terrain on already generated landmass. The landmass and ocean around it consist of hexagons. Hexagons aren't really a concern for me, because I can always interpolate the ...
6
votes
1answer
342 views

How is Signed Distance Field Ray Marching implemented for a dynamic world?

I think I understand the basics of Signed Distance Field Ray Marching. You model your scene with a bunch of distance fields (such as these: ...
0
votes
2answers
102 views

Connect phone to computer? [closed]

In order to test out my game, I need to use my real life device. The problem is, android studio isn't recognizing my device plugged in: The problem: My device isn't getting detected in android studio ...
0
votes
1answer
40 views

Generating Formulas for glDrawElements with Tile Grids

glDrawElements can be used to save you from uploading a lot of vertices to the GPU. Many 2D games use tiles, which are rendered in grids. I have done some experimenting with the indices array. For a ...
1
vote
1answer
153 views

How do you rotate all the objects around the camera?

If I'm correct, the way that you can "look around" in an environment is that you rotate all the objects around the camera. This is the code that I've created using JavaFX 3D. So what's the algorithm? ...
3
votes
2answers
168 views

How to avoid Walls in A*

Well I had a problem with the implementation of my A* algorithm in C# for unity, and I don't realize how to prevent the diagonal movement and the cross walls, I had the next code, the print line's are ...
3
votes
1answer
86 views

How to make “Shaky mouse cursor” Before shoot the target Like in a Dart Game?

I develop a shooting game. To make it harder I want to make the reticle shaky/move randomly. I use Robot class to move random as suggest here. But I modified it by adding an infinity loop and by ...
2
votes
0answers
50 views

3D Zoom To Mouse Cursor accounting for Change in Camera Pitch

Overview: Simply put, I'm trying to make a zoom to cursor algorithm. This would normally be very simple, but the implementation of the camera is making it difficult. As the camera zooms in and out, ...
3
votes
5answers
632 views

Want to play 1 of 3 tracks depending on current level

I want to play a gameplay music track depending on what the current level is. E.g. 1 - Play track 1 2 - Play track 1 3 - Play track 2 4 - Play track 2 5 - Play track 3 repeat... 6 - Play track ...
2
votes
1answer
216 views

How to calculate delta time with SDL?

I have heard that you can calculate delta time with two functions called SDL_GetPerformanceCounter and SDL_GetPerformanceFrequency. I'm not sure how they work completely, but I heard it is a bit ...
2
votes
0answers
166 views

How do i add a rain effect to a top down design game in Java, using no external libraries?

I'm creating a top-down game for my A-level/college computer science project, and I'm trying to implement rain. The game needs to be usable on any platform, so the use of external libraries is out of ...
2
votes
1answer
30 views

Returning a List of coords for a sphere in order of inside to outside

I'm looking for any algorithm that can return a list of Vector3 coordinates that form a sphere. If you read the list from the beginning it would appear the sphere was expanding. The only algorithms ...
1
vote
0answers
63 views

Movement algorithm for Pocket Civ game

I am developing a Pocket Civ game engine. (You can check the process at www.pocketciv.com). Basically there is maximum of 8 Areas (round nodes in the pic) that have Tribes (number inside the node). So ...
1
vote
1answer
78 views

common math algorithms that aren't physics/object based [closed]

I'm starting to customize my game a lot more beyond just the engine and I'm curious what sorts of algorithms and concepts exist. There are a ton of solutions for physics and geometry-like questions, ...
2
votes
0answers
52 views

GPU Spatial Clustering

I have a around 100k points on the screen (that might update). 2D points. The goal is to cluster them into groups, by a constant distance. Meaning, finding groups of points that the distance between ...
3
votes
2answers
225 views

How to compare different states of my game? (rpg)

I'm working on a rpg, the battle system. I want to compare different scenario with each other. For example, what if I play move A then move B ? or two times move A ? or ...? I'm using a ...
3
votes
2answers
90 views

Putting items into a 3D space

Imagine a fridge and a bunch of random foods. I want to take one food item, automatically put it somewhere in the fridge, and repeat. I can stop at any time. Basically, the filled fridge should look ...
2
votes
2answers
99 views

Algorithm for spending x points on y things divided by n people

I'm trying to devise an algorithm to spend a given amount of points on a randomly generated list of items each with their own cost in a way that results in having a number of items that is divisible ...
4
votes
1answer
159 views

Generating 'Specially' shaped rooms for a Dungeon

I've made a fairly simple dungeon generator but now I want to expand on it so that I can procedurally generate a dungeon with irregular shaped rooms. I don't just want any old crazy shapes popping up ...
0
votes
2answers
152 views

Exponential EXP Curve | FIXED TIME -> MAX LEVEL

I have yet another experience equation question, with a slight twist. Problem Situation Player gain experience from Level 1 - 80. Time to level from Level 1 to 80 grows exponentially. There is a ...
0
votes
1answer
68 views

How are loot box labels positioned?

Take this screenshot for example: How exactly are they positioned perfectly adjacent to each other? Do they already create the label positions based upon the world map first, and then when the ...
3
votes
1answer
107 views

Calculate visible points in grid in 2D game

I have a game grid and I need to figure out which game grid points are not behind occupied grid point from players view. The visible points. I'd like to define a visible point first, because it can ...
1
vote
1answer
82 views

My attempt at a drunkard walk algorithm seems to generate large groups instead of more linear paths

...and I'm not sure if that's normal due to the random nature of the algorithm or am I doing something wrong. What I'm doing is: Set a random point within map boundaries (which I called a sandbox). ...
4
votes
2answers
154 views

Graph search with a high number of actions

I have implemented A* to reach a goal state from a start state. My state is position X,Y, angle and others state variable. I have a number of actions. What I call actions is : A* on a grid has 4/8 ...
3
votes
3answers
307 views

Find two points in a point cloud with the maximum distance?

What is the least computationally complex way to find two points such that the distance between them is greater or equal to any other pair. Remember hearing something about how you could find such a ...
-2
votes
1answer
121 views

Why is my delta time constantly under 1 millisecond?

I have a game loop that looks like this: while (Sync()) { DoStuff(); } The sync function computes my delta time like this: bool Sync() { EndTime = GetTime(); DeltaTime = (EndTime - ...
7
votes
3answers
462 views

How should a circuit or power system (like redstone in Minecraft) be implemented

I want to implement a power-system like the redstone system in minecraft. I have n power sources and m cables. If I disconnect the power source or a cable the circuit should turn off. How do I ...
0
votes
1answer
91 views

Most efficient way for nested loop to not repeat a value of parent loop in pair-wise structure (C# or Javascript) [closed]

It's hard to choose the correct title for this question, so let's see if I am able to better convey here what I am in search for. If the title is too far away, suggestions are welcome and I can edit ...
2
votes
1answer
247 views

How to implement view bobbing?

I'm developing a First-Person shooter game. Everything is just fine but I've a little problem with my camera moving. My FPS camera is moving smoothly! But the camera should move like a human is ...
0
votes
0answers
55 views

Marching cubes and greedy meshing

Currently i am trying to implement the marching cubes algorithm into my voxel engine to get smoother terrain. My voxel engine also uses the greedy meshing algorithm to optimize the engines meshing. My ...
17
votes
2answers
2k views

Matching a chunk of procedurally generated world to a chunk of other world

Have you read The Chronicles of Amber by Roger Zelazny? Imagine yourself playing in 3rd person MMO game. You spawn in the world and start to wander around. After some time, when you think, that ...
5
votes
2answers
183 views

Are hard coded “rooms” better than dynamically generated on a smart phone, from performance point of view

This question pertains to a type of platform/maze game (made with Unity 5) for typical smartphones (iOS/Android). This game has following characteristics: 1. an upper limit (about 100) on the amount ...
0
votes
1answer
166 views

Improve (adding randomness) minmax algorithm for Connect Four

I have implemented the minmax algorithm for the Connect Four game. It works well (almost...), but if the player does the same moves, the computer will do the same moves as well, for each match. There ...
4
votes
1answer
60 views

What is a viable way of finding the minimum swaps to sort numbers in pyramid?

I have made a game that consists of a pyramid of hexagons with numbers from 00 to 99 randomly positioned in groups of 6, 10 or 15 elements. Now, I'm working to create an auto-solver but for the last 2 ...
2
votes
2answers
132 views

Funnel algorithm

I'm implementing the funnel algorithm for pathfinding. After searching many resources I found those : https://skatgame.net/mburo/ps/thesis_demyen_2006.pdf ...
5
votes
4answers
225 views

Good algorithm to generate pixels for thick line?

I am not really making some drawing as of picture manipulation but I use line function to calculate "claimed" pixels in my line race game (demo here): The actual rendering is apart from the game ...