Stack Exchange Network

Stack Exchange network consists of 174 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.

2
votes
0answers
25 views

Slot Probability Function

Please can someone point me in the right direction. I'm working on a slot game. that I'm having trouble figuring how to implement the probability function for. The game has a set of symbols that bets ...
0
votes
2answers
25 views

Algorithm to detect impossible scenarios

I'm making a simple game where a surface is split up into 4 parts, rows, obstacles spawn in them, and a player tries to dodge them. Up to 3 obstacles are generated in each row, and this can lead to ...
0
votes
0answers
20 views

A* Quad/Oc Tree path-finding vs Navigation Mesh path-finding

Main What are the differences between those path-finding algorithms. Is Navigation Mesh faster in finding the path? Is it more correct than Quad/Oc Tree? Does Navigation Mesh use Quad/Oc tree under ...
-1
votes
0answers
44 views

Algorithm Design - Player obtaining level resources

Let's say a player has 50 mining, he should be able to mine a level 10 rock quicker than a player who has level 15 mining Ideally. This is what I have so far, so I think I could use some pointers: ...
0
votes
1answer
27 views

Generate a HexMap where each tile has a different tile on each edge

I’m trying to generate a 7*13 hexmap, with 9 different types of tiles, numbered 0 through 8. I need the map to be randomly generated on each run and it has to be so that each tile has a different ...
2
votes
2answers
76 views

Pathfinding with non-deterministic transitions between nodes

Consider a map not unlike a board game, where some of the moves are made non-deterministic. For example, moving onto certain cells will require you to roll a dice to determine where you should move ...
2
votes
2answers
64 views

2D walled map generation

I want to make a 2D walled map. the walls must be L,T,+,-,| shaped. (made from vertical and horizontal lines) There must not be a complete closed block (i.e. all parts of the map must be connected). ...
0
votes
2answers
51 views

Weighted random events with conditions

I'm building a system for distributing ingame events for a strategy game. The game is heavily driven by the events and each country/player should receive one or more per time unit. The algorithm is ...
0
votes
1answer
71 views

How to use grammars for procedural generation?

I am working on a system to procedural generate a house using this article. I am trying to understand how grammars work and are made I have found very little information on the topic online. From my ...
0
votes
1answer
20 views

Score multiplier based on lowest time

I'm making a score system that will be based on several factors, how many collectibles you have obtained, how few hits you have taken, etc. I want to add in a multiplier based on how quickly the ...
1
vote
2answers
200 views

How could a NPC find items that appear randomly?

My main question is basically: What is the algorithm that CPU players use in smash bros to find items like the smash ball? I am trying to make a small ai character that will "look around" and once an ...
0
votes
1answer
55 views

Unity3D: activeSelf issues

I've been trying to script some basic AI for a Unity Roll-A-Ball game, which involves two balls collecting cubes for points (one controlled by the player and the other controlled by AI. Everything ...
1
vote
0answers
25 views

Team matchmaking based on ELO score

I'm looking for a very simple way to put up 2 teams out of unspecified amount of players. So its not actually a standard matchmaking since it only creates one match out of the whole pool of queued ...
1
vote
1answer
213 views

How simulate a random distribution?

I'm working on a battle algorithm for a text-based game and I stumble when it comes to randomly distributing attacks on a set of units. E.G, 100 archers shoot 100 targets at the same time. I thought ...
4
votes
2answers
257 views

How to implement n-body in an Entity Component System

Recently I've been throwing problems at Entity Component Systems to see how far I can push the paradigm. One problem in particular I struggle with, which is writing an elegant implementation of the n-...
5
votes
1answer
183 views

How to randomly create a fair maze for a multiplayer game?

I am creating a 2d multiplayer RTS game which happens inside a maze. I have used Growing Tree algorithm to randomly generate the maze. I thought that the maze would be fair for each team as long as ...
0
votes
0answers
22 views

Duplicate packets and termination of packets in multiplayer game

I'm making a multiplayer game (lazertag) with real hardware. After hours of research, I'm choosing the UDP instead of the TCP protocol to exchange data. Because of how unreliable UDP is and because ...
1
vote
0answers
18 views

