So, I was looking at the Gameboy CPU manual and some common algorithms. This helped me clean up my code quite well and helped me create easier solutions to problems that have always haunted me! Anyways I'm pretty far into developing my game. I expect to have it finished by April. For those who have seen my previous posts, It's the one with the demon girl and getting lost. If you have seen my even older posts, it's the one with zombies. Zombies have been removed due to how complicated planning them out was. This game is being written on a portable machine similar to a Gameboy. Specs: Z80 CPU, 24K RAM, 96x64 res, 2MHz clock, 6V power supply. Anyways I would like to know what algorithms you use in your games?
I onlyuse algorithms, I don'twrite algorithms. It sounds like you are writing algorithms (re-inventing the wheel) instead of using existing algorithms.
I've had to write some flocking algorithms from scratch before and a box select with crawling ants. Both of them I looked up on Google / asked on forums about before writing so I wasn't starting cold. I didn't use an existing algorithm because there were none exactly fit for my purpose. These are the two I found most challenging so far.
I also have to make up little algorithms here and there - the last example I can think of is last week writing one to make playing cards with health fight and move from one pile to another, or draw or be discarded when appropriate - but these algorithms are kinda more simple and I tend to just write them straight off rather than looking them up.
Yipper, I understand about writing the small stuff. When I was first getting into code, Tic Tac Toe is where I had written one of my most complicated algorithms. It had only been used once. In this game, the algorithm is used ~20 times. It has to be rewritten due to low memory (It's hard to explain) and all maps are different. also, it's written in two different modes, 1D and 2D. This algorithm controlled the cursor in Tic Tac Toe now controls player movement and menus. It's basic and obvious but when I was looking up how to do what I wanted to do, it gave me stuff like
1 2 3 4 5 6 7 8 9
#include <Crazy64-BITLibraryIKnowIDon'tNeed.h>
string main() //does this even work???
{
int a;
a = keyboard;
menu("Blah","Blah",1,"Blah",2
DrawCastle(5,6);
}
I'm not sure how you manage to make games without making any of your own algorithms? Some circumstances that comes up are just so specific that you have to make up your own algorithm, especially when it comes to AI playing a game you invented, but also in other situations. Also, even when you use an existing algorithm, you still have to modify the algorithm to fit your game.
You're making it sound like you aren't properly abstracting your code so it can be reused, or so that implementations can be switched out.
Mats wrote:
even when you use an existing algorithm, you still have to modify the algorithm to fit your game.
No, you do not modify the algorithm, your implementation looks different from case to case - the algorithm is always the same. Renaming a variable doesn't change the algorithm.
I definitely disagree with this. Elements of the algorithm are the same, but when for example, I implemented a flocking algorithm, it really was not a case of just copying the code and renaming variables. All sorts of things had to be changed. Another example was when I was applying a mini-max type algorithm to a board game I invented last year. Sure, it was a kind of mini-max type thing, but you couldn't call it a pure mini-max algorithm.
You're making it sound like you aren't properly abstracting your code so it can be reused, or so that implementations can be switched out.
Mats wrote:
even when you use an existing algorithm, you still have to modify the algorithm to fit your game.
No, you do not modify the algorithm, your implementation looks different from case to case - the algorithm is always the same. Renaming a variable doesn't change the algorithm.
If you "change" the algorithm, it's now another algorithm that someone already invented/discovered. I would be extremely impressed if you invented/discovered a new algorithm.
Okay, fine. Here mats, hold my beer. I have invented a new math operation. It's called the inverted not gate! Lemme show you how it works.
The not gates logic goes like this:
1 -> 0
0 -> 1
Now add a not gate in front of that not gate and presto! The inverted not gate! It's perfect for cryptography, Try it!
If that's been invented, add another not gate. Something new! It becomes the inverted inverted not gate! Keep going until you invent something new! Not gates are the answer to the worlds problems!
I hate looking up other peoples code to copy. I only search for algorithm implementations when it's a critical or non-trivial task. If the task is something I instinctively know how to handle, I just do it myself. If it's something specific and non-generic, and I want some kind of complex behavior that I thought of, I don't bother looking at all.
I know people who when they start a project, all they do is brainstorm on what libraries to use for what. They find a library for every little thing. In the end they hardly get anything done and certainly nothing impressive. Usually they spend most of their time trying to figure out how to use or modify other peoples code to little avail. Huge waste of time.
they spend most of their time trying to figure out how to use or modify other peoples code to little avail.
Not always true. With the modification of others code, you can come up with some pretty efficient and fancy stuff. Most of the time you're right though.
Example, in the language I'm writing this game in (high level) there are menus pre-made that are designed to work better. This method is commonly used by beginners. The second method, which isn't as conservative in terms of memory but conservative in terms of ease and "memory jumps" (labels).
I hate looking up other peoples code to copy. I only search for algorithm implementations when it's a critical or non-trivial task. If the task is something I instinctively know how to handle, I just do it myself. If it's something specific and non-generic, and I want some kind of complex behavior that I thought of, I don't bother looking at all.