_id
int64
0
49
text
stringlengths
71
4.19k
28
Is there a repository of game logic algorithms? I'm writing my first 2D game, and I'm writing some tracking logic for the computer enemies. Basic follow the player tracking was easy, but ineffectual. Too easy to escape. So I'm trying to implement some more sophisticated flanking and other tactics, and (as expected) it's pretty tricky. This is a topic I know nothing about. I'm going to keep trying, but it'd be awesome to have some examples or tips to work off of. Is there any place that has a decent set of pseudocode AI algorithms, or tips or advice on the subject, e.g. for 2D tracking?
28
Is A efficient even when the obstacles are moving? I'm just starting to learn about path finding and have been looking into the A algorithm and my main concern is that it all of the examples I have seen show static obstacles that it computes around. If I have moving obstacles, say other characters for example, moving around as well that the character must find their way around, I'm assuming I'll have to run the algorithm each frame, but I'm worried that will become rather expensive for the hardware to process each frame for each moving actor. So is A still efficient enough to use whenever the obstacles are moving too, or is there another method of path finding that handles moving obstacles more eloquently?
28
Is there a repository of game logic algorithms? I'm writing my first 2D game, and I'm writing some tracking logic for the computer enemies. Basic follow the player tracking was easy, but ineffectual. Too easy to escape. So I'm trying to implement some more sophisticated flanking and other tactics, and (as expected) it's pretty tricky. This is a topic I know nothing about. I'm going to keep trying, but it'd be awesome to have some examples or tips to work off of. Is there any place that has a decent set of pseudocode AI algorithms, or tips or advice on the subject, e.g. for 2D tracking?
28
Algorithm for generating a 2d maze What algorithm have you used in the past to generate a simple 2d maze?
28
How to avoid self intersection when applying stroke to a curve? I have several Spline2D objects in my code, each of which has a Position, Velocity, and Acceleration method that returns a vector of the specified quantity at a particular time. I've been using these vectors in order to construct geometry to create gradient strokes for the curves, but I'm having problems with self intersections at steep curves. As an example, here's one curve where I'm having this occur Wireframe http twitpic.com 2zplw1 full Filled http twitpic.com 2zpmnt full As you can see, on the second bend, the inner portion intersects itself, which causes that ugly artifact. Is there a good algorithm method to stroke curves without causing that self intersection? EDIT More extreme examples, plus a mock up of what I'd like to achieve Wireframe http twitpic.com 2ztwzi full Filled http twitpic.com 2ztwkt full Ideal Outcome (Mock Up) http twitpic.com 2ztxa8 full
28
Programatically placing musical notes on a stave I'm trying to program a musical stave and have come against the problem of where to place a note, given its index. The index of a note is defined from a model created from the table in the following Piano Note Frequencies For example, in the model, C4 has an index of 40 and D 5 an index of 55. Here is an image of what the stave currently looks like The text in red shows the indices the stave has available to put notes (disregard the horizontal position). Only a few indices are shown, however they extend much further. For example, placing a note on the stave at index 0, it appears at A4 on the stave. I'm having difficulty translating from an index in the note model, to an index on the musical stave. At first, I've done a (knowingly) naive implementation. Index 0 in the stave corresponds to A4, or index 49 in the note model. Given an index from the model, calculate how many half steps away the index is and use this as the index in the stave. For example, C5 is index 52 and gives a stave index of 3. Looking at the above image, it's clear this is wrong for two reasons. Firstly, we didn't account for a note and its sharp laying on the same index. Secondly, we didn't account that B4 and C5 have one half step between them, but are in different places on the stave. I've been scratching my head over this for a while. What are the rules to follow for translating from a note index to a position on the stave? EDIT Each note in the note model knows whether it is sharp or not, its pitch (e.g. C, D, E, etc), and octave.
28
How should a circuit or power system (like redstone in Minecraft) be implemented I want to implement a power system like the redstone system in minecraft. I have n power sources and m cables. If I disconnect the power source or a cable the circuit should turn off. How do I avoid circles? If each cable with the status "on" powers the nearby cables I can create infinite circles where there is no power source involved (see image). Plus site is that it runs in T m I could send power burst through the graph starting at every power source and in each update call I turn every cable off. Problem is it runs in T n m. Is there a best practice? In Minecraft the redstone system was very slow so I think I overlooked something. EDIT The system should work without a distance based decay.
28
Where can I find info on grid based algorithms for stateless AI? There seems to be an overwhelming amount of info out there on AI of all kinds, and it's kind hard to digest at once. For my testing purposes, I'm creating a "typical stateless AI", as described in this article, and now I need to implement the following functions for a 2D square based game board (void)runAway (void)attackPlayer (void)moveTowardsPlayer (void)tacticalMoveAwayFromPlayer (void)waitOrStationaryAction For example, I can run my own run away function like this (void)runAway DLog( "runAway") self debugMessage int bestTileIndex 0 int largestDistance 0 int distance 0 if(validMoves.count gt 0) for(NSNumber tileNumber in validMoves) distance self distanceToTargetFromTile tileNumber.intValue if(distance gt largestDistance) largestDistance distance bestTileIndex tileNumber.intValue move to best tile but this method only checks the distance from 1 target, which may not be the best if there are multiple enemies on the game board. Where can I find good efficient implementations of algorithms for searching a 2D grid for these functions? For example finding a point that is furthest away from multiple opponents and is accessible within a certain number of moves. Other functions that come to mind is picking the best weakest target, moving towards a specific target while accounting for variable terrain cost, etc I'm certain someone has already done this before.
28
Square collision Detect which side of the wall it collided I'm using a standard square collision in my 2D game. The player shoots little balls, and when they hit any wall it should bounce. The problem is that I know when it hits a wall but I don't know if the collision happened on the side or top bottom of the wall. Here's my collision algorithm (pseudo code) If A.x lt (B.x B.width) AND B.x lt (A.x A.width) AND A.y lt (B.y B.height) AND B.y lt (A.y A.height) Then a collision happened Is it easy to detect if the collision happened on a side or top bottom? If yes how should I do it?
28
How do I determine the draw order in an isometric view flash game? This is for a flash game, with isometric view. I need to know how to sort object so that there is no need for z buffer checking when drawing. This might seem easy but there is another restriction, a scene can have 10,000 objects so the algorithm needs to be run in less than O(n 2). All objects are rectangular boxes, and there are 3 4 objects moving in the scene. What's the best way to do this? UPDATE in each tile there is only object (I mean objects can not stack on top of each other). and we access to both map of Objects and Objects have their own position. UPDATE2 see these figures in first one first blue object should be drawn then green then red. while in second one you have to draw them in reverse order. you need to draw red first and then green and finally blue object. as you can see there is no difference in position of blue and red objects ,they both have different distance from camera and so on. but because of their relative position to green box, you need to change their draw order between two images. that's what makes this problem a mess. side note since all objects are rectangular prism, it's mathematically provable that there is at least one draw order to satisfy problem needs.
28
Help understanding Simplex Noise Introduction This is less of a "how to" on using 2D simplex noise and more of a quest to understand what is happening both in the math and visually. I would rather not copy and paste the code I've found. I really would like to understand it. I have done my homework on the subject and have read through Stefan Gustavson's paper and other sources many times. I feel like I understand about 70 of what my sources are saying, but when I try to manually follow my code loop through to check my understanding I either get hung up on what the variables represent or the math just doesn't add up. I have begun to rename the variables in the code I've found in order to better understand what's going on. If someone with some knowledge of what is actually happening can cross reference the original code (basically Gustavson's code) with my code that would be most excellent. I'm not actually done with renaming the variables though, partly because I'm stuck. My Understanding Let's say I pass pixel (2, 3) into my noise function. At this point I'm working with a normal grid and my goal is to translate this normal grid into a simplex. This simplex is in the form of many triangles since we're working in 2D and supposedly this is better for various reasons. To translate this point from the normal grid to the simplex grid, I must scale the point along the main diagonal line. After doing that, I apparently don't care about the decimals because I then Floor the results putting it back near the closest previous grid point. Now I'm going to align the simplex cell to the normal grid by unskewing the simplex cell. Why I do all this work to get to the simplex cell, then undo it I'm pretty hazy on. Seriously, I think the best way for me to understand this is if someone could whiteboard out in steps what the heck is going on here. Super lost. I didn't walk away empty handed though. I now have what I believe to be the distance between the original grid point I passed in and the simplex point I translated from that original grid point. Woo. I think I'll stop here for now, just because I don't want this to turn into a huge wall of text. I'm pretty sure the rest of this will click once I understand the the beginning part. Weird Math Using the (2, 3) point from earlier, this is what I get by stepping through my own code on paper x 2 y 3 skewfactor 1.830 unskewFactor 1.479 unskewed x 1.520 unskewed y 2.520 simplexCell i 3 simplexCell j 4 x distance0 1.520 y distance0 1.520 i1 0 j1 1 x1 1.309 y1 2.309 x2 2.5207 y2 2.5207 ii no idea why this isn't i2 or something like that. No idea what this is. jj same Not sure if plotting on a graph would work, but I tried and it looks so bad. I used the original parameters (2, 3), simplexCell i amp j, i1, j1, x1, y1, x2, and y2. Doesn't make any sense visually. Not just visually, but mathematically as well. What's with (2, 3) returning negative numbers that go off the chart? What am I doing wrong here?
28
How can I make a "paint" effect? I am wondering how one could implement "paint" in games. As a reference, I have two games I am specifically thinking about which are Super Mario Sunshine with its "goo" and Splatoon. I'm wondering how I could replicate that kind of paint effect, where paint can be sprayed on to both the walls and floors of the environment, and on to objects.
28
How do I calculate market share in an economic simulation? I want to make a game in which the players create different products (supply), and I give them a certain finite number of customers (demand). Players can choose the price and quality of their products (among perhaps other variables). I've been trying to come up with an algorithm to decide on the market share of each product based on those variables. I could do something random, but thought I'd ask first!
28
Find a line that connects the outer most points in a set of points Does anyone know an efficient algorithm to find the edge of a point cloud? Hopefully the picture in the link can illustrate what I mean. It's a plus if the algorithm can handle point clouds that are distinctly separated in space. The algorithm only needs to work in 2D. Many thanks!! http uploadpic.org storage 2011 4n68m1OYLSYIGt8vfuJrK1LnA.png
28
How to implement auto aiming auto targeting We all know how auto aiming or auto targeting works in games. Now, I need to find how to implement it in my game. In fact I should implement it in UDK and I would be glad if anyone gave me more specific explanation for UDK. But conceptual explanation is also enjoyable and I'll implement it myself in my way.
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
Swept AABB vs Line Segment in 2D I've been trying to get a swept collision detection up and running now for almost a week and I can't for the life of me get it working. There is a answer on this linked here below Swept AABB vs Line Segment 2D I've translated this into Go which will be running the game server and needs this logic func SweepRectLine(rectX, rectY, rectW, rectH, rectHSpeed, rectVSpeed, lineX1, lineY1, lineX2, lineY2 float64) (bool, float64) outVel 2 float64 hitNormal 2 float64 lineNX, lineNY lineX2 lineX1, lineY2 lineY1 lineMinX, lineMaxX, lineMinY, lineMaxY math.Min(lineX1, lineX2), math.Max(lineX1, lineX2), math.Min(lineY1, lineY2), math.Max(lineY1, lineY2) var lineMinX, lineMaxX, lineMinY, lineMaxY float64 if lineNX gt 0 lineMinX, lineMaxX lineX1, lineX2 else lineMinX, lineMaxX lineX2, lineX1 if lineNY gt 0 lineMinY, lineMaxY lineY1, lineY2 else lineMinY, lineMaxY lineY2, lineY1 r (rectW 2) math.Abs(lineNX) (rectH 2) math.Abs(lineNY) radius to Line boxProj (lineX1 rectX) lineNX (lineY1 rectY) lineNY velProj rectHSpeed lineNX rectVSpeed lineNY if velProj lt 0 r 1 hitTime math.Max((boxProj r) velProj, 0) outTime math.Min((boxProj r) velProj, 1) log.Println( quot start quot , hitTime, outTime) rectXMax, rectXMin rectX rectW 2, rectX rectW 2 if rectHSpeed lt 0 left if rectXMax lt lineMinX return false, 0 hitTime math.Max((lineMaxX rectXMin) rectHSpeed, hitTime) outTime math.Min((lineMinX rectXMax) rectHSpeed, outTime) else if rectHSpeed gt 0 right if rectXMin gt lineMaxX return false, 0 hitTime math.Max((lineMinX rectXMax) rectHSpeed, hitTime) outTime math.Min((lineMaxX rectXMin) rectHSpeed, outTime) log.Println( quot right quot , hitTime, outTime) else if lineMinX gt rectXMax lineMaxX lt rectXMin return false, 0 if hitTime gt outTime return false, 0 rectYMax, rectYMin rectY rectH 2, rectY rectH 2 if rectVSpeed lt 0 up if rectYMax lt lineMinY return false, 0 hitTime math.Max((lineMaxY rectYMin) rectVSpeed, hitTime) outTime math.Min((lineMinY rectYMax) rectVSpeed, outTime) else if rectVSpeed gt 0 down if rectYMin gt lineMaxY return false, 0 hitTime math.Max((lineMinY rectYMax) rectVSpeed, hitTime) outTime math.Min((lineMaxY rectYMin) rectVSpeed, outTime) else if lineMinY gt rectYMax lineMaxY lt rectYMin return false, 0 if hitTime gt outTime return false, 0 outVel 0 rectHSpeed hitTime outVel 1 rectVSpeed hitTime return true, hitTime I also put up a Gist with a executable UI here https gist.github.com KidLinus 3f847c46b0e6dc1addac7252d9cb54ab I can't for the life of me figure out what all class variables stand for. I think that some of them are native to Unity but that's just a guess. I've come so far as to figure out that the extent is half of the width height in said direction. What the quot line.n quot stands for is anyones guess, I assume its the direction and have no idea if it's normalized or not. There are also a couple of dead variables just laying there.
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
Algorithm for querying linearly through a non linear list of questions For a multiplayers trivia game, I need to supply my users with a new quizz in a desired subject (Science, Maths, Litt. and such) at the start of every game. I've generated about 5K quizzes for each subject and filled my database with them. So my 'Quizzes' database looks like this ID Subject Question 23 Science What's water? 42 Maths What's 2 2? 99 Litt. Who wrote "Pride and Prejudice"? 123 Litt. Who wrote "On The Road"? 146 Maths What's 2 2? 599 Science You know what's cool? 1042 Maths What's the Fibonacci Sequence? 1056 Maths What's 42? And so on... (Much more detailed complex but I'll keep the exemple simple) As you can see, due to technical constraints (MongoDB), my IDs are not linear but I can use them as an increasing suite. So far, my algorithm to ensure two users get a new quizz when they play together is the following Take the last played quizzes by P1 and P2 var q one player one.getLastPlayedQuizz('Maths') var q two player two.getLastPlayedQuizz('Maths') If both of them never played in the subject, return first quizz in the list if ((q one NULL) amp amp (q two NULL)) return QuizzDB.findOne( subject 'Maths' ) If one of them never played, play the next quizz for the other player This quizz is found by asking for the first quizz in the desired subject where the ID is greater than the last played quizz's ID (if the last played quizz ID is 42, this will return 146 following the above example database) if (q one NULL) return QuizzDB.findOne( subject 'Maths', ID gt q two ) if (q two NULL) return QuizzDB.findOne( subject 'Maths', ID gt q one ) And if both of them have a lastPlayedQuizz, we return the next quizz for the player whose lastPlayedQuizz got the higher ID if (q one gt q two) return QuizzDB.findOne( subject 'Maths', ID gt q one ) else return QuizzDB.findOne( subject 'Maths', ID gt q two ) Now here comes the real problem Once I get to the end of my database (let's say, P1's last played quizz in 'Maths' is 1056, P2's is 146 and P3 is 1042), following my algorithm, P1's ID is the highest so I ask for the next question in 'Maths' where ID is superior to 1056. There is nothing, so I roll back to the beginning of my quizz list (with a random skipper to avoid having the first question always show up). P1 and P2's last played will then be 42 and they will start fresh from the beginning of the list. However, if P1 (42) plays against P3 (1042), the resulting ID will be 1056...which P1 already played two games ago. Basically, players who just "rolled back" to the beginning of the list will be brought back to the end of the list by players who still haven't rolled back. The rollback WILL happen in the end, but it'll take time and there'll be a "bottleneck" at the beginning and at the end. Thus my question What would be the best algorith to avoid this bottleneck and ensure players don't get stuck endlessly on the same quizzes? Also bear in mind that I've got some technical constraints I can't get a random question in a subject (ie no "QuizzDB.findOne( subject 'Maths' ).skip(random()) "). It's cool to skip on one to twenty records, but the MongoDB documentation warns against skipping too many documents. I would like to avoid building an array of every quizz played by each player and find the next non played in the database with a nin. Thanks for your help
28
How to find a safe path for an AI snake? I have been working on a game in which a player can compete with a snake ai to get the most apples. The current path finding technique i use (A Pathfinding) works fine. But I am struggling with coming with an effective way to make sure that the AI snake does not go for an objective that leads to it trapping itself. Consider that the snake can teleport and that there may be max 4 apples on the map at any given time. The decision tree I am trying to create looks somewhat like this If path to goal is safe go for apple! Else check next apple until a safe path is found or all apples are checked. If no path to any apple is safe including the paths produced if teleportation is possible, Then find the farthest path to the tail and remain chasing the tail until a safe path to an objective becomes available. If no path to tail is found stall until death! The problem is that it is really hard to find a fast and efficient way to determine if a path is safe! My question is what is a good way to determine if a path into an enclosed area is safe given that you cannot take the same path back out of that area?
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
Generating random Pools or lakes I have implemented functions that can draw any polygonal shape, however I have been unable to generate a smooth shape that mimics the rounded edges of a lake. I tried generating two circles and joining the edges but there is not enough variation or smoothness to it. Does anyone have any pointers or ideas that could generate a shape like this?
28
How to get a smooth path for a vehicle in a 2D top down map? I am making a 2D tile based game which involves having AI that needs to traverse the map avoiding obstacles in a natural and smooth path (NOT NECESSARY THE SHORTEST) The orientation of the vehicle is also important in the example above the initial orientation of the vehicle is to NORTH but the orientation of the vehicle at the destination doesn't matter. All I could do now is to compute the path using A or a BFS fill through the center of the tiles. This is an example of a desired path
28
Algorithm to find average position In the given diagram, I have the extreme left and right points, that is 2 and 4 in this case. So, obviously, I can calculate the width which is 6 in this case. What we know The number of partitions 3 in this case The partition number at at any point i.e which one is 1st,second or third partition (numbered starting from left) What I want The position of the purple line drawn which is positio of average of a particular partition So, basically I just want a generalized formula to calculate position of the average at any point.
28
How to create a grid based on random shapes? How to create a "grid" using actionscript like the image below? Basically you have an area of 1100x615 which should be filled with shapes that could be rotated and scaled... Collision detection perhaps or something less cpu intensive for flash (as3) to manage?
28
Efficient algorithm for simultaneously updating game objects which need to be updated I have a grid of objects like this 1 F 1 is equal to the constant 1, F flickers between 0 and 1 each tick, and is equal to the sum of the 1 and the F. I want to update these values as described above. The 1 won't change, the F will change from 0 to 1 and vice versa, and the will change to the sum. I could just do a loop for node in nodes if(node.type ' ') node.value node.input1.value node.input2.value if(node.type '1') ... if(node.type 'F') ... but the problem is that this will depend on the order of iteration. If the F is iterated on first, then it will be set to 1 from an initial value of 0, then the would equal 1 1, i.e. 2. But if the was first, the result would be 1 0 0 and the NEXT tick would be 1 1 2. I want to do this simultaneously. So I thought I could have a map of new values global map new HashMap lt Node, double gt () ... map.clear() for node in nodes if(node.type '1') if(node.type 'F') map.set(node, node.value 1 ? 0 1) if(node.type ' ') map.set(node, node.input1.value node.input2.value) map.forEach(k, v gt k.value v) but this is probably inefficient as all values have to be looped over and entries in the map must be created for each node (node count is expected to be alot, around 10,000). How do I do this? I probably need a list of "update required" nodes but I'm not sure what to do exactly, especially to do it simultaneously. Examples 1 (flickers between 6 and 7 starting at 6 due to F flickering) F 3 2 Nodes can be created by the player 1 gt lt 2 (equals 3) Player creates a node 1 gt lt 2 (factorial) gt (equals 6) There can be multiple of these connected nodes at a time 1 gt lt 2 (equals 3) 2 gt lt 3 (equals 5) If the player chooses, they can connect these 2 together 1 gt lt 2 2 gt lt 3 gt (equals 8) Nodes can be inputs to themselves, or have no inputs (in which case the inputs default to 0) gt (starts at 1 in the first tick, then keeps incrementing.) 1 gt lt
28
Testing for connected maze cells I'm currently in the middle of writing a game where there is a maze. The maze itself is already drawn ok, and once I have the layout I randomly rotate all the pieces. I have a 'start' cell that is a different colour to the others,when cells are rotated in such a way that they become 'linked' to this start cell, then all the cells that are linked back to this cell should change colour.The start cell itself can be rotated as well so just because a cell is back in it's initial rotation it doesn't mean it's connected. Also any random cell can be rotated regardless of whether it's neighbour is already connected. E.g if the start cell is at 8,8 in a grid, then all the other cells bar it's immediate neighbours could get connected and then finally the closest neighbours get rotated to form a completely connected grid in which case all cells should change colour like a flood fill. Are there any good algorithms to solve an issue like this? I was thinking of a flood fill from the start cell every time a cell is rotated somewhere but I'm not sure if this is the optimum way to do this, especially as I have to check what each type of cell is (e.g is it a corner piece, a straight piece, a T Junction or a dead end with only one connecting side) and then check what it's current rotation is compared to it's neighbours rotation and type. Obviously this is fine if you can stop at immediate neighbour to the start piece, but when other sections of the maze might be 'complete' and then an interjoining piece is linked I would need to flood fill all of them. I had started writing this but I found myself just pretty much duplicating switch statements for all the different types of piece and then what type of piece their neighbour was and comparing the rotations of each piece. It felt very 'DRY' even though the comparisons were changing I'm writing this in swift, but I guess an algorithm would be generic thanks
28
Why do KD trees put the median split exactly on a point? I've understood that KD tree split points using the median while cycling on each axis. I've also understood that at each node traversal, a nearest search must use a sphere to store to nearest neighbor (in case the query point is very close to the split median). What I don't understand, is why median are always aligned with one point? Does that mean nodes are always storing one point? Does that mean each node can only have one point and 2 childs nodes ?
28
Checking whether moving object has reached target position So I have a fast moving object in my game, let's say a bullet. At each iteration of the main loop I update the object's position based on the delta time value dt and draw it at the new position. I also check whether the object's new position is close to a target position. In that case the object will be removed S.... ... .... .... ...... ... .... .... ... ..T.. X The object starts from location S, moving towards target position T. Each dot . represents one ms time. The vertical bars represent a game loop iteration, in which I check whether the object has reached its target destination. At X the object will be removed. Since these checks (ie. game loop iterations) might take place before or after the 100 exact target position (even if only a few pixels off), I perform this check with a distance between a line segment from the last position to the current position, and whether the target position is on that line. This approach works well. There is one issue though Since the check in which I recognize that the target has been reached happens after the real position of the target, the object moves a little bit further than desired. That's becoming more severe when the object is moving very fast. Now my question Is there kind of a "best practice" how to deal with this issue? I assume this is a common problem in game development. PS The only solution I could think of is to re position the object to the real target position as soon as the check succeeds. However, that can look a bit like a "jump" back, which does not look great.
28
RTS Unit sight in fog of war I am making an RTS game, and like most RTSs, you can see what's going on in a part of a map only if you have a unit over there. I have few ideas how to accomplish this, but there are problems with them. Problems are Algorithm must be efficient. I need to notify players (over network), when an enemy comes into sight. How do I account for obstacles obstructing sight (such as cliffs). Na ve approach would be like this pseudocode func calculate visibility vector lt Bitfield gt visible for all units on map let unit enumerated unit for all human players let player enumerated player for all units of player let player unit enumerated unit if player unit sees unit visible unit.id player.id true process next player And then run this calculation each frame, compare results with previous frame and send out events, like enemy unit detected . I did some benchmarking, and using approach like this may take up to 2 3 of a frame, which is unacceptable. I figured out a better way to calculate which units are visible. This approach is to use a visibility map. Subdivide the map into N M cells. Each cell is marked by IDs of players that can see the cell. To determine which players can see an unit, I need only to check cells that contain given unit. However, I don't know how to fill the map in the first place. I could iterate through all units and use a circle drawing algorithm. But I'll have to redraw the visibility map every frame, so this doesn't look much more efficient than the first approach. Unless I update it at a lower rate, but then there's a problem with fast moving units. And how do I detect when unit comes in player's sight, except than iterating through every unit and comparing with previous frame? How is this done in modern RTS, such as StarCraft 2?
28
What rendering techniques would I use to draw a drop shadow effect for cards in a card game? What type of shading algorithm might be used to create shadows like these? the one I'm making is similar but it is all done with a 2D drawing API powered by OpenGL so there is no Z coordinate. In addition, for the hand itself, I'd really like to get a shaded feel like seen here I'm just not sure how to achieve a shaded look close to that. The number of cards is bound to change and the cards get thrown onto the table so I can't use any type of light map of sorts. What sorts of algorithms should I look into (aside from blur which I know 'll need to do?) Thanks Update I'm making a 2D card game. I want to add dropshadows offset from the cards, a bit like The way I'm thinking of doing it is Keep a texture that is the same size as the backbuffer. Draw dark rectangles as makeshift cards to that texture. Blur that texture. Draw my cards to that texture. Do additional lighting on the cards. Draw this texture to the backbuffer. My questions are Is this the right way to do this? Is there a way to do it without render to texture (keeping a bitmap as big as the backbuffer)? Is it safe to assume that the maximum texture size will not be exceeded by the backbuffer size? (What I mean is, if the backbuffer is 2000x3000, then is it safe to say that I can create a texture in video memory of that size? Thanks
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
Randomly generating the hallways between a network of rooms So here's my base map (It won't necessarily be 5x5, just using this as an example.) It's kinda boring the way it is with all the rooms connected. I want it to be more of a randomly generated labyrinth, where every room is accessible like so I've tried setting the hallways randomly foreach(Room r) r.northWall randomBoolean() r.southWall randomBoolean() r.eastWall randomBoolean() r.westWall randomBoolean() But that almost always ends up with rooms that you're unable to go to, like this And often some rooms have no hallways at all. I tried saying each room must have a minimum of 2 hallways, but it still doesn't fix the problem that sometimes there an inaccessible areas. How should I go about doing this? I'm not too worried about the speed, as long as it's not ridiculously slow (Some levels will have 100 rooms).
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
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
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 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 of doing like this The 100 targets are considered as a single block The arrows are distributed inside The units hit the same number of times are grouped together. I manage the life of each new group Repeat on each new group if necessary I can distribute the arrows (step 2) and get the result (step 3) through a loop, but with many armies composed of millions archers, computing time amp memory consumption becomes a problem. Step 2 const targets new Array( 1000000000 ) targets.fill( 0, 0, 1000000000 ) const arrows 1000000000 for( let i 0 i lt arrows i ) const index Math.floor( ( Math.random() arrows ) ) targets index 1 Step 3 const result targets.forEach( value gt if( value ) if( result value ) result value 1 else result value 1 ) Is there another way to solve this problem ? I believe that with large numbers, directly calculating the most likely scenario may be a good option. Unfortunately, I do not know anything about probabilities.
28
How to correctly solve a procedurally generated puzzle? I'm creating a puzzle game where the player must remove all colored blocks from a grid. When the player selects a block, all adjacent blocks of the same color are removed. Any blocks that have empty cells below them will then fall into those cells. Here's a simple illustration of the mechanic https imgur.com TBNrAUW The game will procedurally generate puzzles with varying degrees of difficulty. When the player completes a puzzle the game will then score the player based on how quickly and, more importantly, how efficiently they solved the puzzle. The problem I am having is implementing a method of determining the most efficient way of solving a puzzle (i.e. identifying the fewest number of moves possible). Here's an example of a puzzle that was generated https imgur.com RQcAgkH As a human, I could identify that the fewest number of moves that could be made to solve this puzzle was 11. Here is a gif of the solve https imgflip.com gif 463qck However, when I whipped up an application that just clicked blocks at random in order to solve this puzzle, the lowest number of moves that it was able to solve this in was 14. And this was over billions of iterations which took many minutes. Obviously that is not acceptable. I need to find the correct solution and it should be done within seconds. I also tried to reverse engineer the generation process but that doesn't work. For example, it could place a blue block in column 1, a bunch of other blocks, a red block in column 1, a bunch of other blocks, then another blue block in column 1. Column 1 could be resolved in 2 moves (by clicking the red block and then one of the blue blocks), which reverse engineering the generation would not detect. So, my question What kind of techniques or tricks can I implement that will allow the application to resolve this type of generated puzzle quickly and correctly? I'm sadly out of ideas.
28
How can I divide a 3D mesh into small pieces? I'm considering a manufacturing game. A player should assemble parts of an object in given time. The object will be a 3D mesh model. I want to automatically split the 3D mesh into many small pieces to be provided to players. Each divided piece is needed to have area as similar as possible. And I want to control the number of pieces too within range about 2 6. How can I do this? I know the method to modify a given mesh like adjusting values of vertices, indices. All I need is the algorithm.
28
How can I create a random "world" in a tile engine? I am designing a game that is working on a classic tile engine, but whose world is generated randomly. Are there existing games or algorithms that do this? The procedural generation algorithms I have found are never using a tile system... What would be the best way to generate a whole "world" using a tile system? I am not talking about mazes of blocks, but an overall "world map" thanks
28
AI for solving a Match 3 game Is there a known good way to have a "computer" opponent play a Match 3 game? It doesn't have to be fancy, or even considered fair. If the AI always takes the best move on the board that would be OK with me. Note that a valid move is one that doesn't make a match. Edit What I am currently doing is a brute force approach. I look at every tile on the board, and see what the best move that tile can do. I add it to a collection and give it a score (based on how many it will match 3 or 4). Once I have traversed the entire board I use the move with the best score. In the event of a tie I pick one. If a 5 match combo is found I short circuit out to that one. 5 is the highest combo you can get) I may not be able to improve it, but it feels like this should have been solved already.
28
How to devise an algorithm for a person being on a walk? The game is an isometric RPG. The map is tile based. I'm creating a town for this game. And I want one of the characters to roam the town randomly, because she is on a walk with her children. I tagged the tiles she can go on. And I created a simplistic algorithm that I, in my naiveness, thought would be enough. Here it is If the character is blocked out and can't move in any direction she waits 1s before checking this again. If she can move in only one of the 4 directions, she moves that direction. If there is more than one possibility If she can go forward, she always has 50 chance of going forward if she can go both to her left and to her right there is an equal chance she chooses either of those two directions and finally, if she can turn back, that chance is 2x smaller than turning to her left and 2x smaller than turning to her right. So, if she can choose from all 4 directions, she will have 50 chance to go forward, 20 chance to go to her left, 20 chance to go to her right, and 10 chance to go back. Repeat the above every step. This algorithm fails beautifully. The character mostly moves randomly in one place. If she gets on a square she almost can't leave it. I thought the solution would be to increase the chance of her moving forward. So I made the chance to go forward 5 times bigger than doing anything else. But this proved to hardly improve things. COuld you give me some hints, point me to the correct direction? Or at least tell me that this is not worth it and I should instead resort to giving her a predefined path? (Are there no algorithms to make a character roam a given set of walkable tiles?)
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
which is the best approach or algorithm to calculate real time ranking I want to know the fastest and most efficient way to compute points and ranking in real time. I'm doing a betting football game (a game where users try to predict the outcome of a game before it). In my country is called "Quiniela". Players put "predictions" just before the match starts. My question is from the moment the game starts, which is the most efficient way (not just code level but to the database and server) to calculate the ranking for the players "real time" as their predictions regarding the actual outcome of the game. For example If a Team1 vs Team2 plays, the user U1 predicted that the game would end 0 0, U2 predicted the game would end 1 0, U3 predicted the game would would end 1 1. When starting the game, the U1 would be to first in the ranking because, if the match ends like this, his prediction would be correct, or at least the most accurate. Then the score switches to 1 0, and the user U1 would be the last of the ranking (because his prediction is not possible anymore), U2 would be the first and U3 second. If the score changes to 1 1, U2 would go first, U3 would be second (because he guessed part of the result) and U3 last. I thought about creating a tree of possibilities with one level (0 0 first node, with 1 0 and 0 1 as child nodes) as you change the score, changes the Ranking "temporarily" and I would keep it in cache. Once the game is over, I keep the latest Ranking in the database. There is a more optimal way to solve this problem? It has been proposed before and already solved? I'm using MySQL for database, PHP (Cake Php) for the server and a bunch of mobiles who ask for the ranking once in a while.
28
Algo for given an amount of XP, find a character's level In a RPG context, what are the ways to quickly find a character's level, given his XP? There are two cases which I am looking at For when a formula is defined, like in the case of D amp D, which is N N (N 1) 500, where N is the desired level. When no formula is defined, each level has an amount of XP require which is defined by a table. I guess the easiest way is to do a for loop and subtracting the XP required for that level from the character's XP pool, till he reaches a point where you can't attain the next level. What other ways are there to, given a character's XP, to find his level? Edit The language is PHP
28
Help me please to choose proper path finding algorithm I am new to game development and just want to ask for advice. I need to know which path finding algoritm will be suitable for my scenario Units any shape. But in most cases rectangles of different sizes. I have random generated maze and destination point or area. Because of different maze borders not all unit can fit and move to the end. How to find path from unit to destination area and check that shape can move to this area?
28
Match three puzzle games algorithm I am trying to write a match three puzzle game like 'call of Atlantis' myself. The most important algorithm is to find out all possible match three possibilities. Is there any open source projects that can be referenced? Or any keywords to the algorithm? I am trying to look for a faster algorithm to calculate all possibilities. Rules Diagonals don't count. The size is 8x8 Thanks.
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
Generate 2D Triangular Mesh from Vertices on a Map Given a map of vertices (x1,y1), (x2,y2), ... (xn,yn) , how can I generate a 2D triangular mesh covering all vertices, and where the area of all triangles completely covers the map? The triangular areas may fully enclose other triangular areas, but no two triangles may intersect.
28
A Partial recalculation when one node changes I have implemented an A library. Its most interesting feature is that it is "interruptible" for example, you can stop the calculation loop on a game frame, and resume it later on the following frame. The library works by creating "Nodes". Each node holds information about a cell in a grid what is the cost to get there, what is the cell's "parent" (from which it is cheaper to get to the cell) etc. This information is stored until manually released it is available for other uses if needed. The "bestNode" is a pointer to one of such nodes. When the search starts, it is the "origin", and it gradually changes until the destination is reached. Now I'd like to use that information to "partially recalculate" the node information when a node changes the typical example is a door which opens closes, allowing new paths cancelling existing paths. Since I have already calculated the path from the origin to the "changed" node, I'd like to conserve that info, instead of re calculating everything. So far my thinking is function update(location) If the modified location is not in a node, return not affected let node self.nodes location let parent node.parent delete all nodes that where created after parent add parent to the open list bestNode parent end So I have two problems I don't know how to select the "nodes created after parent". Would a "unique increasing integer", like in a database, be enough? This looks kind of complicated and clumsy. Is there a simpler way to do it? Are there any other "partially re calculable" A algorithms out there? I could not find anything on the subject. Regards!
28
Object detection in bitmap JavaScript canvas I want to detect clicks on canvas elements which are drawn using paths. So far I have stored element paths in a JavaScript data structure and then check the coordinates of hits which match the element's coordinates. Rendering each element path and checking the hits would be inefficient when there are a lot of elements. I believe there must be an algorithm for this kind of coordinate search, can anyone help me with this?
28
Finding shapes in 2D Array, then optimising I've just been allowed an image...The image below from my game shows some darkened blocks, which have been recognised as being part of a "T" shape. As can be seen, the code has darkened the blocks with the red spots, and not seen the "T" shapes with the green outlines. My code loops through x y, marks blocks as used, rotates the shape, repeats, changes colour, repeats. I have started trying to fix this checking with great trepidation. The current idea is to loop through the grid and make note of all pattern occurrences (NOT marking blocks as used), and putting these to an array loop through the grid again, this time noting which blocks are occupied by which patterns, and therefore which are occupied by multiple patterns. looping through the grid again, this time noting which patterns obstruct which patterns That much feels right... What do I do now? I think I would have to try various combinations of conflicting shapes, starting with those that obstruct the most other patterns first.How do I approach this one? use the rational that says I have 3 conflicting shapes occupying 8 blocks, and the shapes are 4 blocks each, therefore I can only have a maximum of two shapes. (I also intend to incorporate other shapes, and there will probably be score weighting which will need to be considered when going through the conflicting shapes, but that can be another day) I don't think it's a bin packing problem, but I'm not sure what to look for. Hope that makes sense, thanks for your help EDIT Despite clarity of question, everyone seems to have understood, yes, I want to find the maximum "T" shapes within each colour (because if I gave you points for two and you had made three, you'd be a bit annoyed)
28
Randomly generating the hallways between a network of rooms So here's my base map (It won't necessarily be 5x5, just using this as an example.) It's kinda boring the way it is with all the rooms connected. I want it to be more of a randomly generated labyrinth, where every room is accessible like so I've tried setting the hallways randomly foreach(Room r) r.northWall randomBoolean() r.southWall randomBoolean() r.eastWall randomBoolean() r.westWall randomBoolean() But that almost always ends up with rooms that you're unable to go to, like this And often some rooms have no hallways at all. I tried saying each room must have a minimum of 2 hallways, but it still doesn't fix the problem that sometimes there an inaccessible areas. How should I go about doing this? I'm not too worried about the speed, as long as it's not ridiculously slow (Some levels will have 100 rooms).
28
Tron type game AI algorithm Im looking for a tron AI algorithm on snap! scratch. If not can you help me develop an AI for this game?
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
Retro game development how did 8 bit computers store large level maps and build a screen from them? Not sure whether this would be better in the retro computing exchange, but I'm trying in game development first. During the 80s I played a lot of what would now be called "arcade adventures" on the BBC Micro games like Citadel, Camelot, Jet Set Willy, etc. Jet Set Willy could support 64 rooms, Citadel had over 100. Presumably, some form of encoding was used to compress the maps to fit in the limited storage space that these machines had, but does anyone have any information on how these games actually managed to cram screen layout and object types and locations into this limited space, then decode these into a tilemap and game objects?
28
Diamond square terrain generation problem I've implemented a diamond square algorithm according to this article http www.lighthouse3d.com opengl terrain index.php?mpd2 The problem is that I get these steep cliffs all over the map. It happens on the edges, when the terrain is recursively subdivided Here is the source void DiamondSquare(unsigned x1,unsigned y1,unsigned x2,unsigned y2,float range) int c1 (int)x2 (int)x1 int c2 (int)y2 (int)y1 unsigned hx (x2 x1) 2 unsigned hy (y2 y1) 2 if((c1 lt 1) (c2 lt 1)) return Diamond stage float a m heightmap x1 y1 float b m heightmap x2 y1 float c m heightmap x1 y2 float d m heightmap x2 y2 float e (a b c d) 4 GetRnd() range m heightmap x1 hx y1 hy e Square stage float f (a c e e) 4 GetRnd() range m heightmap x1 y1 hy f float g (a b e e) 4 GetRnd() range m heightmap x1 hx y1 g float h (b d e e) 4 GetRnd() range m heightmap x2 y1 hy h float i (c d e e) 4 GetRnd() range m heightmap x1 hx y2 i DiamondSquare(x1, y1, x1 hx, y1 hy, range 2.0) Upper left DiamondSquare(x1 hx, y1, x2, y1 hy, range 2.0) Upper right DiamondSquare(x1, y1 hy, x1 hx, y2, range 2.0) Lower left DiamondSquare(x1 hx, y1 hy, x2, y2, range 2.0) Lower right Parameters (x1,y1),(x2,y2) coordinates that define a region on a heightmap (default (0,0)(128,128)). range basically max. height. (default 32) Help would be greatly appreciated.
28
How to determine what hexes are in an area bounded by 3 hexes I've been searching for hex grid algorithms for a while now, but I'm not having much luck. I'm working on a game that will be using hex grids for the board. There seems to be sufficient resources to manage the A path finding routines, but trying to find something as simple as determining a set of hexes within a triangle seems to be a real challenge. An example of what I'm looking for is that I want to have a starting coordinate. I want to get a hex that is 3 hexes to the north east away from the source hex. I want to get a hex that is 3 hexes to the south east away from the source hex. I then want to produce a list of all hexes bounded by these 3 hexes. It should be simple enough, but the fact that rows are staggered is completely confounding me. Thanks
28
Methods for generating a map I'm looking to create a simple, "randomly" generated map for a small game. The game consists of a top down view of a world, with land mass and ocean areas. Think of a simple outline map of the world for example. The closest thing I can think of that I've seen before was the level generator for the old SimCity games, or the Civ series, where you can set a preference for single continent versus many islands, etc. What sort of algorithm would be suitable? The map will need to be moderately zoomable, so I can have a "whole world" view, and also a more zoomed in local view, but I think I'll sort that out later. Initially I don't need any concept of heights, just two areas land and sea, although I might extend it later.
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
Smart terrain generation to avoid unconnected tiles To make this clear from the get go I'm not looking for HOW To randomly generate a terrain (I know I can use Perlins noise for that). I'm looking for an algorithm that can help with the terrain generation. Example Me and my friend are working on a flash game to be use as advertisement for an upcoming game (And to see if theres actually interest for the base game). And I've been working on randomly making terrains, however! When i generate the map, i have no idea how to make it so it connects properly. The map is isometric and tilebased and after its been generated we're going to litter chest traps and other gameplay elements on the map. However, theres no reason to put an item on a piece of that map thats not connected to the rest of the map.. Or worse yet, spawn a player on a tile thats unconnected to anything. Does anyone know of a algorithm that helps with stuff like this? Thanks in advance people. Etarnalazure EDIT What I'm looking for is an algorithm that makes sure theres no unconnected tiles, thus no items or players may by accident get seperated from the rest of the walk able tiles. Hopefully this clears up what i mean.
28
How does Navigation Mesh path finding work? I want to understand how navmeshes work, how to implement them and why it is better than other types of pathing systems.
28
Documentation on 2D space partitioning I am looking for documentation that explains the different kinds of (well the major ones anyway) 2D space partitioning algorithms amp data structures. Any pointers besides 'Google it and sift through hundreds of papers'. A book perhaps?
28
Algorithm to make groups of units In Age of Mythology and some other strategy games, when you select multiple units and order them to move to some place, they make a "group" when they reach the desired location I have a Vector with several sprites, which are the selected units, the variables tarX and tarY are the target x and y. I just want an example, so you can just set the x and y position and I can adapt it to my code. Also, I would like to ask that the algorithm calls "isWalkable" for the x and y position, to determine if it's a valid position for each unit.
28
How can I make a computer opponent for my board game? I am trying to create a game, not exactly checkers, but the level of its interactivity is on par with checkers as opposed to something more complex (I think) like chess. Anyway, according to my analysis, the UI, gameplay, player turns, time constraints, rewards are very easy to implement. What I find hard is the actual CPU logic. I'm looking at checkers as an example because I used to play checkers on my PC and Nokia long before sophisticated modern AI became a thing. Are there techniques used in old checkers games that I could use to calculate which of its moves is the most advantageous for it to win the game? I would implement a logic on my own but I need a special algorithm to compute every possible move, and this will def take me a decade to implement. I am sure there is a smarter and quicker way but I have no idea.
28
How can I create a six sided tillable perlin noise image? I'm attempting to create a tillable hex shaped terrain map using c . As part of the process I'd like to use perlin noise, but it seems that in order to make it tillable I'll need to generate it 5 dimentionally and take a "circle" from it (if you know another way please let me know, I'm basing my theory on this post https ronvalstar.nl creating tileable noise maps by Ron Valstar) creating three cylinders that together make up the image I've coded my own 2d perlin noise function but getting to 5d seems like a whole different beast Unless anyone knows of one that already exists, I think I'll have to write my own library for generating the noise. I'm working on c , and while I've seen a few perlin noise libraries I haven't seen any with 5d. I can generate a 5d vector feild no problem but it's the actual linear algebra where I'm confused. It'd involve me doing some quin linear interpolation and I have no clue how to even start on that. If anyone knows how to do this already or has any resources that could help I'd appreciate it. in summary 1) anyone know how to generate 5d perlin? 2) anyone know of a different method to tile a six sided image generated from perlin noise?
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
A and Space partitioning I'm planning on implementing A in my game for pathfinding, I understand the basics of how the algorithm works but I was wondering, other than finding the start and end nodes Are there any benefits to placing the navigation graph into a tree? It seems to me that it wouldn't really benefit any as each node has a list of connections to other nodes. But I recall reading an article about pathfinding a while back and it suggested using a space partition tree, I believe it suggested an AABB tree to be exact. If A wouldn't benefit would any of the algorithms benefit from such a thing? And no, sadly I can't find the article again.
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
How to find grid cells not seen by an object I am writing a VB.NET program. I have a grid view which is made of multiple small cells called grid cell. On the grid view, I have placed an obstacle (red box) and an observer (blue box). My task is to find how to find grid cells which are not seen by the blue box. You may refer to the screenshot below. Take note that the yellow box shape is not necessary a rectangle. 1) I have considered to loop through all grid cells in the grid view and check each of them if it is seen by the blue box. However, there could be millions of grid cells in the grid view and looping through each of them will consume a lot of time and is not efficient. Is there any better way to locate grid cells not seen by the blue box other than looping through all the grid cells in the view? Thank you.
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
Prevent collisions between mobs npcs units piloted by computer AI How to avoid mobile obstacles? Lets says we have character a starting at point A and character b starting at point B. character a is headed to point B and character b is headed to point A. There are several simple ways to find the path(I will be using Dijkstra). The question is, how do I take preventative action in the code to stop the two from colliding with one another? case2 Characters a and b start from the same point in different times. Character b starts later and is the faster of the two. How do I make character b walk around character a without going through it? case3 Lets say we have m such characters in each side and there is sufficient room to pass through without the characters overlapping with one another. How do I stop the two groups of characters from "walking on top of one another" and allow them pass around one another in a natural organic way. A correct answer would be any algorithm, that given the path to the destination and a list of mobile objects that block the path, finds an alternative path or stops without stopping all units when there is sufficient room to traverse.
28
Swept AABB vs Line Segment in 2D I've been trying to get a swept collision detection up and running now for almost a week and I can't for the life of me get it working. There is a answer on this linked here below Swept AABB vs Line Segment 2D I've translated this into Go which will be running the game server and needs this logic func SweepRectLine(rectX, rectY, rectW, rectH, rectHSpeed, rectVSpeed, lineX1, lineY1, lineX2, lineY2 float64) (bool, float64) outVel 2 float64 hitNormal 2 float64 lineNX, lineNY lineX2 lineX1, lineY2 lineY1 lineMinX, lineMaxX, lineMinY, lineMaxY math.Min(lineX1, lineX2), math.Max(lineX1, lineX2), math.Min(lineY1, lineY2), math.Max(lineY1, lineY2) var lineMinX, lineMaxX, lineMinY, lineMaxY float64 if lineNX gt 0 lineMinX, lineMaxX lineX1, lineX2 else lineMinX, lineMaxX lineX2, lineX1 if lineNY gt 0 lineMinY, lineMaxY lineY1, lineY2 else lineMinY, lineMaxY lineY2, lineY1 r (rectW 2) math.Abs(lineNX) (rectH 2) math.Abs(lineNY) radius to Line boxProj (lineX1 rectX) lineNX (lineY1 rectY) lineNY velProj rectHSpeed lineNX rectVSpeed lineNY if velProj lt 0 r 1 hitTime math.Max((boxProj r) velProj, 0) outTime math.Min((boxProj r) velProj, 1) log.Println( quot start quot , hitTime, outTime) rectXMax, rectXMin rectX rectW 2, rectX rectW 2 if rectHSpeed lt 0 left if rectXMax lt lineMinX return false, 0 hitTime math.Max((lineMaxX rectXMin) rectHSpeed, hitTime) outTime math.Min((lineMinX rectXMax) rectHSpeed, outTime) else if rectHSpeed gt 0 right if rectXMin gt lineMaxX return false, 0 hitTime math.Max((lineMinX rectXMax) rectHSpeed, hitTime) outTime math.Min((lineMaxX rectXMin) rectHSpeed, outTime) log.Println( quot right quot , hitTime, outTime) else if lineMinX gt rectXMax lineMaxX lt rectXMin return false, 0 if hitTime gt outTime return false, 0 rectYMax, rectYMin rectY rectH 2, rectY rectH 2 if rectVSpeed lt 0 up if rectYMax lt lineMinY return false, 0 hitTime math.Max((lineMaxY rectYMin) rectVSpeed, hitTime) outTime math.Min((lineMinY rectYMax) rectVSpeed, outTime) else if rectVSpeed gt 0 down if rectYMin gt lineMaxY return false, 0 hitTime math.Max((lineMinY rectYMax) rectVSpeed, hitTime) outTime math.Min((lineMaxY rectYMin) rectVSpeed, outTime) else if lineMinY gt rectYMax lineMaxY lt rectYMin return false, 0 if hitTime gt outTime return false, 0 outVel 0 rectHSpeed hitTime outVel 1 rectVSpeed hitTime return true, hitTime I also put up a Gist with a executable UI here https gist.github.com KidLinus 3f847c46b0e6dc1addac7252d9cb54ab I can't for the life of me figure out what all class variables stand for. I think that some of them are native to Unity but that's just a guess. I've come so far as to figure out that the extent is half of the width height in said direction. What the quot line.n quot stands for is anyones guess, I assume its the direction and have no idea if it's normalized or not. There are also a couple of dead variables just laying there.
28
Reducing adjacency bookkeeping work in constrained Delaunay triangulation I'm using the Sloan algorithm for constraining a generated Delaunay triangulation. This primarily consists of edge flipping for the edges that overlap the constrained edges. In order to flip an edge, I have to know what two triangles contain that edge, and so for every edge I currently maintain an index (into the triangle array) of the current and opposite triangles for that edge. This gets built from the triangle array, where each triangle maintains indices for all adjacent triangles. While this works, I've found that the vast bulk of my code is dealing with the maintenance of these triangle adjacencies. Every time an edge gets flipped, I not only have to update the two triangles that share the edge, but also update all of the other neighboring triangles that may have adjacency to one of those triangles, as well as go through and update any adjacency indexes within my list of edges to be flipped. And then again, after the edges are flipped and you get a list of final quot good quot edges to use, you have to go through them and make sure they still satisfy Delaunay circumcenter rules, and if not, flip them again. Which means repeating all of the same work to maintain adjacency indexes. Is there an algorithm for efficiently maintaining triangle edge adjacency without all of this work? Or, better, is there an efficient method of determining neighboring triangles that share a common edge without the need to maintain these links? I feel like I'm doing more adjacency maintenance than actual triangulation...
28
GPU Spatial Clustering I have a around 100k points on the screen (that might update). 2D points. The goal is to cluster them into groups, by a constant distance. Meaning, finding groups of points that the distance between them is less than this distance. Instead of drawing those points, a big point will be drawn there with a number on it. The problem is the calculation time. Tried many algorithms on CPU, but didn't get the performances i wished for. I'm trying to find an algorithm to solve this problem in the GPU using WebGL GLSL, when texture contains all my locations. Can be single draw phase or multiple.. as long as i achieve better calculation time than i get with the CPU.
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 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
Partially observable game map is A appropriate? I know very little about game development and I'm trying to wrap my head around pathfinding algorithms. Consider this setup an agent is on a 2D map and must find the shortest path to a globally know object but only has information about obstacles in his local vision scope (ie. only immediate obstacles are known, the general layout of the map is unknown). Also, every move to an adjacent square is expensive and the pathfinding algorithm should minimize the number of moves. Computational efficiency is also of utmost importance and more important than accuracy. Is A appropriate for this use case?
28
Cavity map generation I am looking for an algorithm how to generate cavity (or curvature) map. There seems to be no refernce to it, only final solutions like xNormal software, but that is not what I want. I am looking for a way how to do it, not for a final solution. I have also found this site http wiki.polycount.com wiki Curvature map, but again, mostly references how to do it in specified soft (maya etc). On my input, I have a mesh and a normal map. From this, I have calculated curvature on my mesh, and now I would like to extend this info with more details from normal map.
28
How to generate Bayer matrix of arbitrary size? In ordered dithering Bayer matrix is used. How is that matrix generated? What algorithm can be used to generate matrix of arbitrary size?
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
What rendering techniques would I use to draw a drop shadow effect for cards in a card game? What type of shading algorithm might be used to create shadows like these? the one I'm making is similar but it is all done with a 2D drawing API powered by OpenGL so there is no Z coordinate. In addition, for the hand itself, I'd really like to get a shaded feel like seen here I'm just not sure how to achieve a shaded look close to that. The number of cards is bound to change and the cards get thrown onto the table so I can't use any type of light map of sorts. What sorts of algorithms should I look into (aside from blur which I know 'll need to do?) Thanks Update I'm making a 2D card game. I want to add dropshadows offset from the cards, a bit like The way I'm thinking of doing it is Keep a texture that is the same size as the backbuffer. Draw dark rectangles as makeshift cards to that texture. Blur that texture. Draw my cards to that texture. Do additional lighting on the cards. Draw this texture to the backbuffer. My questions are Is this the right way to do this? Is there a way to do it without render to texture (keeping a bitmap as big as the backbuffer)? Is it safe to assume that the maximum texture size will not be exceeded by the backbuffer size? (What I mean is, if the backbuffer is 2000x3000, then is it safe to say that I can create a texture in video memory of that size? Thanks
28
How does Hierarchical Pathfinding deal with obstructions in the same chunk? Aigamedev.com provides this visualization of HPA All the nodes within the same chunk connect to each other. What if there was an obstruction between nodes in the same chunk? For example What would the resulting visualization look like with an obstruction in the center bottom left chunk? How would this be detected?
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
What is the best practice to handle event with order? When you play card games, you always face some abilities and effects will be triggered at the same time. To resolve this, players relies on the rules. For example, if a minion dies, it triggers effects on my side and opponent side. If the effects is handled on my side first if it is my turn. But how would you resolve it in computer games. Even you are using mediator for event handling, the event is usually handled by the order of subscription. Unless there are some indicators for the subscribers, you will not able to distinguish between the subscribers. But wouldn't it defeats the purpose of observer pattern? What is the best way implement it?
28
Placing an AABB close to a point so that it doesn't intersect any other AABBs Give a 2D space with a bunch of non intersecting AABBs, and a point in this space (that may or may not be inside an AABB), how can I find the closest place where I can place a new AABB of a given size? For example, given the space below and the point 'X', the correct position for a certain AABB is marked in green One solution I have considered is to iterate every edge, and find the closest point on that edge where the shape doesn't intersect (if such a point exists). This could be achieved by placing the AABB at the closest point on the given edge, and then if it's intersecting with another shape, move it to the outside edge of that shape, along the given edge, repeating until it's no longer intersecting. This seems relatively expensive (though could probably be optimized by using some kind of spatial hashing), but might be the way to go. I'm wondering if there are any obvious or not so obvious solutions I'm missing here.
28
Why is my bullet disappearing after I release the shoot button? I'm making a game using DirectXTK for my university project. When I press space bullet moves forward like I wanted, but when I let go it stops my bullet from moving. How do I keep the bullet moving when space was pressed? void update shooting if (kb.Space) Shoot(true) else Shoot(false) void Render() if (draw) for (int i 0 i lt 10 i ) m projectile i gt Draw(m bullet i , m view, m proj, Colors Red) bool shoot(bool test) shoot test draw true bool isShot false if (!shoot) for (int i 0 i lt 10 i ) m bullet i Matrix CreateRotationY(m ship. 42) m ship else m bullet 0 Matrix CreateTranslation( Vector3 Forward float(1)) Matrix CreateRotationY(0.f) m bullet 0 m bullet Matrix CreateTranslation( Vector3 Forward) return draw
28
How Can I Improve This Card Game AI? Let me get this out there before anything else this is a learning exercise for me. I am not a game developer by trade or hobby (at least, not seriously) and am purely delving into some AI and 3D related topics to broaden my horizons a bit. As part of the learning experience, I thought I'd have a go at developing a basic card game AI. I selected Pit as the card game I was going to attempt to emulate (specifically, the 'bull and bear' variation of the game as mentioned in the link above). Unfortunately, the rule set that I'm used to playing with (an older version of the game) isn't described. The basics of it are The number of commodities played with is equal to the number of players. The bull and bear cards are included. All but two players receive 8 cards, two receive 9 cards. A player can win the round with 7 bull, 8, or 8 bull (receiving double points). The bear is a penalty card. You can trade up to a maximum of 4 cards at a time. They must all be of the same type, but can optionally include the bull or bear (so, you could trade A, A, A, Bull but not A, B, A, Bull). For those who have played the card game, it will probably have been as obvious to you as it was to me that given the nature of the game, gameplay would seem to resemble a greedy algorithm. With this in mind, I thought it might simplify my AI experience somewhat. So, here's what I've come up with for a basic AI player to play Pit... and I'd really just like any form of suggestion (from improvements to reading materials) relating to it. Here it is in something vaguely pseudo code ish ) While AI does not hold 7 similar bull, 8 similar, or 8 similar bull, do 1. Establish 'target' hand, by seeing which card AI holds the most of. 2. Prepare to trade next most numerous card type in a trade (max. held, or 4, whichever is fewer) 3. If holding the bear, add to (if trading lt 3 cards) or replace in (if trading 4 cards) hand. 4. Offer cards for trade. 5. If cards are accepted for trade within X turns, continue (clearing 'failed card types'). Otherwise a. If only one card remains in the trade, go to 6. Otherwise i. Remove one non penalty card from the trade. ii. Return to 5. 6. Add card type to temporary list of failed card types. 7. Repeat from 2 (excluding 'failed card types'). I'm aware this is likely to be a sub optimal way of solving the problem, but that's why I'm posting this question. Are there any AI or algorithm related concepts that I've missed and should be incorporating to make a better AI? Additionally, what are the flaws with my AI at present (I'm well aware it's probably far from complete)? Thanks in advance!
28
How can I write my scoring system and add a score multiplier? I am new to the scripting world and I am currently trying to add a score multiplier to the game code I am working on. Right now the score is set to increase as the player runs across the level however I want to set it up so that the players gains X amount of score for every Y amount of distance traveled. I also want to add a multiplier for when they come into contact with certain objects X amount of time. Any help would be greatly appreciated.
28
A Partial recalculation when one node changes I have implemented an A library. Its most interesting feature is that it is "interruptible" for example, you can stop the calculation loop on a game frame, and resume it later on the following frame. The library works by creating "Nodes". Each node holds information about a cell in a grid what is the cost to get there, what is the cell's "parent" (from which it is cheaper to get to the cell) etc. This information is stored until manually released it is available for other uses if needed. The "bestNode" is a pointer to one of such nodes. When the search starts, it is the "origin", and it gradually changes until the destination is reached. Now I'd like to use that information to "partially recalculate" the node information when a node changes the typical example is a door which opens closes, allowing new paths cancelling existing paths. Since I have already calculated the path from the origin to the "changed" node, I'd like to conserve that info, instead of re calculating everything. So far my thinking is function update(location) If the modified location is not in a node, return not affected let node self.nodes location let parent node.parent delete all nodes that where created after parent add parent to the open list bestNode parent end So I have two problems I don't know how to select the "nodes created after parent". Would a "unique increasing integer", like in a database, be enough? This looks kind of complicated and clumsy. Is there a simpler way to do it? Are there any other "partially re calculable" A algorithms out there? I could not find anything on the subject. Regards!
28
Tron type game AI algorithm Im looking for a tron AI algorithm on snap! scratch. If not can you help me develop an AI for this game?
28
Implementation of finding an index in a 1D array for a triangular grid Am using a while loop to find an index within a 1D array, is there an easier, less time consuming and or mathmatical way to find the index? Consider the next grid 4 o 3 o o 2 o o o 1 o o o o 0 o o o o o 0 1 2 3 4 To find an index in the triangular grid within a 1D array I have the next function int size 5 int getindex( int x, int y ) int columnCount size while( y gt 0 ) x columnCount return x The array (The numbers within the parenthesis are the coordinates and to simplify your view, in reality the (x,y) is in its whole the data) pointdata data 15 (0,0), (1,0), (2,0), (3,0), (4,0), (0,1), (1,1), (2,1), (3,1), (0,2), (1,2), (2,2), (0,3), (1,3), (0,4),
28
How to maximize enclosed area and minimize perimeter on a grid with obstacles? Developing an RTS game, I have a tile based terrain (grid) filled with obstacles. It looks like this (red shapes are obstacles) Now I need to plan an enclosed area on the terrain with some restrictions tile marked with a quot star quot must be included (it is a seed) area needs to be at least 20 tiles (for this example) farthest area tile from the seed needs to be no more than 7 steps away (for this example) area needs to traversable by moving in 4 directions area should be bound by existing obstacles and by new fences new fences building takes time and resources, it is beneficial to use existing obstacles as much as possible and have the smallest number of fences placed. there are cases where terrain could be free of any obstacles, or contrary to that be a maze like labyrinth) it is okay to fail (e.g. there's not enough walkable tiles around the seed), or the area fences ratio is too low. processing is done on CPU (if that matters) So, here are some quot manual quot attempts at outlining an area of required size using the least fences As you can see, there are 3 enclosed areas (green, blue, orange) with very similar perimeters, yet different areas. Best one in this case would be quot green quot one it has the least fences added (just 10) and has the sufficient area (21). What is the algorithm to allow to plan area of given size ( 20) while minimizing the amount of additional fences required? So far I have tried to take the larger area and try to clip it using BFS to get the area within possible reach (7 steps), clipped the last step (since it is touching the unexplored and has no neighbor info) and clipped the obvious protruding buds leaves plenty of tiles to work with. I'm out of good ideas on how to improve from that yellow tile is the seed red tiles are walkable (saturation shows distance from the seed) dark grey tiles are obstacles light grey tiles are obstacles that also need fences purple tiles got clipped by existing incomplete algo black tiles are unexplored yellow dashes are required fences As you can see, it looks quite sub optimal, but I'm at loss as to how to proceed.
28
Path Finding for an Arena based map in 3D using NavMesh I have a 3D arena map (consider a small island surrounded by water on all sides) for a multiplayer Tank fight game. The moveable areas are marked using a Navigation Mesh made by the Arena designer. My question is what would be the best way for navigation in such an environment ? Specially considering the case when there is a Bridge at the center of the arena and you could walk under it or even above it ? If suppose the enemy is standing at the top of the Bridge and my AI is at one of the edges of the map ? How can it know whether the enemy is above or below the bridge and how can it navigate till it ?
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
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
Voxel sparse octrees for indirect illumination I don't understand the use of voxel sparse octrees for indirect illumination calculations. First of all, what exactly is happing? We're rendering the scene as usual with diffuse lighting. In the meantime, we're maintaining the octree of our scene. But when do we use it and for what exactly?
28
Checkers AI Algorithm I am making an AI for my checkers game and I'm trying to make it as hard as possible. Here is the current criteria for a move on the hardest difficulty 1 Look For A Block This is when a piece is being threatened and another piece can be moved in behind it to protect it. Here is an example Black Moves W W W W W W W W W W W W B B B B B B B B B B B B White Blocks W W W W W W W W W W W W B B B B B B B B B B B B 2 Move pieces out of danger if any piece is being threatened, and a piece cannot block for that piece, then it will attempt to move out of the way. If the piece cannot move out of the way without still being in danger, the computer ignores the piece. 3 If the computer player owns any kings, it will attempt to 'hunt down' enemy pieces on the board, if no moves can be made that won't in danger the king or any other pieces, the computer ignores this rule. 4 Any piece that is owned by the computer that is in column 1 or 6 will attempt to go to a side. When a piece is in column 0 or 7, it is in a very strategic position because it cannot get captured while it is in either of these columns 5 It makes an educated random move, the move will not indanger the piece that is moving or any piece that is on the board. 6 If none of the above are possible it makes a random move. This question is not really specific to any language but if all examples could be in Java that would be great, considering this app is written in android. Does anyone see any room for improvement in this algorithm? Anything that would make it better at playing checkers?
28
Player ranking using Elo with more than two players I would like to use Elo to track player rankings between matches of a certain game, however the game can be played with up to four players in a match. I have seen games like Carcassonne use Elo with more than two players playing, but I am not familiar with Elo beyond a 1 1 matchup. From the wikipedia article the two player equations I would like to extend are Ea 1 (1 10(Rb Ra) 400) Eb 1 (1 10(Ra Rb) 400) Rxnew Rxold 32 (W Ex), where W 1 if X wins and W 0 if X loses. How would the computation for Ex and W change given more than two players?
28
Fastest way to group units that can see each other? In the 2D game I'm working with, the game engine is able to give me, for each unit, the list of other units that are in its view range. I would like to know if there is an established algorithm to sort the units in groups, where each group would be defined by all those units which are "connected" to each other (even through others). An example might help understand the question better (E enemy, O own unit). First the data that I would get from the game engine E1 can see E2, E3, O5 E2 can see E1 E3 can see E1 E4 can see O5 E5 can see O2 E6 can see E7, O9, O1 E7 can see E6 O1 can see E6 O2 can see O5, E5 O5 can see E1, E4, O2 O9 can see E6 Then I should compute the groups as follow G1 E1, E2, E3, E4, E5, O2, O5 G2 O1, O9, E6, E7 It can be safely assumed that there is a commutative property for the field of view if A sees B, then B sees A . Just to clarify I already wrote a na ve implementation that loops on each row of the game engine info, but from the look of it, it seems a problem general enough for it to have been studied in depth and have various established algorithms (maybe passing through some tree like structure?). My problem is that I couldn't find a way to describe my problem that returned useful google hits. Thank you in advance for your help!