Handling game message packet loss at low speed and at a microcontroller level

I read this: How do I handle packet loss in a client-server network model? ...But I'm looking for more advice. Currently I'm implementing my own lazertag vests. I'm programming hardware (8051 ...
0
votes
1answer
26 views

Getting an object to move in another objects direction

I have a player and an enemy, both have x and y values, and I want to move the enemy to the player and have them 'touch' over time in a speed that I can determine, I tried calculating the angle ...
-1
votes
1answer
57 views

Java 2d array to generate grid - java.lang.ArrayIndexOutOfBoundsException: length=4; index=-1

I am creating a Hashi Puzzle game (Islands and Bridges) I am generating a 2d grid with Islands that can be connected using bridges, I am also running a DFS algorithm to check if the map is solvable I ...
3
votes
1answer
183 views

Creating random path in grid

I need to find a path with required length in the NxN matrix without loops and deadlocks. For example: We Have a grid 7x7 (49 blocks in total) with START (orange) point. We need to build random ...
0
votes
0answers
31 views

Instancing Meshes With Overdraw Algorith

I am working on a Game Engine(DX11) and we are at a point where we are starting to cull, and order our objects in the scene for rendering order. However, since we want to instance the same mesh, ...
1
vote
5answers
232 views

How can I select an enemy to act next, biased toward smaller enemies?

Suppose there are X number of enemies in the game. They all have to attack one by one. Each enemy is picked randomly, and can be of Y size. How can we attain biased randomness in such a way that ...
1
vote
1answer
321 views

Welzl Algorithm to find the Smallest Bounding Sphere

