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.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
25 views

Calculate index of bottom left block on a mxn grid

I am working on a board game that requires me to color the bottom left corner of the board with random number of rows and columns a different color from the other blocks. Given an m x n grid, how do I ...
user avatar
0 votes
1 answer
25 views

Algorithm to get all the blocks to the top and right of the current chosen cell in Chomp game

If I have a grid of 4x4, I want to get all the blocks/buttons in java that are to the right and top of the chosen block, how would I write an algorithm for it? For instance if the user picks the block ...
user avatar
0 votes
1 answer
46 views

Trying to generate a Tile labyrinth in Unity

So I have a generator code that renderes a TileMap on the scene, but It keeps creating a sollid block of walls Where I want it to have empty cells(This is not the final algorythm(Recursive ...
user avatar
  • 11
9 votes
3 answers
2k views

Maintaining unit formation while following path

I'm currently working on a 2D Age of Empires style RTS game. Here's my problem: I'm currently using the A* algorithm (via Path finding package) to move my units. When you select a "group" of ...
user avatar
0 votes
0 answers
39 views

How to quickly calculate the number of tiles between buildings in a tile system

my friend and I are currently working on a city builder game like Anno/Cities Skylines but with some own ideas and tweaks. (of course, on a much smaller scale) Currently, we are struggling a bit with ...
user avatar
  • 1
1 vote
1 answer
36 views

Determine if a triangle is on the screen

I am working on a small software renderer, and I want to discard invisible triangles from the drawing process. Let's say I have a screen with resolution of 200x100 pixels. The triangle is defined with ...
user avatar
1 vote
1 answer
102 views

Find closest open space in grid of rectangles?

I'm making a builder game where you snap arbitrarily sized rectangles into a 2D grid. I want the player to be able to drag and drop these rectangles anywhere on the grid, but prevent collisions (i.e., ...
user avatar
  • 13
0 votes
0 answers
10 views

aiming prediction in 2d game using projectile [duplicate]

I am trying to make an agent predict the velocity required to throw a ball at a target and take into consideration the target. So what I need is a ball following a projectile path until it hit the ...
user avatar
1 vote
1 answer
30 views

Detect if a chain of tiles form an enclosed shape/contour [duplicate]

I'm looking to determine if in a tilemap if a set of tiles of same color in a chain (either right next to cardinally, or diagonal) is forming a closed shape and to detect the tiles inside the said ...
user avatar
0 votes
0 answers
45 views

How to render the border of a collection of many overlapping radii on the surface of a sphere

I am developing a 3D game with THREE.js where all players are represented as points on the surface a sphere. The player A can move on the surface of the sphere within a radius of X meters. If another ...
user avatar
  • 1
1 vote
1 answer
58 views

Determine if a static mesh is lit by directional light

I want to determine if a mesh is lit by the directional light on my scene in editor to automatically disable its "dynamic shadow casting" property (let's say I have one light source in my ...
user avatar
0 votes
2 answers
77 views

How to find words on a hex grid

I am trying to make a hex grid based word game. Currently the words are placed from a list of pre-defined words(a list of animals in this case). All colored cells make a word that was placed, while ...
user avatar
0 votes
0 answers
49 views

What is the most efficient way to detect collisions of a large number of similarly sized objects?

Also, the maps are around 4000x4000 (pixels) So, all the objects in my game are 2D circles, and they all have a radius of between 5 and 10 pixels. My current solution is to use a spatial hash where ...
user avatar
1 vote
1 answer
117 views

How to generate boards for a game like GamePigeon's Word Hunt?

Naively, I would assume that there's an even probability of any of the 26 given letters appearing in a tile and that each tile is generated independently. After playing around a hundred times, though, ...
user avatar
0 votes
0 answers
41 views

Projectile Aim Prediction with Target Acceleration and Bullet Deceleration Varying with Angle

I previously asked a question about this topic here, and now I'd want to review if the offered solutions worked, and then frame a new inquiry based on the difficulties and issues that resulted. So my ...
user avatar
1 vote
1 answer
48 views

How can I implement an algorithm to mix potions?

I would like to build something that allows me to obtain potions using two identical lists of ingredients. ...
user avatar
  • 257
0 votes
0 answers
30 views

Finding connected values of the same type within a 2D array

I am currently working on a puzzle game where blocks drop and you match nearby colors Blocks are stored within a int 2D array that stores with a value between 1-3 once placed, and it should find ...
user avatar
0 votes
1 answer
60 views

In a portal-based engine where Items are owned by a room, how to do inter-room collision detection?

My engine consists of Rooms. Rooms are connected via Portals. Items have a roomNumber field to indicate which room they belong to. And rooms have a linked list of ...
user avatar
  • 641
0 votes
0 answers
69 views

Balancing random chance

I'm working on a text-based RPG incremental/clicker game. One of the features I'd like to implement is a 'bloodline' system; Every user gets a one time random chance to 'roll' for a bloodline. ...
user avatar
  • 113
2 votes
2 answers
88 views

Understanding use of "localUp" in planet mesh generation code

I'm following a tutorial on YouTube about procedural generation of planets. I'm puzzled in some aspects of the code shown. If any of you could explain the following points, I would be very pleased. ...
user avatar
0 votes
2 answers
66 views

How to check multiple rings of tiles around a center tile on a 2D grid

In my game project I create the terrain programmatically by creating tiles on a 2D grid as the player moves around the game map. I have it working where I select the current tile and check all 8 ...
user avatar
  • 145
0 votes
0 answers
26 views

Algorithm to create adjacent cubes while updating neighbour pointers

Following problem: I have a class node. Each node holds 6 pointers to its neighbours. I recursively check for nullptr while creating them but that leads to double declarations of the same node. I am ...
user avatar
  • 1
1 vote
0 answers
55 views

Fast way to test whether a point is over a 3D mesh

I have a map with islands, and I need to detect whether the player is on an island or not. The player can be flying far above the island, so a fixed-distance raycast is not sufficient, and firing long ...
user avatar
  • 241
1 vote
1 answer
87 views

Optimal way to find the closest entity to player with a restricted set of functions

The scripting engine of Skyrim (and Fallout 4) has an interesting function called FindClosestActor(x,y,z,radius). If you call it with x,y,z center coordinates and a radius, it returns the closest ...
user avatar
-1 votes
1 answer
91 views

Best way to save game in story game

In a while I plan to create a story game that would have different routes and endings and I was wondering what would be the best way to save a game of a game like this, if it would be a folder, ...
user avatar
  • 1
7 votes
2 answers
4k views

How to calculate player damage in a game

I'm developing an RPG and I want to do the damage calculation in my game. I have for example the following situation: Player 1 Stats: ...
user avatar
  • 197
0 votes
1 answer
28 views

Given a set of points with color values, finding a gradated color value from a given position

I guess the verb form of gradient is "gradate" and not "gradiate"? Hi! I have a set of 2D points (actually 3D, but we can ignore the Y axis unless it's trivial) bound to color ...
user avatar
0 votes
1 answer
44 views

Need help on finding the algorithm for getting the FlipX, Y and TextureRotation of my DirectionalAnimation class

I've created a class called DegreeAnimation, which is basically an implementation of my CustomAnimation class, but works with other directions, there are 2 constructors for this class, one where the ...
user avatar
1 vote
1 answer
76 views

Dividing amount of exp between rank A and B into a curve?

In my game I have a rank system. You start at rank A, and then you can level from level 1 to level 10. When you reach level 10, you get promoted to rank B, and you go from level 1 to 10 again, and ...
user avatar
  • 113
0 votes
0 answers
24 views

Aim assist-- How to cast a wedge in screen space

My character exists in a 3D, isometric, top-down world. I'd like to make an aim assist mechanic, such that when holding the right joystick in a direction the game will choose the enemy roughly in that ...
user avatar
  • 143
0 votes
1 answer
113 views

Extracting cell center and corner points from rasterized Voronoi diagram

I currently have this code which I copied from Rosetta code: ...
user avatar
1 vote
1 answer
132 views

Rollback netcode: how to avoid teleportation?

I've currently implemented rollback netcode with a central, authoritative server (wooh!). I'm running into issues where if players have zero input delay, the other players see them "teleport"...
user avatar
0 votes
0 answers
49 views

In-game computation of heat maps OR pre-computed floyd warshall algorithms for AI path problems

I am working on a project, in developing a simple game. We need to have bots that shoot, ram, flee and chase other bots/players. Currently, I pre-compute my Floyd warshall algorithm so it is ...
user avatar
0 votes
1 answer
88 views

Check if a procedurally generated maze built out of cubes is solvable

I have created a procedural level generator in unity. However, occasionally the algorithm creates a level that is impossible to solve. Therefore, I tried to implement a navmesh agent to check if it is ...
user avatar
2 votes
1 answer
236 views

How can I build an accurate 15-bit Highcolor RGB palette

I want to recreate an accurate version of a 15-bit RGB color palette (PC Highcolor, SNES, Playstation 1), storing each color from the palette as a standard 6 digit hex code. With each color component ...
user avatar
  • 151
2 votes
3 answers
808 views

How to read a sparse Octree sequentially, like a 3D array?

Is it possible to read a sparse Octree like a regular 3D grid: for(z) for(y) for(x) ...and still benefit from skipping large empty areas? I need this for a ...
user avatar
  • 161
0 votes
1 answer
97 views

Confirming whether a user has drawn a character correctly

This is a follow-up post to this post: How can I check if a player-drawn line follows a path?. I'm having difficulty implementing the said feature and I believe it's because of a lack of math ...
user avatar
  • 103
1 vote
1 answer
50 views

How can I remove unnecessary vertices from wall edges?

I've got a pretty simple tile based 2d top-down map with an array of walls. In order to figure where to cast light and shadows, I've generated an array of vertex coordinates along the walls like so: ...
user avatar
  • 11
1 vote
1 answer
57 views

How to draw splatter (one color) on 2D grid to cover approximate number of pixels? (looking for algorithm/math answers)

Imagine a 2D grid, where water stain increasing because of water drops. But not in plain circular way but more like noisy-splatter way. Or like corruption way. I want to create effect that will ...
user avatar
  • 145
0 votes
1 answer
60 views

Connecting rooms after BSP

...
user avatar
1 vote
0 answers
31 views

How to implement a big audio source and a cluster of audio sources?

I have a 3D game. The sound engine supports: playing ambient music to the player (two channels always the same) playing static sounds from a single position in space playing mobile sounds from a ...
user avatar
  • 188
1 vote
1 answer
175 views

How does a game like slither.io handle collision?

This question can be generalized to "how does one efficiently determine if a collision has taken place between curvy lines" On https://slither.io there are snakes that players play as that ...
user avatar
1 vote
1 answer
80 views

How do I create an event trigger system for a Discord bot?

I am making a card game and I am having issues implementing "effects" and effects that are continuous. How can I get effects to activate at the right times, before and after an attack does ...
user avatar
0 votes
1 answer
58 views

Recycling bullets versus spawning them on demand

Until now, I know 2 bullets' algorithms/configurations : (I mean 2 ways of logically creating a bullet class) Make a bullet class and create only one instance from it that represents the bullet. The ...
user avatar
  • 216
1 vote
1 answer
53 views

Making Sprite Movement Appear More Natural

Currently I have a 2D game in which the player and a computer controlled (non-player) sprite move from point to point collecting tokens in a continuous environment. The player and the non-player ...
user avatar
  • 111
2 votes
1 answer
67 views

Space out units to a grid pattern

So imagine an RTS game, with ~150 units all cramped together, just staying chill. What I would like is to "space them out" so that they d form a grid. This is useful for example when a large ...
user avatar
  • 121
2 votes
2 answers
96 views

Need help with fixing Optimized Raycasting / Line of Sight algorithm

I'm trying to implement collision detection with raycasting for my 2D javascript game. The game uses equally-sized tiles as its level structure so to optimize collision detecton I'm trying to use a ...
user avatar
2 votes
0 answers
38 views

Finding a path to a circular zone in continuous space [duplicate]

I need to find the shortest path for an agent that wants to use a ranged attack against the specified target. This means that the path's ending point should be inside the range of the attack and have ...
user avatar
  • 121
4 votes
2 answers
139 views

Can't figure out math for converting negative indices of my voxels and chunks to positives

In my voxel game, I'm trying to spawn chunks in all directions. But since my world starts at 0,0,0, some chunks can spawn at negative positions like ...
user avatar
  • 541
0 votes
0 answers
70 views

Making a level progression system similar to Bravely Default's

So I am working on an RPG and I want the level up system to be similar to Bravely Default's, which must be similar to how FF classically levels up characters. What I know about the level up in the ...
user avatar

1
2 3 4 5
23