Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 5708

Algorithms are used for calculation, data processing, and automated reasoning. More precisely, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function.

2 votes

How do I produce "enjoyably" random, as opposed to pseudo-random?

A variant on lorancou's approach: for each puzzle type, keep an array of (shuffled) puzzle numbers; then every time you hit a puzzle of that type, get the next number off the list. for instance, let's …
Steven Stadnicki's user avatar
1 vote

3-in-a-row or more logic

While I basically agree with Nathan's answer, I wanted to emphasize that (a) another reason to find all the matches at once is for presentation purposes: it just looks better to blow them all up toget …
Steven Stadnicki's user avatar
2 votes
Accepted

How do I make something I flash/blink more frequently as it gets closer to disappearing?

My concern with either of the approaches currently offered is that they'll both lead to 'variable-speed' blinking, which could not only be distracting for the players but also make it hard to gauge ex …
Steven Stadnicki's user avatar
17 votes
Accepted

Checkers AI Algorithm

Instead, what you want to do is to write an algorithm that searches all possible moves-and-replies for some number of moves ahead (5 to 10 would be typical), evaluates the position at the end of each branch … is often called the Minimax algorithm. …
Steven Stadnicki's user avatar
8 votes
Accepted

How do I find the intersection of a ray and a cylinder?

This breaks into two distinct pieces: testing collisions against the endcaps, and testing collisions against the body of the cylinder. The simplest way to handle both is to first transform your way i …
Steven Stadnicki's user avatar
1 vote
Accepted

How do I implement a field of vision for AI entities?

A few things that come to mind: For the first test you shouldn't really (directly) need any quaternions; you have your AI's heading as a vector (and if you don't, you can quickly derive it from thei …
Steven Stadnicki's user avatar
12 votes

Is it better to hard code data or find an algorithm?

I guess I'll take the counterpoint here and argue against using static values. In this case, all of the hex regions you're talking about are (a) easy to compute - you don't need to use BFS or anythin …
Steven Stadnicki's user avatar
7 votes
Accepted

How to utilize miniMax algorithm in Checkers game

explicit recursion for the minimax, and instead maintain a stack yourself, and there are plenty of other object-management optimizations that you would want to make for a practical implementation of the algorithm … Still, this code should show the core of the algorithm: to evaluate a position, evaluate all of the subpositions from the current side's point of view, pick the 'best', and return that value. …
Steven Stadnicki's user avatar
2 votes
Accepted

Data structure for bubble shooter game

Finding connectivity in a general graph is usually done with floodfill-style algorithms (i.e., breadth- or depth- first search and variants thereof) anyway, so I don't think that abstracting out the p …
Steven Stadnicki's user avatar
2 votes

100 points between 0-1000 on an increasing scale

If you're intending to use only integers then I would give serious consideration to expanding the range from 1000 to something higher; an average of ten units between levels means that you'll either b …
Steven Stadnicki's user avatar
12 votes

What is the simplest method to generate smooth terrain for a 2d game?

Assuming that you want an actually smooth terrain, I'd suggest stepping back from the noise-based answers and understanding where they come from. A 'noise' signal is essentially a sum of infinitely m …
Steven Stadnicki's user avatar
3 votes

Pygame: circular motion with Bresenham's algorithm

Bresenham's algorithm is specifically built to draw circles with fixed-point mathematics; that is, to rasterize circles. …
Steven Stadnicki's user avatar
1 vote

Need ideas for an algorithm to draw irregular blotchy shapes

Another straightforward approach is by using your own low-frequency noise to draw (or define) a figure in polar coordinates. Suppose you want a blob centered at the origin, of average radius 1; this …
0 votes

How to divide hex grid evenly among n players?

Another approach would be to start with a distribution that's 'fair' but regular, and then use an appraoch similar to Simulated Annealing to break up the regularity without losing the fairness: Star …
Steven Stadnicki's user avatar