I'm implementing Welzl's Algorithm to find the Smallest Bounding Sphere. In brief, the algorithm works by maintaining: a set of points to contain in the sphere (inside its interior, or on its ...
1
vote
1answer
71 views

How to find sequences of consecutive cards of the same suit in a hand, including wild cards? (Indian Rummy)

I have a hand of 13 cards (chosen from 2 standard decks of 52 cards + 4 jokers, so it's possible for the same card to appear multiple times). I want to search this deck to find sequences according to ...
1
vote
1answer
82 views

Physics - How to calculate the next position of a ball rolling against a slope?

For a small C/C++ game project, I want to add some physics on a ball, to allow it to roll against the slopes of a 3d world, in the same way as the example visible in the image below: However I have ...
1
vote
1answer
95 views

Looking for a square-to-hex pixel coords algorithm

So as the headline suggests, I am looking for an algorithm/algorithms used for square-to-hex and hex-to-square pixel coordinates convertion. I have an image which looks kinda "interpolated", meaning ...
0
votes
1answer
122 views

Can you use A* to make a unit move nonspecifically?

A* is typically used to calculate the best way to move towards something, and it's quite flexible when it comes to threats, extra movement costs, and 'refuelling' on the way to something. However, if ...
5
votes
1answer
119 views

Ordered dithering between “discrete” colors?

I want to achieve color dithering between discrete colors like this: As you can see, there is no gradient, or technically there is, but very discrete as it's only a 3 color image (right bar). So I ...
0
votes
0answers
38 views

AStar Scores Explain Question. What is GScore?

I Tried to create AStar Algorithm and i'm already finished but i didnte work cause of this line : ...
0
votes
0answers
20 views

Algorithm for tile loading order

I'm working on an Android app (you could call it a "game") that loads meshes (= kind of tiles) depending on your line of sight. Basically I'm generating the ground in a void world in which you are a ...
0
votes
1answer
84 views

Implementing a score system similar to Moon Patrol

I am working on an Android game scenario inspired by Moon Patrol. My beta version is available for beta test from https://play.google.com/store/apps/details?id=dev.android.buggy In my case, I got ...
8
votes
3answers
914 views

What are good algorithms to generate borders / state areas on 2d star maps?

I'm trying to generate a fairly large two-dimensional star map that shows different factions / states, each owning one or more star systems. I'd like to automatically create borders / areas for the ...
0
votes
0answers
22 views

Failing to apply Max Rectangle algorithm

After asking this question, I have few problems trying to implement Max Rectangle Algorithm that is described here on page 19. I have a hard time implementing this, do you have leads or advices on ...
1
vote
1answer
154 views

Algorithm to generate random shapes that fill up a rectangle?

The final result can be like this I've thought up several approaches: Generate random curved lines to "cut" the rectangle (or generate random dots and form the line from the dots) Break the ...
0
votes
0answers
30 views

Algorithm for 'grid based occlusion'

I am working on a project within which I have a 3d grid-aligned world. On the 'faces' connecting grid cells (whether XY, XZ, or YZ plane), there is the possibility for an occluder (wall/floor/etc.) to ...
3
votes
2answers
267 views

Two Army Battle Simulator

I'm currently developing a small game project on unity (with purpose of learning C#) where each player controls a base and can build buildings, do research, build units, pretty much the basis. I ...
1
vote
0answers
123 views

How is terrain editing implemented like a sculpt tool?

Some creativity/sandbox games have a terrain editing feature. When thinking of a terrain, I'm thinking of a grid of vertices. The elevation of each vertex is then determined by a heightmap (image). ...
0
votes
1answer
78 views

Acceleration in Unity

I am trying to emulate acceleration and deceleration in Unity. I have written to code to generate a track in Unity and place an object at a specific location on the track based on time. The result ...
2
votes
2answers
326 views

How can I generate the smallest enclosing sphere from a mesh?

I have a polygon which is defined by a set of vertices and I need the smallest sphere encompassing the mesh. The spheres are defined by a position vector (x,y,z) and a radius. Is there an algorithm ...
0
votes
0answers
16 views

(Houdini) Twist control for bones on curve using parallel transport algorithm (Rigging)

Hopefully you guys use Houdini and some math genius can help me. I have a curve where I used the parallel transport algorithm to transport the normal along the curve and then I use this curve as a ...
2
votes
1answer
585 views

How to make ghosts AI chase Pac-Man in Java

I'm beginner at Java and I want to make ghosts chase Pac-Man in game. I read some algorithm like A* or Dijkstra but I don't know how to implement them in my game. Please help me.
1
vote
1answer
112 views

efficient 2D light source

I wanted to add a light source for a project I'm working on, and luckily I had some code based on this article: http://ncase.me/sight-and-light/, but when I ran the code after carefully transplanting ...
0
votes
1answer
137 views

Removing duplicate vertices on a mesh

I have a set of vertices and another set of indices. Sometimes I find that I have duplicate vertices in my mesh. I tried at first to check if two identical vertices were in the array of vertices but ...
0
votes
1answer
89 views

How to get a reflex edge on a non-convex mesh

I am trying to implement a convex decomposition and I need to find the convex vertex on a mesh. Is there a algorithm that I can use to find the convex vertex on a mesh.
0
votes
0answers
17 views

How to compute volume of intersection of non-axis-aligned cuboids in 3D?

Given two cuboids in 3D space (8 vertex coordinates each) that are arbitrarily oriented, how can we find the volume of overlap between them in the fastest manner?
0
votes
1answer
223 views

Algorithm to solve a battle in a card game

I am trying to write a solver for a sort of card game. I mainly do that for fun, and also to be able to learn a bit about the different types of algorithms I could use for this problem. The rules of ...
0
votes
1answer
34 views

algorithm for combining smaller tiles to balance the bigger ones

I have a field of tiles - basically each tile is a country that has some kind of sovereign. The tiles - countries - have different weight. For now I use some numerical value but in the future the ...
1
vote
1answer
227 views

Tic Tac Toe Victory State Detection [closed]

Below is the code I'm using to check if the board state has a tic tac toe style victory state. The board is always square and is made of an array of objects that keep track of their own completion ...
3
votes
1answer
239 views

Procedural Star Generator

I want to develop a procedural galaxy / starfield generator. A rather simple approach would be to use some pseudo-random algorithm to repeatedly create a star and its properties (such as position, ...