Tag Info

New answers tagged

0

I found a solution, just if somebody encounters the same problem some way.. The iteration switches now betweeen 0 -> max and max -> 0 each frame. Now the fish is spreading as it should.


1

If you have multiple sprites at the same position, are they all supposed to prevent the player from falling? if so, you can either merge them, or disable collision for one. Else, if not all the sprites should collide, maybe you can add a flag to indicate if they are ground colliders. On a side note, you could use a complete AABB instead of using arbitrary ...


0

Ive returned to answer my own question now. I ended up using the resources found in this answer: Creating a frozen bubble clone I converted my 2D grid array into a hex array. I still used a 2D array to index into the hexes, but I made sure to make sure my hex grid function in a odd-r layout, and that I indexed my array properly based on that layout. All ...


0

here is the alpha-beta algorithm definition: Alpha–beta pruning is a search algorithm that seeks to decrease the number of nodes that are evaluated by the minimax algorithm in its search tree. It is an adversarial search algorithm used commonly for machine playing of two-player games (Tic-tac-toe, Chess, Go, etc.). It stops completely evaluating a move when ...


1

The easiest and quickest might be simply to find out how thick the line would have to be to cover all the points of the user drawn line. The thicker the line has to be, the worse the user did in drawing their line.


0

Somehow referring to MSalters Answer, here is some more specific information. Use the least squares method to fit a line for your points. You are basically looking for a function y=f(x) which fits best. Once you have it you can use the actual y values to sum the square of differences: s = sum over ( (y-f(x))^2 ) The smaller the sum, the straighter the ...


2

One method you could use is to subdivide the line into segments and do a vector dot product between each vector that represents the segment and a vector representing a straight line between the first and last point. This has the benefit of letting you find extremely "spiky" segments easily. Edit: Also, I would consider using the length of the segment in ...


2

A very easy and intuitive measure is the area between the best fitting straight line and the actual curve. Determining this is fairly straightforward: Use a least-squares fit on all points (this prevents the end-kink problem mentioned by Joel Bosveld). For all points on the curve, determine the distance to the line. This is also a standard problem. (linear ...


19

Existing answers do not take into account that the end points are arbitrary (rather than given). Thus, when measuring the straightness of the curve, it does not make sense to use the end points (for example, to calculate expected length, angle, position). A simple example would be a straight line with both ends kincked. If we measure using the distance from ...


3

A* operates fundamentally on a graph, not a grid. When you create a grid for A* to search, what you've actually done is created something called a "lattice graph." The connections between nodes in the lattice can be anything. They don't have to just be straight lines between neighboring grid cells. In your case, you can combine the best of both worlds just ...


27

This might not be the best way to implement this either, but I suggest a RMSD (root mean square deviation) could be better, than merely the distance method, in cases mentioned by Dancrumb (see first two lines below). RMSD = sqrt(mean(deviation^2)) Note: The sum of the absolute deviations (integral-like) might be better, as it does not average out ...


2

This is a grid based system, right? Find your own points for the line and calculate the slope of the line. Now, using that calculation, determine valid points that the line would pass through, given some margin of error off the exact value. Through a short amount of trial-and-error testing, determine what good and bad amount of matching points would exist ...


2

The idea is to keep all the points the user touched, then evaluate and sum the distance between each of those points to the line formed when the user releases the screen. Here is something to get you started in pseudo-code: bool mIsRecording = false; point[] mTouchedPoints = new point[]; function onTouch mIsRecording = true functon update if ...


49

A perfectly straight line would also be the shortest possible line with a total length of sqrt((x1-x2)² + (y1-y2)²). A more scribbly line will be a less ideal connection and thus be inevitably longer. When you take all individual points of the path the user drew and sum up the distances between them, you can compare the total length with the ideal length. ...


0

I would do something like removing the same random number from each array each time, so that after 10 times you are guaranteed a match; or implement a counter and every nth time remove a number.


2

I'd like to chime in and mention "format preserving encryption" as a method for shuffling cards in a game. Essentially what you'd have is an encryption algorithm that takes in a value 0 to 51, and a key (shuffle seed) and spits out a value 0 to 51. Since encryption is reversible by definition that means any 2 input numbers cannot encrypt to the same output ...


0

I think what I need is a vertex collapse algorithm that is typically used with reducing excess polycount. http://pomax.nihongoresources.com/downloads/PolygonReduction.pdf but create a different cost formula.


1

Create two dimensional array Randomly place mines and place mine location to list Foreach mines and add +1 to adjacent cells Mine creation int x = random.next(min, max); int y = random.next(min, max); mineList.add(new XYClass(x,y)) Number calculation Foreach(XYClass xy : mineList) addPlusOneToAdjacentCells(xy); This way, you don't even have to ...


2

I think the fastest method will be by not generating the numbers at board generation (I know it's almost cheating). It's most likely fastest to only generate the number when the player clicks on a square rather then during board generation. Secondly consider how you are going to generate mines, is each place on the board going to pass a check (loop over ...


0

Cant comment so Ill leave as answer instead. I like the implementation of A* from this page: http://www.redblobgames.com/pathfinding/a-star/introduction.html. It goes step by step on how to build a path finding algorithm from the simplest and gradually increases complexity. I scanned over your implementation and it is not clear to me where the bug is. But ...



Top 50 recent answers are included