_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
27 | How to make the character dash forward in Roblox? In my game I want to make a skill in a tool to dash forward for a specific range and if the character came in contact with a humanoid during the dash, it stops right on contact and stops the other humanoid from moving temporarly too and deal damage I don't know what functions should i do and where to look for them... i figured how to use onActivate and getting the mouse through Equipped Appritiate any help and guidance |
27 | Create a game start up menu screen with Lua love 2d I just got started programming games and decided to try out love2d since I'm learning lua. I was wondering if anyone knows how I can create just a simple 2 3 button menu when you start up the game. All I want to do is make a start up menu. I have 2 files and nothing else main.lua, in which I have the game code and the level design conf.lua, in which I have the title screen code and the icon of the game I couldn't find any wiki page to help me for coding for the first time a splash screen and a overall game screen !! now i have only one screen the game screen and i want to have 3 screens 1 splash screen in wich i want to draw a image background and 3 buttons PLAY,EXIT,TITLE with coding mousepress! 2 game screen! 3 game over screen with an other background image! |
27 | How can I link to callback functions in Lua such that the callbacks will be updated when the scripts are reloaded? I'm implementing Lua scripting in my game using LuaBind, and one of the things I'm not clear on is the logistics of reloading the scripts live ingame. Currently, using the LuaBind C class luabind object, I save references to Lua callbacks directly in the classes that use them. Then I can use luabind call function using that object in order to call the Lua code from the C code. I haven't tested this yet, but my assumption is that if I reload the scripts, then all the functions will be redefined, BUT the references to the OLD functions will still exist in the form of the luabind object held by the C code. I would like to be able to swap out the old for the new without manually having to manage this for every script hook in the game. How best to change this so the process works? My first thought is to not save a reference to the function directly, but maybe save the function name instead, and grab the function by name every time we want to call it. I'm looking for better ideas! |
28 | How to divide hex grid evenly among n players? I'm making a simple hex grid 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 small areas. For example, if there's four players and 80 cells in the map, each of the players would have about 20 cells (it doesn't have to be spot on accurate). Also, each player should have no more than four adjacent cells. That is to say, when the map is generated, the biggest "chunks" cannot be more than four cells each. I know this is not always possible for two or three players (as this resembles the "coloring the map" problem), and I'm OK with doing other solutions for those (like creating maps that solve the problem instead). But, for four to eight players, how could I approach this problem? |
28 | Algorithm for a dense crowd of people who avoid the player? I want to make a game like this. When player moves other humans will move too. And other humans will push people around. Are there any algorithm for this ? How can i solve this very efficient way ? I dont want to check all objects at scene with loop. And i dont want people overlap. Video https youtu.be V5ZMicq05LQ |
28 | How can I quantify a drawn line's straightness? I'm working on a game which requires players to draw a line from a point A(x1,y1) to the other point B(x2,y2) on the screen of an Android device. I want to find how well that drawing fits to a straight line. For instance, a result of 90 would mean the drawing almost perfectly fits the line. If players draw a curved line from A to B, it should get a low score. The end points are not known in advance. How can I do this? |
28 | Is there a known most efficient version of A search algorithm? Is there a known 'most efficient' version of the A search algorithm? I know some people write papers on the most efficient way to compute common operations, has this been done for A ? |
28 | How can I quantify a drawn line's straightness? I'm working on a game which requires players to draw a line from a point A(x1,y1) to the other point B(x2,y2) on the screen of an Android device. I want to find how well that drawing fits to a straight line. For instance, a result of 90 would mean the drawing almost perfectly fits the line. If players draw a curved line from A to B, it should get a low score. The end points are not known in advance. How can I do this? |
28 | How do you map a 3D scene to a stero image pair? I'm a novice. I'm working in XNA studio with simple models. How can I turn a 3D image into two images meant for the left and right eyes respectively? Note I'm not referring to "magic eye" I'm wondering how you calculate the left and right images starting from the 3D scene info. |
28 | Generating random values, keep trying till value within bounds are generated Sorry for the strange topic name, couldn t think of a good way to describe it. I m basically trying to achieve the following I'm placing items randomly on the screen, but these items shouldn't be placed near eachother at a given distance. This is the process I have in my head right now generate a random location check if this location is not near any other objects it is near start the process over to generate a new item (till it is not near anymore) I've run into this scenario multiple times but could never think of a way to efficiently do this, while I do feel that there is a simple way to do it. Here is the implementation I have right now. I feel like I should use a while loop but I can't get my around how to do it. The code is in AS3 but that shouldn't matter. public function generatePlanetsFromXML(xml XML) void planets new Array() for (var i int 0 i lt xml.projects.project.length() i ) var planet Planet new Planet() planet.data xml.projects.project i planet.radius (Math.random() 20) 20 addChild(planet) addObject(planet) planets.push(planet) calculatePlanetLocation(planet, i) private function calculatePlanetLocation(planet Planet, i int) void var randomX int (Math.random() (worldwidth planet.width)) 20 var randomY int (Math.random() (worldheight planet.height)) 20 get a location that isn't close to another planet keep looping till the distance is higher than minimum distance for (var j int 0 j lt planets.length j ) if (i ! j) var dx int planets j .x randomX var dy int planets j .y randomY var distance int Math.sqrt((dx dx) (dy dy)) if (distance lt minPlanetDistance) trace("retry getting location..") planet.alpha 0.3 calculatePlanetLocation(planet, i) else distance is fine, planet can be placed! planet.x randomX planet.y randomY else if (i 0) first planet should always be placed planet.x randomX planet.y randomY |
28 | How to track and find entities within radius in realtime game? What is best approach to implement tracking in real time for, say, 1000 npcs? Every frame update simple a square grid (remove or insert into linked list) and every time check in square radius? I tried kd tree but its really bad in real time updates even with 100 entities I can't reach 10 FPS. |
28 | Diamond Square Algorithm How to fix horrible diamond shaped artefacts and spikes? I was attempting to follow this article explaining the implementation of a wrapping version of the diamond square algorithm. I tried running it with dimensions of 128x128 and a "feature size" of 16, like in the article, but the resultant terrain is this monstrosity I read through past questions on this topic and am aware that there can be some issues with somewhat noticeable diamond or square shaped artifacts when using this algorithm, but this is definitely beyond that. Here is my code private float GetHeightAtPoint(int x, int z) if (x lt 0) x width x if (z lt 0) z height z return fractal (x (width 1)) (z (height 1)) width private void SetHeightAtPoint(int x, int z, float value) if (x lt 0) x width x if (z lt 0) z height z fractal (x (width 1)) (z (height 1)) width value private void SquareStep(int x, int z, int size, float value) int halfSize size 2 float a GetHeightAtPoint(x halfSize, z halfSize) float b GetHeightAtPoint(x halfSize, z halfSize) float c GetHeightAtPoint(x halfSize, z halfSize) float d GetHeightAtPoint(x halfSize, z halfSize) float meanHeight (a b c d) 4.0f float adjustedHeight meanHeight value SetHeightAtPoint(x, z, adjustedHeight) private void DiamondStep(int x, int z, int size, float value) int halfSize size 2 float a GetHeightAtPoint(x halfSize, z halfSize) float b GetHeightAtPoint(x halfSize, z halfSize) float c GetHeightAtPoint(x halfSize, z halfSize) float d GetHeightAtPoint(x halfSize, z halfSize) float meanHeight (a b c d) 4.0f float adjustedHeight meanHeight value SetHeightAtPoint(x, z, adjustedHeight) private void DiamondSquare(int stepSize, float scale) int halfStep stepSize 2 for (int z halfStep z lt height halfStep z stepSize) for (int x halfStep x lt width halfStep x stepSize) SquareStep(x, z, stepSize, Random.Range( 1.0f, 1.0f) scale) for (int z 0 z lt height z stepSize) for (int x 0 x lt width x stepSize) DiamondStep(x halfStep, z, stepSize, Random.Range( 1.0f, 1.0f) scale) DiamondStep(x, z halfStep, stepSize, Random.Range( 1.0f, 1.0f) scale) Generate a fractal map using diamond square algorithm and store in fractal private void GenerateFractal(int featureSize) fractal new float width height for (int z 0 z lt height z featureSize) for (int x 0 x lt height x featureSize) SetHeightAtPoint(x, z, Random.Range(0.0f, maxHeight)) int sampleSize featureSize float randomScale 1.0f while (sampleSize gt 1) DiamondSquare(sampleSize, randomScale) sampleSize sampleSize 2 randomScale randomScale 2.0f Could anyone give me any guidance here? One thing that was a bit suspect was that I had to make slightly different wrapping array access functions in order to make this run as I was getting negative values. You can see that my functions have the if statements checking for negatives, whereas the original implementation does not. Thanks in advance |
28 | How do I optimize searching for the nearest point? For a little project of mine I'm trying to implement a space colonization algorithm in order to grow trees. The current implementation of this algorithm works fine. But I have to optimize the whole thing in order to make it generate faster. I work with 1 to 300K of random attraction points to generate one tree, and it takes a lot of time to compute and compare distances between attraction points and tree node in order to keep only the closest treenode for an attraction point. So I was wondering if some solutions exist (I know they must exist) in order to avoid the time loss looping on each tree node for each attraction point to find the closest... and so on until the tree is finished. |
28 | How do you disable frame skips in a game, in SFML preferably by frame skip off i mean that the game should just slow down if the fps drops, just like in terraria, i got this code currently and want to implement it to it static class Globals static public Time dt new Time() static public Vector2f Friction get return new Vector2f(2 dt.AsSeconds(), 0) class Player private void StartMoving(int direction) moving true direction direction heldfor 1 Move(direction) public void Move(int direction) if(!moving) StartMoving( direction) return if(direction direction) if(heldfor lt heldforlimit) heldfor Velocity new Vector2f(((speed (heldfor 10f)) direction) Globals.dt.AsSeconds(), 0) else direction direction heldfor 2 Velocity new Vector2f(Velocity.X 1.5f, Velocity.Y) if (heldfor lt heldforlimit) heldfor Velocity new Vector2f(((speed (heldfor 10f)) direction) Globals.dt.AsSeconds(), 0) public void StopMoving() moving false heldfor 1 public void Update(Time dt) if(!moving) if(Math.Abs(Velocity.X) Globals.Friction.X lt 0) Velocity.X 0 else i really should make this direction independent and apply direction at end of the update Velocity.X Velocity.X gt 0 ? Velocity.X Globals.Friction.X Velocity.X Globals.Friction.X if (Math.Abs(Velocity.X) lt velocitySnapX) Velocity.X 0 if (Math.Abs(Velocity.Y) lt velocitySnapY) Velocity.Y 0 if (Math.Abs(Velocity.X) gt XMaxvel) Velocity.X XMaxvel direction if (Math.Abs(Velocity.Y) gt YMaxvel) Velocity.Y YMaxvel direction Position Velocity class Program Player player new Player() while(game.isrunning) this is made up as the genuine code is too messy if (Keyboard.IsKeyPressed(Keyboard.Key.Right)) player.Move(1) if (Keyboard.IsKeyPressed(Keyboard.Key.Left)) player.Move( 1) window.Clear(Color.White) window.Draw(player) player.Update(Globals.dt) window.DispatchEvents() window.Display() window.SetView(mainview) Globals.dt deltaclock.Restart() |
28 | Low CPU Memory Memory bandwith Pathfinding (maybe like in Warcraft 1) Dijkstra and A are all nice and popular but what kind of algorithm was used in Warcraft 1 for pathfinding? I remember that the enemy could get trapped in bowl like caverns which means there were (most probably) no full path calculations from "start to end". If I recall correctly, the algorithm could be something like this A) Move towards enemy until success or hitting a wall B) If blocked by a wall, follow the wall until you can move towards the enemy without being blocked and then do A) But I'd like to know, if someone knows ) edit As explained to Byte56, I'm searching for a low cpu mem mem bandwidth algo and wanted to know if Warcraft had some special secrets to deliver (never seen that kind of pathfinding elsewhere), I hope that that is more concordant with the stackexchange rules. |
28 | Tile pair matching algorithm I'm trying to make a tile matching game. User can select a pair of tiles from a square grid, and if they match, both are removed from the grid. Tiles are matched if they are of the same type (many types of tiles are in the grid) AND they can be connected in the grid (either adjacent, or has a clear path of empty spaces between them in the grid) I would like to scan the grid in advance and find the currently matching pairs (desirably with the path that connects them). Thus I can give hint to users if they're stuck in finding a pair detect a situation when no more pairs can be matched (so the tiles will be reordered) Ideally during the scan each tile pair of the same type should be taken and checked for matching. Is there any algorithm technique I can use in here to obtain an optimized approach in finding the connecting paths? Also, is there anything I should take care of while initializing the grid (currently just random assignment) so as to ensure at least some tiles are adjacent in the beginning (and that I won't have to reorder them too much during the game) ? |
28 | How to place objects entities randomly in JS? I'm making a game and I have a script (running it with Node) on the server that currently just randomly places things on the map... I'd like to change that. I saw something about Perlin noise but I'm not sure if that's the thing I want and I'm even less sure how to implement it... I want something like this, green dots represent trees, red ones represent enemies and grey ones represent rocks. Where can I get a simple JS algorithm to achieve this? |
28 | Calculating the illumination level of an object In my (UE4) scene I have an object and several (point) light sources. The object can move around, getting closer and away from all those light sources. Now I need to calculate for each light source how much it affects the object at its current position (i.e. distance from the light). Every light source has three important values Intensity How bright the light shines (integer vlaue 0..10000) Attenuation Radius around light, how far it visibly influences the scene Falloff exponent Radial falloff around light (inverse squared by default, or can be an integer between 2 and 8) Now, depending on how far the object is from a light source, it is more or less affected by the light. If the object is outside the attenuation radius, it is not affected at all by the light. I am not so much interested in the light intensity, but more in the distance between the object and a light. For each light I am interested in a value between 0 and 1. So the easy way would be to simply calc 1 distance attenuation. But I would like to take the falloff exponent into account. Any ideas how to accomplish that? |
28 | Creating the nodes for path finding during run time more like path making and more I'm making my 1st game. I'm using javascript as I currently want to learn to make games without needing to learn another language but this is more of a general game dev question. It's a 2d turn based tile grid game. You can check it here http www.patinterotest.tk it creates a movable area when you hover a player and it implements the A algorithm for moving the player. The Problem I want to make the 'dynamic movable area creation' already implement a limited number of steps for a player. The Questions What is a good way to do this? Is there another algorithm to use for this? The A algorithm needs a start and destination, with what I want to do I don't have a destination Or should I just limit the iteration of the A algorithm to the steps variable? |
28 | What's the best way of transforming a 2D vector into the closest 8 way compass direction? If you have a 2D vector expressed as x and y, what's a good way of transforming that into the closest compass direction? e.g. x 1, y 1 gt NE x 0, y 3 gt N x 10, y 2 gt E closest compass direction |
28 | 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 sort of tile they'd like to create (like cliff going up or down), and then clicking individual tiles, or "painting" over multiple by holding down mouse button and scrolling. I don't want the player to have to manually click every tile they want to rise or fall in elevation. The most elegant solution I can conceive, is for the player to "paint" a loop of cliff tiles, which is then filled in automatically when the loop closes. Imagine, perhaps, someone drawing a line using MS Paint or Photoshop, until that line closes into a shape which then autofills. Let's say the player wants a plateau, and so they select cliff going up, and then click and drag the desired shape. Upon closing the loop, when the last cliff tile is created beside the first cliff tile, witchcraft is invoked which fills the inside. I have no idea how this can be done, never mind elegantly or optimally. There are obvious possible solutions (find the average vector of all tiles in the loop, and then dijkstra algorithm from the average until the space is filled with the correct elevation), but these assume the shape generated is blobby or boxy. An irregular shape where the mid point falls outside of the shape is possible and would probably ruin that solution! How can I fill the inside of a closed loop? I'd like a theoretical solution I can go away and implement in C . At this point it seems like there is probably conceptual overlap between raster graphics and procedural maps! |
28 | Reduce the number of edges of a graph, keeping it connected I'm designing a game with random generated dungeons. I'd like to view this as a connected, undirected graph in which nodes are rooms and edges are doors or corridors. Then I choose a "side" node as the dungeon entrance, I calculate the distance between this entrance and all other nodes, and decide that one of the farthest nodes is the "goal" of the dungeon (the location of the treasure, boss, princess, etc.). I saw 2 ways to generate the final dungeon topography Generate first a random graph, then try to fill the 2d world with rooms at random locations, respecting the edge connections. I figured this would be sometimes difficult because the room generation could be "locked" trying to fit rooms in impossible places. Generate first rooms, placing them randomly where they fit, then map the result to nodes and edges. I decided to try this. My idea consists in First generate a big room that would contain the whole dungeon. Put a wall inside the big room, at a random location, dividing the big room into 2 smaller rooms of different area. Then I continue to divide each room into 2, until they are too small, or the total number of room reach a maximum (or any other condition). Each new room is a node. Once finished, I check each room and find all adjacent other rooms, marking the 2 nodes as connected by an edge. That way I ensure that all rooms have a possible location in the 2D world, and are correctly mapped by a connected graph. My problem is that there are too many doors and corridors connecting the rooms. So I'd like an algorithm that reduces the number of edges of a connected undirected graph, but keeping it connected (all nodes stay reachable) in the end. |
28 | Algorithm for generating levels for shooting game I have a shooting game made in Java. It's based on time, i.e you have to shoot the objects before the time runs out. Everything is working fine, except that I'm trying to implement an algorithm to generate levels. I implemented one that increases the number of game objects and increase their speed, but I don't know how to give the player an appropriate time based on these factors to provide an appropriate challenge for the player. |
28 | Stepping from Point out on Archimedes Spiral for Length along Arc I wasn t sure whether to put this question in mathematics or programming? My question has two parts with the second part dependent on the first. I m looking to use Archimedes spirals in some game code I m writing. I figured that there is possibly a unary Archimedes spiral from which all other achimedes spirals can be derived. (Hopefully the use of unary is correct here?) That is a unary Archimedes spiral is one where the spiral spirals one radian outwards for every radian of angle starting at centre. So my first question is Is that true? Can every Archimedes spiral be derived from a unary Archimedes spiral like I ve described? By derived I mean by the use of simple multiplication and division to transform from the unary Archimedes spiral to any Achimedes spiral with a different rate of out spiral. eg. spiral20RadiansOutPerRadian unaryspiral 20 If that is the case then could someone possibly help me also with this second question? I m looking to step a measured arc length outwards (and inwards) from a point that is out on a measured Archimedes spiral. So not from the zero or centre point but from somewhere out on the spiral. The begin point out on the spiral is represented by a measured radius from zero (or centre). I m looking to find r' f(r , arclen) where r is the initial radius, arclen is the length stepping outwards along the arc (negative to step inwards) and the resultant r' is the new radius at that stepped to point. My process for deriving from the unit spiral would hopefully then be Programmer sets a value for delta radius which is per radian of angle. Programmer sets a value for start radius. Programmer sets a value for step length which is the length to step around arc. The unary step length is worked out by dividing step length by delta radius. The unary start radius is worked out by dividing start radius by delta radius. We call achimedes() function with the two unary values and it returns unary end radius. The actual end radius is worked out by multiplying unary end radius by delta radius. The delta angle is worked by subtracting unary end radius from the unary start radius. My second question is Could somebody please help me to write this achimedes() function (if the answer to question 1 is yes)? I m looking to have function be of the form unary end radius archimedes(unary start radius , unary step length) where the unary delta radius is understood to be 1 radian. |
28 | How to generate point based on a map I am making a multiplayer game in Unity, with a socket.io server in NodeJS. I am using a globe, with a texture to represent the world in Unity. Let's say something similar do this. Now, there I am stuck with some algorithm. I would like to generate equally distant point, on the lands, where user can build stuff. Something similar to this I saw this post here post and I would like to generate the map in the server, create from the generate map a mongoDB collection of point. When a user connect, he get back a list of point (that are already generated and can interact with those). I get stuck on the generation. How do I make the server generate point based on a map that I will show to client, but that the server do not have idea of ? How would I store the coordinate position, so that the server generate them, and the client no matter the scale of the map would be able to display them at the good point ? Basically, I don't know where to start to make this algorithm. I just would like some idea on how you would achieve this, so I can inspire myself to find my solution. |
28 | best way to compute vertex normals from a Triangle's list hi i'm a complete newbie in computergraphics so sorry if it's a stupid answer. i'm trying to make a simple 3d engine from scratch, more for educational purpose than for real use. for now i compute only face normals. in this way i have a Surface object with inside a Triangle's list. i compute normals inside Triangle class, in this way triangle.computeFaceNormals() Vec3D u v1.sub(v3) Vec3D v v1.sub(v2) Vec3D normal Vec3D.cross(u,v) normal.normalized() this.n1 this.n2 this.n3 normal and when building surface t new Triangle(v1,v2,v3) t.computeFaceNormals() surface.addTriangle(t) and i think this is the best way to do that.. isn't it? now.. this works, ok. but light it's not smoothed. i'm trying to compute also vertex normals. (i'm testing my engine with tubolar surfaces so i have almost all vertex shared with more then one triangles) i've found this simple algorithm flipcode vertex normal but.. hei this algorithm has.. exponential complexity? (if my memory doesn't fail my computer science background..) (bytheway.. it has 3 nested loops.. i don't think it's the best way to do it..) any suggestion? |
28 | How to place objects entities randomly in JS? I'm making a game and I have a script (running it with Node) on the server that currently just randomly places things on the map... I'd like to change that. I saw something about Perlin noise but I'm not sure if that's the thing I want and I'm even less sure how to implement it... I want something like this, green dots represent trees, red ones represent enemies and grey ones represent rocks. Where can I get a simple JS algorithm to achieve this? |
28 | 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 you designate only threats, perhaps with a main threat first and foremost, can you use it for "finding somewhere to go"? What about adding both threats, safety, resources and other such heuristic influencers to determine what a unit does when idle? |
28 | Flowfield density conversion I'm trying to implement flowfield navigation, as described in http grail.cs.washington.edu projects crowd flows but I can't understand how the Density Function in Figure 4 of the paper is supposed to handle unit radius. Has anyone ever implemented that and can provide more information? This is the part in question Their algorithm seems to be using only 4 cells, pointing to the lower left of the unit, so is this some kind of kernel that needs to be applied multiple times? Thanks. |
28 | 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 areas so that I can use search algorithms to generate paths through the map. It is easy to find the shortest path between two areas, but I would like to find a path with a specific number of steps(or path cost). So, my question is What is an algorithm that I can use to find a path that has a specific cost or cost range? An Example of why I think this is useful Say that I randomly choose two areas(start and end for example). These area might be next to each other, they might be on the opposite sides of the map. I want to force the player to travel through a minimum number of areas before reaching the end, let's say 5. I should be able to be like path startArea.findPathMinimumCost(endArea,5) And it will return a path of cost 5, or the shortest path, whichever has the greater cost. Thank you. |
28 | Pathfinding Algorithms I am new to game programming I currently am using unity's 2D power to remake an 2D game for sake of practice. So I am just little confuse about one thing, so far every enemy in my game was dumb(they move on predefined paths) but this enemy, alien copter, flies and follow the player wherever the player goes. My question is should I implement any pathfinding algorithm? I had studied A but I trying to figure out if A is gonna be helpful in my envoirnment because player will be moving and the enemy have to keep on looking for shortest path. I tried to write code for this AI my code was working perfect when there were no obstacles but my game has obstacles so I want something efficient so what do you people think should I implement A or any other algorithm or not? |
28 | background animation algorithm for single screen I m writing simple strategy game (in xna), and would like to have an animated background. In my game all the actions happens inside one screen and thus standard parallax effect does not look appropriate. However, I found a video of a game with suitable background animation for my game http www.youtube.com watch?v Vcxdbjulf90 amp feature share amp list PLEEF9ABAB913946E6 (from 3 to 6s, while main character stays at the same place). What is the algorithm to do this stuff? It would be nice if someone can provide a reference for a similar example (language is not important). |
28 | Multiplayer Network Game Interpolation and Frame Rate Consider the following scenario Let's say, for sake of example and simplicity, that you have an authoritative game server that sends state to its clients every 45ms. The clients are interpolating state with an interpolation delay of 100 ms. Finally, the clients are rendering a new frame every 15ms. When state is updated on the client, the client time is set from the incoming state update. Each time a frame renders, we take the render time (client time interpolation delay) and identify a previous and target state to interpolate from. To calculate the interpolation amount factor, we take the difference of the render time and previous state time and divide by the difference of the target state and previous state times var factor ((renderTime previousStateTime) (targetStateTime previousStateTime)) Problem In the example above, we are effectively displaying the same interpolated state for 3 frames before we collected the next server update and a new client (render) time is set. The rendering is mostly smooth, but there is a dash of jaggedness to it. Question Given the example above, I'd like to think that the interpolation amount factor should increase with each frame render to smooth out the movement. Should this be considered and, if so, what is the best way to achieve this given the information from above? |
28 | Implementing a color picker I'm making a paint program using applets in Java, and I want to create some sort of color palette where the colors blend into each other, similar to this However, I'm having trouble understanding the correlation between the R, G, B, values and the X, Y coordinates for both the outer circular color palette, and the inner hue selecting palette. Representation |
28 | How do I know when a player has crossed a point threshold? I m needing help figuring out logic when adding a time bonus to my game. I only want to reward the player with extra time if they level up. Currently when the player s score is less than 100 no bonus is given. If the player s score reaches 200 I want to reward the player with some bonus time. My issue is if the score is 190 and then jumps to 210, the 200 level mark is passed and the player isn't rewarded. If I turn on the logic to say if the score is between 190 and 210, it could reward the player at the 190, 200, 210 mark or skip from 180 to 220, bypassing the reward altogether. I have tinkered with the idea of setting a bool BonusFlag, but the same issue arises, when I set the flag. Can anyone help provide some logic on how to overcome this obstacle? |
28 | AI algorithm for avoiding bullets in a shoot em up game I am working on a shoot up game in XNA, it is going to be my final project in school. I was thinking of utilizing the minimax algorithm for AI agents for making tactics. However, I realized that the most important issue in such a game is to avoid bullets(fired by the player). An AI agent making tactics but no good at avoiding bullets would be useless in a shoot em up game I guess. So, I need your help about what algorithm to utilize. It's not going to be a bullet storm like game, but it's fast(thanks to XNA). I have read about using threat maps and also pathfinding algorithms but couldn't figure out which one is ideal in such a game. I mean it needs to be simple enough for a fast paced gameplay, but it should also help AI agents act intelligently. |
28 | How does A pathfinding work? I would like to understand on a fundamental level the way in which A pathfinding works. Any code or psuedo code implementations as well as visualizations would be helpful. |
28 | Best data structure to store large amount of data I am making a minecraft kind of game. In which I have 100s of objects and their crafting recipe. Now I want to store them inside the program, ie I cannot load external files. Everything must be inside class for now. In future I might be able to use databases, once the game gets more traction. All these objects will have addition properties like shootable,purchase cost,etc etc. Some also have array property like research1 unlocks object1 50 , object2 100 , research2 unlocks object1 50 . But all these objects will be constant with an exception of "locked" boolean. If I do a huge database I'll also have to search data using filters on they keys like we do on sql. Example "Give me all Researches that are unlocked and that unlocks object1" What will be the best datastructure to store them? Thanks. |
28 | How can I generate random levels like in "Square it!" game? In this game, you have a 2d field with some free squares and two colored squares which you can move but only together (they'll move only if the spot is still "free"). And you have to fill whole free space. Here is a video that demos how the game is played. How can I generate random game levels like in that game? |
28 | How can I generate Sudoku puzzles? I'm trying to make a Sudoku puzzle generator. It's a lot harder than I expected and the more I get into it, the harder it gets! My current approach is to split the problem into 2 steps Generate a complete (solved) Sudoku puzzle. Remove numbers until it's solveable and has only 1 solution. In step 1, since I'm using a brute force methods, I'm facing some run time issues. Is there an optimal way of filling in a complete Sudoku puzzle? In step 2, what kind of algorithm should I use to "puzzlize" a solved sudoku? |
28 | Control diamond square algorithm to generate islands pangea I generated a height map with the diamond square algorithm. The thing is i do not manage to create islands, this is, restrict the height other than water level range to a certain value in the center of the map. I manualy seeded a circle in the middle of the map but the rest of the map still receives heights over the water level. I dont fully understand the Perlin noise algorithm so i'd like to work with my current implementation of the diamond square algorithm which took me 3 days to interpret and code in PHP. P UPDATE I'm trying to get a gradient and its working (it's late and have to refine it, i'll try tomorrow). I tried to work with gradients but silly me, I had been clamping the affected values to a radius, giving me a circle when generating the map. The seeding option is NOT working. I may get some bigger landmass, but may be located in any sector in the map, not even close to the center. Please have in mind that the DSA generates the middle value averaging it's corners, so its not possible to seed the middle of a square. a b f c d f (a b c d) 4 random( value,value) Perhaps that's why seeding it's not working. |
28 | Matchmaking by user supplied parameters I'm looking for matchmaking algorithm for a 1 vs 1 online game. Players must not be matched by their skill level, but instead by some specific filters set by the players. Each player sends a request that specifies some set of parameters (generally, 2 4 parameters). If some parameter is specified, the player can be matched only with those who had sent this parameter with exactly the same value or those who haven't specified the parameter at all. I need this algorithm to be thread safe and preferably fast. It would be great if it worked with 3 4 or even more parameters, but even one is alright (in my case, it's a game bet). Also, I'd appreciate ideas on how to implement or improve this algorithm on my server platform ASP.NET. One more problem I'm facing is that match finding can't be executed right after the user sends request, because if another user sends a request before a previous matching is finished, they won't be matched even if they possibly could. So it seems that match finding should be started on schedule. I need help on how to optimize it and how to choose time interval for starting new match finding. P.S. I've also posted this question on stackoverflow |
28 | Algorithm for random flight of a fly I'm new to game development. What is a good algorithm to model the random flight of a fly? I've been looking at path finding algorithms, but they don't give any interesting random behaviour. |
28 | Fastest way to neutralize scale in the transform matrix? Let's assume we have 4x4 3D transformation matrix, that is the result of scale, rotation, and translation transforms. How to set its scale to (1,1,1) in the fastest way? Assume also that the matrix is represented by float 16 array. By fastest way I mean, the most performance accurate way, that will be low CPU cost. |
28 | Rectangular selection on isometric map Before we get started I checked the following questions Isometric Tile Selection with rectangular bounding boxes Isometric rendering and picking? Calculating the number of tiles shown on an isometric map lt this is exactly how I get my top left and bottom right tile, but I can't calculate what's between them I can pick tiles perfectly, I'm struggling with the automatic selection given two tiles (top left and bottom right in screen coordinates). I've attached a drawing to help you visualize As you can see it's a Diamond setup, not staggered isometric. I'm struggling with finding the orange tiles, I have the green tiles' coordinates. Btw, it's not true isometric, it's 2 1 "isometric". |
28 | What makes a path finding heuristic Monotonic vs. Non monotonic? I am currently working on an algorithm that solves a path through the maze. So far I have implemented a Manhattan and Pythagorean Heuristic. I was wondering what makes a heuristic monotonic and how would one go about making a heuristic non monotonic. |
28 | How does Half Life's covering work? Enemies in this game take cover. AFAIK HL uses some logical decisions for enemy to start searching for cover and to abandon cover, and I am able so far to find them but how does he find a cover place? I know HL has waypoints. I can only guess speculate how they find cover point. They might search for nearest waypoint which has certain properties I thought such node might have some "cover" tag but tutorials seem not to mention it so maybe it is a node which is not visible by player AND offers attack possibility (crate or edge of wall). Thank You. ) |
28 | How do I avoid "too" lucky unlucky streaks in random number generation? I'm currently dealing with a multiplayer combat system where the damage dealt by the players is always multiplied by a random factor between 0.8 and 1.2. In theory, a truly random RNG may eventually yield the same number many times (see the Tetris dilemma). This could result in a match where player is always making very high damage while the other always makes very low damage. What can I do to make sure this doesn't happen? Are some RNGs better than others at avoiding repetition? |
28 | Best algorithm for different shapes maze Based off my previous question here Maze or puzzle algorithm for something similar to noodles are there specific algorithms that would be best suited to building a maze with only 1 solution for A grid made of squares. A grid made from hexagonal tiles Thanks |
28 | 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 item appears it will find it and walk to it. In all smash bros the cpu players are able to find items on the stage when they appear. How do they do this? |
28 | How can I tell if an object in a tile grid is surrounded? I'm making a game which uses a 10x20 matrix to store the position of the objects. I have a castle object, represented by a number in a matrix. It is randomly deployed in some cell of the matrix. I also have a wall object, represented by a different number, which the user will deploy into the matrix by clicking on cells. The idea is to surround the castle. Basically it'll look like this 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 2 1 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 (2 is the castle, and 1 is the wall.) How can I tell if the castle is surrounded by walls? |
28 | Best way to calculate city influence maps similar to civilisation? As the title says, imagine you want to generate the influence mask for a city, given that the map is a 2D grid rather than hex. An extra bit is that different points on the map might have different "influence absorpion" values. Some simple scenarios to make it less abstract Scenario 1 City centered at (5,2) has 10 influence All tiles have influence absorption 1 Tile at (6,2) has 9 influence, therefore within the influence of the city Tile at (7,2) has 8 influence, therefore within the influence of the city Tile at (14,2) has 1 influence, therefore within the influence of the city Tile at (15,2) has 0 influence, therefore out of the influence of the city Scenario 2 City centered at (5,2) has 10 influence All tiles have influence absorption 1, but tile at (6,2) has influence absorption 4 Tile at (6,2) has 9 influence, therefore within the influence of the city Tile at (7,2) has 5 influence, therefore within the influence of the city Tile at (11,2) has 1 influence, therefore within the influence of the city Tile at (12,2) has 0 influence, therefore out of the influence of the city It's like using dijkstra on a 2D grid with single source, multiple destinations. Any pointers for good fast algorithms are appreciated. Also, if this problem has a well known name, that'd be appreciated as well. I made the following algorithm (independently like Jon's, thanks btw, it's the intuitive solution I guess) p0 CITY COORDS Initialize all influences with 0 set CITY INFLUENCE as the new influence at p0 list p0 while list not empty p get point in list with highest influence rating pi get influence at point pa get absorption at point new i pi pa list is updated false for each valid neighbour nb nbi get neighbour's influence if new i gt nbi set new i as the new influence at nb add nb to list list is updated true if list is updated sort list with selection sort, very fast And I have the following results, which can also be helpful to understand what I'm after Influence absorption Influence mask Influence visualisation (city at the brightest spot) |
28 | 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 weight will depend on tile size, produced resources and so on. So I want for those countries to make alliances if their sole weight is much lower or at least lower than a certain threshold than the weight of the neighborhood tile (each sovereign is basically a primitive AI at that stage that is able to make decision to create the alliance). Here is couple of scenarios Here are the examples for bigger maps with possible alliances So my question is is there some kind of algorithm that allows to achieve that or I have to create it myself or use training sets for AI to gain the ability to form alliances? |
28 | Pathfinding in hex grid based game I'm making a TBS using a hex grid. Player can move units from one hex to another using bridges, which will be randomly generated. I'm using cubic and axial coordinate system for my grid, it's well described in Red Blob Games' Hexagonal Grids. I don't know how to make a hex understand connection with another one and then calculate best path for units. I'm not sure how to approach the issue should I make six slots for bridges in my hex class and then calculate path or should I make movement system somehow and then use absence of bridge as a "blocker"? |
28 | 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? EDIT Node based. |
28 | 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 horizontal or vertical to the target point, then we restart this search for every tile that is the nearest one to the target point. I have this result if we take one or the other direction with 54, it ends up with a dead end. For example, if we go up from 40 to 54, then to 60, when we restart the search with G and H, it ends up with "4" (second shema) and comes back in a dead end Why does this happen and how can I solve it? I also looked at the wiki, but I did not understand the system with the colors and the code shown. |
28 | Help me to fine tune my diamond square algorithm Check this map i generated I seeded a sine wave to act as a mountain range. The lower portion of the sine wave looks fine, but the upper side is thin, the algorithm did not do its magic there (expanding with some noise the seeded values to generate wider mountain ranges and then some hills (brown and light brown)). Also, the whole continent shape is not affected by the sine wave. Ideally, it should be like a "S" as the mountain range pretends to be. I bet this is how the diamond square algorithm takes the values it uses to make the average. If not seed the center point of the map, i can not generate a continent, it just makes a pelinesque noise of random hills. Basically, i'm having some hard time trying to control the noise with seeds and toying with amplitude and randomness reduction values. I need some experienced people in world generation and noise to help me out! Thanks! (PS red dots are rivers). |
28 | Algorithm for a dense crowd of people who avoid the player? I want to make a game like this. When player moves other humans will move too. And other humans will push people around. Are there any algorithm for this ? How can i solve this very efficient way ? I dont want to check all objects at scene with loop. And i dont want people overlap. Video https youtu.be V5ZMicq05LQ |
28 | Level design algorithm pattern for Linerunner etc I am wondering how does someone make levels for a game like Linerunner or any other game that uses similar patterns? About Linerunner (game) You are a stick man running, you have to jump or crawl without hitting boxes. Google Play is very illustrative. The algorithm I am looking for How does the game engine know that if it places a box here and here and here, the user will be able to make it without hitting any of the boxes? Two possible solutions came to mind, but neither of them seem very good. Design the entire level. Create an array of small patterns the user can win in and then join the patterns to create a level. I hope someone understands what I am talking about, otherwise I am willing to explain in depth what I want to accomplish. |
28 | Algorithm to generate small tree like branches? I'd like to seed a void map with "branches" of sine waves or any other waveform. Something like Know of any algorithm? Has to be one to generate trees or something like that. |
28 | Algorithm for "healing" multiple rectangles into a smaller number of rectangles? Say I have a grid of rectangles of different shapes and colors and I want to reduce (reasonably close to optimal is fine, optimal is not necessary) the number of rectangles to represent the same layout of colors. The image above is a very simplified case and the whitespace between the rectangles is for visualization only they would actually be tightly packed. What is an approach or algorithm name (happy to google) that can help me do this? |
28 | AI parameters for Tetris like game I am building an AI to play a variation of Tetris. The rules are changed in that there are 19 different types of pieces, rotation is not allowed, and the pieces can be placed anywhere in a 10X10 grid. Also, a line is removed once it is full (all 10 cells contain some block). I was trying to figure out which parameters I might choose in order to optimise how the game is played. Some obvious parameters which I thought of a) A piece should be placed in a position where it forms the maximum number of full lines, as they can be removed in the next step. b) A piece should be placed to minimise the 'bumpiness' or roughness of the topmost surface, i.e, it should be as level as possible. c) This is arguable, but the AI should try to keep as minimum height as possible. d) The number of columns containing atleast one block should be minimised. But the AI is still not playing good enough and keeps getting stuck. I would like to know if there are some other important parameters which I may be missing? |
28 | 2D Drag Racing Algorithm What algorithm can I devise for a 2D drag racing game to simulate a race? The gameplay is 2D and the camera's perspective is from the right side of the cars i.e. cars are seen from their right side in the game. This means that the cars travel in a horizontal line, from left to right till they reach the finish line. There can be many participants in the race however the algorithm must not be affected by the number of participants in a race. It must work for any and every car given the stats of that car and other race time driving info e.g. the time of a gear shift, good shift, perfect shift, over rev, etc. To rephrase my question I am just asking for an algorithm which simulates the car motion velocity along a straight line according to the stats the car has and according to the way the driver shifts up down and revs a car. A car can have many stats. Some I thought of including in the game are General stats Top speed (mph) Acceleration (can be represented by just a number) Power (bhp) Weight (lbs) Grip (can be represented by just a number) Tuning stats Nitrous duration vs. nitrous power (can be represented by just a number) Final drive (can be represented by just a number) Gear ratio for each gear (can be represented by just a number) Tire pressure (can be represented by just a number) Upgrading a part will usually vary these stats. Each participant is able to shift up or down but once the race starts acceleration is automatic. Players will be able to choose from automatic and manual acceleration in a later release for this release the acceleration is automatic. Players must only worry about gear shifting in a race. And outside a race players must worry about changing, upgrading and or tuning their cars. Also, the game is multiplayer on a single system and not on a network. That is, the kind of multiplayer we have on consoles with two controllers. No LAN WiFi networking is involved so we don't have to worry about network lags. Actually, I'm developing the game for Sifteo Cubes. If a single player plays the game we then have AI opponents. We can have any mix of human and AI players in a race as long as their number is within the capacity supported by that race. Right now I am trying to build a prototype so this must be all there is to the game. However, the game will keep evolving after the prototype. It will even keep on evolving after its release in the form of updates and sequels. Any ideas from the gamedev community to make this game better or add remove features are gladly welcome. |
28 | Is there a known most efficient version of A search algorithm? Is there a known 'most efficient' version of the A search algorithm? I know some people write papers on the most efficient way to compute common operations, has this been done for A ? |
28 | Procedural river or road generation for infinite terrain I should say paths, not roads as I'm thinking more medieval like. Also, not looking for realism. The answer I'm looking for will be to fit into the mold I describe rather than realism. I am looking for a method to generate procedural roads rivers in a curvy sort of fashion, but I'm wanting to do so for a infinite terrain type system. Just like how perlin noise generates blobs, I'm wanting to generate random length line segments (possibly infinite length). I'm aware of strategies like the suggested answer found here, however it relies on a specified start and end point to work, I don't have a specified start and end point. I'd like to be able to simply call a function using arbitrary coordinates and have it return whether the specific coordinates are part of the river road. I am not wanting to require terrain to be generated in advance. That includes a heightmap (like used for rainfall simulations or similar). I would also not want to require a start end point. Is there such an algorithm or tweak to a noise algorithm someone might know of to accomplish what I'm trying to explain? The closest I've came to so far is multi ridged fractals, if I'm using the name properly. I'm just taking the absolute value of value noise (assuming it is scaled to 1 to 1) and setting a threshold. My primary issue with this is the lines overlap way too often, are mostly circular, sometimes converge to form large lakes which is neat but undesired, and often times the thickness of the lines vary too much. Here's a picture of what I have so far in 2D, but at a very high frequency to show more detail |
28 | Enemy mathematical behavior I'm really trying to up my game in game mathematics and now I'm working on enemy movement and a bit of AI. I have an enemy with two modes attack and avoid, based on an integer avoid variable that's either 1 or 0. On avoid I want it to hover by the player, moving back and forth at a distance until it is set to avoid. On attack I want to go close at a steady pace say an x and y velocity of 12, then once it reaches a certain distance to gain speed. I have disx and disy variables that have the distance from each other for each coordinate. I also have a totDis variable with the normal a 2 b 2 c 2 formula. I'm pretty sure I'll need another variable that I'll have to change depending on the distance that effects the speed. It kinda feels like I have all the pieces to the puzzle, I just don't know how to put them together though lol. I'd like to be able to do this as mathematically as possible and I don't want anyone to give the the answer or do it for me. I was hoping if anyone could give me pointers or tips or just ideas on the directions I can go myself because I really want to have an understanding of this. I hope this is specific enough, if not I'll try to edit my question for you. |
28 | Creating a Roguelike game in C I'm trying to create a simple rogue like game in ncurses in a C program. The idea here is that, I'd parse a file like this 10X10 ds2 de2 dw5 12X12 ds3 de2 dw1 14X14 ds5 de1 dw5 10X10 ds5 de3 dw5 12X12 ds5 de2 dw5 14X14 dw2 de1 ds2 Where the first number is a door size(rows,columns), the second string being a door, where s south, w west, etc, so ds2 door south 2 down (in the y direction). Effectively, this looks like this when parsed, I have this Where (hopefully viewable), the plus signs at the end of each room, are the doors that lead to another room, so in the first room, the east door would lead to the room to the right, etc. However, this is where I'm not sure how to go about implementing my logic. I need to make it when I step on a plus sign "effectively" a door, I'd teleport the player (the sign cursor) to the correct door. Okay, great I know the locations of each doors, but how would I actually mvoe the cursor to the next room. I can't simply hard code the distance between two rooms, as that's just ineffective and would take too long. Just to clarify, what I mean about teleporting See this picture Where the user " " symbol would move to the door (in the first room), then get teleported to the second room (12x12 room). (AS seen in the next picture) (Again where the symbol is the user, moving the cursor around (w,a,s,d). So to clarify I need a way to move a cursor, between two rooms, without hardcoding the distance between rooms, unless there is an effective way to hard code the distances. Any ideas? |
28 | How to deal with objects placed in the root nodes of a quad tree? I've implemented a quad tree where points and axis aligned rectangles can be put. It works fine, except for one issue that I'll try to describe. When you put a rectangle in the tree and this rectangle collides with quadtree's node borders, than your rectangle is put in parent node of that node. It's ok! That's how it should work! Let's consider I have a small rectangle (red) laying in quadtree's center (x 0, y 0). And I would like to retrieve other rectangles near my rectangle (blue rectangles). But here's the problem, when I do that the algorithm will return all rectangles(blue green), because my rectangle collides with quad tree nodes border and is put in quadtree's root node. I don't need green rectangles and I can't allow myself to have such an overhead. How can I avoid such problem? What would be the easiest way to implement solution to this problem? The current Retrieve method recursively walks to each subnode of the node where red rectangle is positioned. I've heard about overlapping node borders solution, but I guess it won't help in case if red rect would be 3x time bigger?! |
28 | 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 1 7 Play track 1 8 Play track 2 9 Play track 2 10 Play track 3 This is what I have, but problem is track 2 will be used at level 6 when it should be track 1. public static function playGameplayMusic(waveId Int) Void var gamePlayTrackId Int if (waveId 5 0) gamePlayTrackId 3 else if (waveId 3 0 waveId 4 0) gamePlayTrackId 2 else gamePlayTrackId 1 trace('playing gameplay track ' gamePlayTrackId) SoundPlayer.playMusicByName('gameplay ' gamePlayTrackId, false) Update Went with this. Thanks for all your contributions! public static function playGameplayMusic(waveId Int) Void var gamePlayTrackId Int Math.ceil(((waveId 1) 5 1) 2) SoundPlayer.playMusicByName('gameplay ' gamePlayTrackId, false) |
28 | Need help with algorithm for generating connected bricks in Pick A Brick clone I want to make a clone of an Amiga 500 game, Pick A Brick, a 2D game where the goal is to clear a table of bricks by matching them up, following certain rules. I am getting nowhere when it comes to the algorithm for generating the layout of the bricks. I have added the rules of the game (as I remember them) below. The player wins the game by clearing all tiles before the time runs out. Tiles are cleared by clicking on a pair of them and if the following is true The tiles must be of the same type (there is only one pair of each type). There is a clear path between them (more on path in the points below). The path from a tile must always start towards an (clear) edge of the screen. The path between the tiles must be u shaped. (edit) NOTE In the video the path is not always the u shaped. I do not recall if the path shown is just a shortcut or not, but regardless, in my version I do not want to allow removing tiles "from inside out". I have done some manual testing prototyping using both outside in and inside out approaches, with variations on both. So far, nothing I have come up with has really come close. I kind of dislike asking a question like this since it is so specific, probably not of general interest and may take up more than a little time for anyone interested in helping out. That being said, some people enjoy coming up with algorithms and "solving stuff", and the community may learn something from the answer, so, a post it is. (edit) Clarification. The algorithm must provide a solvable solution. |
28 | What algorithm can I use to detect simple shapes in a 4x4 matrix? I'm working on a simple multiplayer game that receives a random 4x4 matrix from a server and extracts a shape from it. For example XXOO OXOO XXOX XXOO XOOX and XOOO XXXX OXXX So in the first matrix the shape I want to parse is oo o oo and the 2nd oo oo ooo I know there must be an algorithm for this because I saw this kind of behavior on some puzzle games but I have no idea how to go about to detecting them or even where to start. So my question is How do I detect what shape is in the matrix and how do I differentiate between multiple colors? (it doesn't come only in X and O, it comes in a maximum of 4). Additionally, the shape must be a minimum of 4 blocks. |
28 | How can I generate random levels like in "Square it!" game? In this game, you have a 2d field with some free squares and two colored squares which you can move but only together (they'll move only if the spot is still "free"). And you have to fill whole free space. Here is a video that demos how the game is played. How can I generate random game levels like in that game? |
28 | 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 of rooms 2. 3 5 different "levels", each with a different amount of rooms 3. the shape and type of the "ground" in each room is dynamically generated 4. each room has some items that are dynamically placed in the room but are generated from a prefab A rough idea on the rooms in this game is given in below screen shot. In that image only the platforms (black and white tiles) and the ground (light brown) would be shaped by an algorithm. The other objects shown in the image are prefabs that would be located somewhere in the room by an algorithm. But considering that this game would not exactly be an infinite runner, and since it should run on smart phones, would it be better from performance perspective, to create 100 hard coded rooms instead? |
28 | "Solve" a game algorithmically creating bots (and making them smart) EDIT at first I gave a lot of context for this question, explaining why I wanted to create a bot. I'm sorry it distracted people from my "actual" question. My question is pretty simple how does one create a bot for a game ? (Especially... on a mac, if it's possible though I can use a Linux virtual machine if needed). Is it interfaced with the application, or just "watching" the screen and extracting information from it (as if it was taking pictures and analyzing them to get informations such as your HP, your position, etc.) ? Could I use python to code it, or are there specific languages ? The forementioned context Since I started programming, I've wanted to try to create algorithms that would be able to "play" (or even "beat") video games. Many games require only logical choices, more and more complex as the difficulty grows, which seems perfect for algorithms. I currently enjoy the game "Pixel Dungeon" a lot (see here), but it's not always nice to you (and you die. A lot.). A few researches on the internet show that a lot can be achieved just by following simple guidelines. So I figured maybe this would be a good game to try and create bots to play it. In the long term, I would like to let bots play, extract data out of it, and modify my algorithms according to these data. I am really enthusiast about this, but also really novice. (maybe this belongs more to https stackoverflow.com ?) |
28 | What are your favourite game specific coding gems? I'll start off with John Carmack's the Fast Inverse Square Root in Quake III float Q rsqrt(float number) long i float x2, y const float threehalfs 1.5F x2 number 0.5F y number i ( long ) amp y i 0x5f3759df ( i gt gt 1 ) y ( float ) amp i y y ( threehalfs ( x2 y y ) ) return y |
28 | Flowfield density conversion I'm trying to implement flowfield navigation, as described in http grail.cs.washington.edu projects crowd flows but I can't understand how the Density Function in Figure 4 of the paper is supposed to handle unit radius. Has anyone ever implemented that and can provide more information? This is the part in question Their algorithm seems to be using only 4 cells, pointing to the lower left of the unit, so is this some kind of kernel that needs to be applied multiple times? Thanks. |
28 | How could I improve this random map? following my previous post on random world map generation, I used several algorithms and obtained results similar to this http i.imgur.com CKL2R.png (the height values are quantisied for viewing but they go from 1 to 500 before quantisation). Now I am trying to improve the "lakes", as you can see, the water bodies that are inside the map are always at 0 altitude, which means that every lake would be at the ocean level. I am willing to keep these "ocean level lakes" (or remove them), but I would like suggestion on how to create from this heightmap real lakes that would be possibly at any height, while keeping most of the altitude structure (ie mountains positions, etc) thanks |
28 | How do you map a 3D scene to a stero image pair? I'm a novice. I'm working in XNA studio with simple models. How can I turn a 3D image into two images meant for the left and right eyes respectively? Note I'm not referring to "magic eye" I'm wondering how you calculate the left and right images starting from the 3D scene info. |
28 | Real Time Dynamic Pathfinding? I'm currently doing some pathfinding research and my simulation is the following I have a 3d scene with a start and end point represented, I'm capable of creating navigational meshes, waypoints and polygons to aid with pathfinding. I've tried an A algorithm and some of its variants and they work perfectly. However, now I'm more interested in 'dynamic' pathfinding. For example, while finding a path from point A to point B, if a new obstacle suddenly appears, i want my algorithm to immediately be able to re plan a path and not start searching from scratch again. I've done some reading on the D algorithm and wondering if this would be appropriate for what I need or would this seem like an overkill. So my questions basically are What algorithm would be best for Real Time Dynamic Pathfinding? OR what combination of techniques could I use instead? |
28 | C XNA Effecient mesh building algorithm for voxel based terrain ("top" outside layer only, non destructible) To put this bluntly, for non destructible non constructible voxel style terrain, are generated meshes handled much better than instancing? Is there another method to achieve millions of visible quad faces per scene with ease? If generated meshes per chunk is the way to go, what kind of algorithm might I want to use based on only EVER needing the outer layer rendered? I'm using 3D Perlin Noise for terrain generation (for overhangs caves etc). The layout is fantastic, but even for around 20k visible faces, it's quite slow using instancing (whether it's one big draw call or multiple smaller chunks). I've simplified it to the point of removing non visible cubes and only having the top faces of my cube like terrain be rendered, but with 20k quad instances, it's still pretty sluggish (30fps on my machine). My goal is for the world to be made using quite small cubes. Where multiple games (IE Minecraft) have the player 1x1 cube in width length and 2 high, I'm shooting for 6x6 width length and 9 high. With a lot of advantages as far as gameplay goes, it also means I could quite easily have a single scene with millions of truly visible quads. So, I have been trying to look into changing my method from instancing to mesh generation on a chunk by chunk basis. Do video cards handle this type of processing better than separate quads cubes through instancing? What kind of existing algorithms should I be looking into? I've seen references to marching cubes a few times now, but I haven't spent much time investigating it since I don't know if it's the better route for my situation or not. I'm also starting to doubt my need of using 3D Perlin noise for terrain generation since I won't want the kind of depth it would seem best at. I just like the idea of overhangs and occasional cave like structures, but could find no better 'surface only' algorithms to cover that. If anyone has any better suggestions there, feel free to throw them at me too. Thanks, Mythics |
28 | Pathfinding with inertia I'm currently working for pathfinding for a game where units are moving, but they have inertia. Most typical pathfinding algorithms (A , Djikastra, etc.) are simply designed to minimize the length of the path. However, these techniques do not apply, as far as I know, to instances where the unit has inertia. If the unit has inertia, then there is a significant difference in the cost to leave a tile in a particular direction based on the direction you want to go. For example, the cost of leaving a tile proceeding North is significantly higher if you entered the tile from the East than if you entered from the South. (In the former example, you would have to slow down to halt you East West velocity, while in the latter, you could go straight through.) The fact that the system has inertia means that in order to make a turn, you may have to slow down well in advance of making the turn. My best thought to date is that you calculate the additional time it would take to slow down, and then add it to the heuristic cost of moving. However, this would seem to imply that you could never add a tile to the closed list, as entering from another direction could fundamentally change the cost of moving. In addition, the concept of using a grid is an abstraction anyway, because both position and velocity are floating point concepts. Is there some algorithm that could handle pathfinding on an open plane with inertia better than A , or what modifications could I make to a pre existing algorithm to make it suitable to this kind of motion? |
28 | 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 you designate only threats, perhaps with a main threat first and foremost, can you use it for "finding somewhere to go"? What about adding both threats, safety, resources and other such heuristic influencers to determine what a unit does when idle? |
28 | Creating the nodes for path finding during run time more like path making and more I'm making my 1st game. I'm using javascript as I currently want to learn to make games without needing to learn another language but this is more of a general game dev question. It's a 2d turn based tile grid game. You can check it here http www.patinterotest.tk it creates a movable area when you hover a player and it implements the A algorithm for moving the player. The Problem I want to make the 'dynamic movable area creation' already implement a limited number of steps for a player. The Questions What is a good way to do this? Is there another algorithm to use for this? The A algorithm needs a start and destination, with what I want to do I don't have a destination Or should I just limit the iteration of the A algorithm to the steps variable? |
28 | How does A pathfinding work? I would like to understand on a fundamental level the way in which A pathfinding works. Any code or psuedo code implementations as well as visualizations would be helpful. |
28 | Spell casting How to optimize damage per second Imagine we have a wizard that knows a few spells. Each spell has 3 attributes Damage, cool down time, and a cast time. Pretty standard RPG stuff. Cooldown time the amount of time (t) it takes before being able to cast that spell again. A spell goes on "cooldown" the moment it begins casting. Cast time the amount of time (t) it takes to use a spell. While the wizard is casting something another spell cannot be cast and it cannot be canceled. The question is How would you maximize damage given different sets of spells? It is easy to calculate the highest damage per cast time. But what about in situations where it is better to wait then to get "stuck" casting a low damage spell when a much higher one is available? For example, Fireball 3000 damage, 3 second cast time, 6 second cool down. Frostbolt 20 damage, 4 second cast time, 4 second cool down. Fireblast 3 damage, 3 second cast time, 3 second cool down. In this case your damage per second is higher if you chose to go for the lower DPCT spell (fireblast) instead of the frostbolt. So we must consider consequences of choosing a spell. In the following example are cases of "over casting" and "waiting". |
28 | 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 vy ay vz az ball.x vx ball.y vy ball.z vz function hitBall(destinationx, destinationy 0, destinationz) calculate vx, vy, vz, so ball imapcts the point (destinationX, 0, destinationZ) destinationY 0 bounce on floor vx .... vy .... vz .... I guess this problem has infinite solution, so we must intersect with 1 point intersection line is (x,1,12) 12 is middle of the tennis court and 1 is 1 metter above the ground. ball passes there 1 meter above the ground. Any clue on how to resolve that math problem ? regards Google doc https docs.google.com presentation d 1EiUYpalDXlJUgjg8aIxLiWENgZJW7fnH4bGHsj1jb9I edit?usp sharing |
28 | Calculate 8 different directional input based on arrow keys combinations Considering I have four variables event binded to each arrow key, that can be 0 or 1 My current approach to this issue is simply 8 nested ifs checking each combination or keys Is there a more math y clever way to solve this issue? |
28 | Raycast algorithm fails to collide with diagonal walls in specific locations I'm having a problem with my ray cast algorithm in a 2D tile based universe. I feel the situation would be best explained with a picture, so here it is The ray, represented by the blue line, is passing "through" the wall to hit its target when the wall passes through a point where the quantized line moves diagonally and the wall is perpendicular to it. The raycast function is as such def raycast(pos, direction, level) dx, dy direction t 0 x, y pos obj None while not obj and t lt 5000 t 1 x dx y dy obj level.get at((round(x),round(y)),True) pass return obj Is there a simple, efficient way to eliminate this kind of edge case? |
28 | How to implement A.I. for checkers draughts? I saw this checkers game and I wondered how the A.I. was implemented. How should I implement an A.I. for checkers (draughts, dama, dame)? Are there any known algorithms? Very thnaks full to all. I m very wonder to see this Tic Tac Toe game tutorial blog post. So, i want dama game algorithm open source code and blog post.. Is there any helpful link or any doc file..? please let me know.. |
28 | MiniMax strategy What is the context of the numbers? I've watched a new videos about the MiniMax concept and invariably the lecturer will say that the computer has 2 parties, Min and Max Min always takes lower number and Max takes higher number. The problem I have is this. I'm finding it hard to understand why Min takes the lower number at all or why Max takes the higher number at all? What is the reasoning and context for these numbers? I mean, logically I know that 7 is higher than 3 but that doesn't mean anything by itself. What is the context of the numbers? Many thanks |
28 | Score Based on Game play Time and a Int I'm trying to do a score that is based on the time taken and number of manipulators used. The faster you do it, with the fewest manipulators, the higher the score. I've managed to get it working with you get the lowest score but not the highest and i can't think how to do it. Any help would be appreciated. I have a play time (GameTime.TotalGameTime.TotalSeconds startTime.TotalSeconds) and a count of the manipulators used (grid.NumberOfManipulatorsInGrid(TextureList.GameplayTextures)) to work with |
28 | 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 can procedurally generate random looking curve that would conform to the Star Wars engagement intensity pattern (linear increase and oscillating peaks valleys). The simplest implementation I can think of is a rectified sine wave and a sloped line, but that would be very predictable. I have an algorithm for perlin noise already in the game and am interested if I can leverage perlin noise algorithm to procedurally generate a varying sequence of peaks and valleys on an increasing slope. Here's my attempt so far Once I have an algorithm, I can reference it to get engagement difficulty in relation to game turn or progress through some level. I will add my thoughts to this question in hopes that someone can correct or point out flaws in my approach below I get the basic XP system in place (previous level 1000 to advance to next level) Decide on the level cap (lets say 20 levels) Plot available equipment tiers vs 20 levels (regular at lvl 1, magical at lvl 10, epic at lvl 20) Using the peak valley graph decide how many fights are in each peak valley cycle (5 to reach lvl 2, 12 to reach lvl 20). estimate number of turns per fight, let's say 5 turns per fight calculate xp needed and turns needed to reach to each new level Plot turn number and hypothetical xp the party has at each level. Now for each peak I have a number of turns and the amount of XP that the curve should have between two valleys. Using whatever formula the curve follows at that peak (let's assume a bell curve), I can get the xp value of monsters I have to spawn during that turn. These monsters have their equipment adjusted according to the equipment vs tier turn number that was calculated above. Now I need to adjust monster XP and test it at different levels. A simple sanity check a party of 6 players must kill 750 xp of monsters in first fight in 5 turns, that is 30 actions. 1500 in second fight 1800 in third fight 1350 in fourth 555 in fifth |
28 | Connecting two arbitrary points with 2 lines DEFINITIONS Any "Point (x, y)" mentioned below is really the bottom left coordinates of a 1 unit by 1 unit rectangle. A "Line" is a defined as a rectangle that is either 1 unit tall and 1 unit or greater wide, or 1 unit wide and 1 unit or greater tall. These rectangles are constructed given a Rectangle(bottomLeftX, bottomLeftY, width, height). The height and or width can be negative. If either are it will shift the start x or y accordingly as so public Rectangle(int x1, int y1, int width, int height) left x1 right x1 if(width lt 0) left width else right width bottom y1 top y1 if(height lt 0) bottom height else top height THE GOAL Given two arbitrary points, define two lines (as rectangles) connecting the two points. The two lines need to randomly 'bend' at one of the two possible connections (see below). The two points aren't in any specific order. Point A's X and or Y can be above, below or even the same as Point B's X and or Y. THE PROBLEM I have made a solution that only partially works. There is a bug in my method below where sometimes the two lines do not connect at the bend junction. It seems to only be when the bend junction is in the bottom right of the points' bounds. WHAT I HAVE NOW A little background I'm working on a random dungeon generator. I create rooms randomly, and then I am going to connect them using the described point and line system above. Here's what I have now. "graph" is a Map , technically it's directional, but the reason was so that I wouldn't draw the same lines twice. int x, y, dx, dy Rectangle a, b loop through each edge of the graph for(Rectangle outer graph.keySet()) for(Rectangle inner graph.get(outer)) randomly set a and b if(random.nextBoolean()) a outer b inner else a inner b outer generate the origin points based on a x (int) a.getCenterX() y (int) a.getCenterY() and the delta of b to a dx (int) b.getCenterX() x dy (int) b.getCenterY() y create line starting at a, then create line starting at end of above line lines.add(new Rectangle(x, y, dx, 1)) lines.add(new Rectangle(x dx, y dy, 1, dy)) Here's what it produces. Most of the time it works, however there are cases where the corners do not line up. I'm not sure how to fix this. Any input is much appreciated. |
28 | How can I generate Worms style terrain? I'm working on a Worms styled game and want to generate some terrain procedurally. I've previously done a lot of terrain generation using perlin noise, and this is what I started out using for this game. The only problem with it is that it's too simple and boring, giving me some hills but not the complexity I want. I'd like to have features like caves and hanging mountains and I don't mind floating islands and such. Something like this, but even crazier would be ok I thought of first generating the terrain using classic perlin noise, then just removing parts to create caves and what not, but I'm having trouble guiding the removal of those parts. Are there any alternatives to generating such a terrain? |
28 | How can I create the arriving engaging in combat movement like in StarCraft 2? I currently have two armies (smaller scale) crashing into each other. They will usually form a line of units fighting. I have no idea how to handle a unit coming from behind the line to properly go around its allies to reach the enemies. Like in this position, where a new unit approaching from the green army needs to navigate around the battle front to reach the red enemies StarCraft 2 handles this beautifully, as seen here I've read that SC2 uses steering for local avoidance and A and some other methods to plan out the paths. Which all is perfectly clear, but I haven't found anywhere any details on engaging the enemy. This is what I have, it's been a month and I still haven't solved this specific issue. How is it possible to do continuous checks of possible destinations before engaging the enemy, wouldn't it be too costly? To clarify, in the video of the Zerglings vs Zealots, they first engage each other and form a line, all the other units that come after them will go around the line, but, if space opens in the line they will immediately go towards it. This kind of arrival behaviour is briefly explained in their GDC talk, they have a cone of vision in which they do checks. The only ideas I had was Have a cone of vectors (in the direction of Velocity) and do checks for each vector to see if it could provide a favorable position to move to issue Cannot figure out the math to create offsetted (by an angle) vectors, but it seems like a pretty decent solution Have a spatial query in a rectangle to where the unit is moving issue How do I check for an empty space? I can get all entities in that rectangle but how can I check for empty places and score them (how favorable are they)? Are they even reachable, I'd still need some kind of raycast like with the first option I have circlular collision shapes, seperation and goal following in place. I somewhat have introduced a goal system that should further spread the units, but as it stands I still lack the arrival behaviour described in the GDC talk. |
28 | Locating point on a closed path to maximize sum of distances to a sample of weighted points I'm doing AI for a simple puzzled game and need to solve the following problem efficiently (less than 1 sec for the range specified since I need to do many iterations in a game). A sample of N (1 to 100,000) monsters with strength from 1 to 10,000 are distributed on the sides of a square (0 to 200,000,000) at 1 unit interval starting from the upper left corner. Move hero to a point X on the square to maximize sum of the weighted distances to the monsters. A weighted distance to each monster is calculated by MonsterStrength ShortestDistanceToX (by going clockwise or anticlockwise). X must also be on the 1 unit interval mark and the monsters and hero move on the sides of the square only I have tried several approaches but none are fast or accurate enough. The possibly complementary of this problem (minimizing the sum of distances to set of points at furthest distance from each corresponding monsters in the original set) seems to related to finding the geometric median, facility location problem, Weber problem etc. Linear programming is also possible but might be too slow and overkilled. Does anyone have any idea for a good approach? Here is an illustration on a square of sides of length 3 1 2(M 3) 3 4(M 1) 12(M 2) 5 11(M 1) 6 10 9 8(X) 7 if you put a monster of strength 3 at 2, one with strenth 1 at 4, one with strength 2 at 12 and one with strength 1 at 11 and the hero(X) at 8. the sum of weighted distane is 3 6 1 4 1 3 2 4 33, which is also the maximum in this case |
28 | What is the simplest method to generate smooth terrain for a 2d game? What is the simplest method to generate smooth terrain for a 2d game like "Moon Buggy" or "Route 960"? I got an answer at stackoverflow.com about generate an array of random heights and blur them later. Yes, it's quite okay. But it would be better to give some points, and get a smooth curve. |
28 | How to create a random, warped 2D grid? How do you create a random grid where the lines aren't orthogonal (and cells aren't a perfect square), but are warped? Here's an example of what I mean (Credit screenshot taken from a video by Silvarret about the game Townscaper.) Lines curve. Sometimes many cells come together in a single point. Yet, it still looks like a grid and the cells are clearly visible and roughly equal in size and shape. I have absolutely no clue how to go about something like this. How is this achieved? Is there an algorithm for this? How would you detect the cell over which the mouse hovers? |
28 | Predicting enemy position in order to have an object lead its target In my 2D game I have AI turrets that should assist the player by automatically firing towards enemies. I would like to make them fire intelligently and lead their target instead of just targeting an enemy's current position. So, given the (always constant) velocity and position vector of both the enemy and the turret's projectile, how can I find a vector that represents the actual position the turret must target in order for the projectile to intersect (and hit) the enemy? Any links to articles that describe the math, algorithms, etc. would be appreciated! |
28 | Axis Aligned Spatial Division Divide space into random rectangles? I need a method to divide 3d space into random axis aligned box shapes. For now I am currently dividing the 2d space for testing purposes. The most immediate approach I came up with was to define a rectangle of size (1, 1) and then recursively split all existing rectangles to two uneven rectangles alternating between axis X and Y. The problem here is obvious. This approach results in long stretching lines (marked in red) What I would like is something more organic looking (I included an example) See, no long straight lines from top to bottom or left to right. The only constraint is that I may wish to limit the minimal size of the rectangle without affecting the granularity of the sizes. i.e. if the smallest rect is 1 square centimeters than the seconds smallest room should not be 2 square units. So ideally the algorithm should meet all three following constraints Rectangles are not infinitesimally small. Rect sizes aren't discrete multiplication of the smallest rect size. i.e. if the smallest rect is 3 square unit than larger rects are not constrained to be 6, 9, 12 and so forth square units and instead could be 3.2 or 4.7 for that matter). The algorithm runs in polynomial time (needs to compute fast). |
Subsets and Splits