Best way to validate algorithms?

Started by
5 comments, last by JoeJ 1 year, 11 months ago

Just wondering if anyone can share their tips or process of how they go about validating their own custom algorithms before writing a single line of code. How do you go about testing/validating the conceptual (mathematical) idea that your code is based on? Do you validate the conceptual idea first or do you just go head first with the implementation, and see if it works.

Do you use proof by mathematical induction? Say for example in the case of lighting, shadow rendering, animation,

and etc.

Advertisement

Depends on the concept being implemented.

Almost nothing in game development is “proof by mathematical induction”. That type of thing exists but is extremely rare. Sometimes it is implementing based on a research paper. Quite often it is reasoning about the logic of simple elements which then combine into complex forms. Very rarely it is working out what you want on paper (or by arranging physical things), hashing it out with co-workers, and implementing whatever fits best.

As for more verification, it also depends on what's being implemented. If you're working on a library or other permanent code, you're more likely to have some automated tests that ensure the functionality doesn't break in the future. If you're working on gameplay code or throwaway stuff for a single title, verification is sitting with a designer or QA person and saying “looks good enough”.

So would you say that game dev, in the case of things like testing out a new lighting or animation system, is essentially just trial and error. Develop a mathematical model, convert it to an algorithm, implement it through code, then see what happens. If it doesn't suit your needs revert back to the drawing board (back to step one the mathematical model)?

Just trying to see if there is a more efficient methodology that doesn't involve code rewrite (Even though I understand that is the nature of software development in general). More than welcome to share your own experiences on the matter in regards to methodology.

No, I would call it iterative.

Start at the drawing board, start with paper and pencil experiments. If those work out, refine it out on computer. Get feedback and refine more. Repeat until you're satisfied or you're shipping a product. If you're dumping and going all the way back to the drawing board you've probably messed up badly along the way.

It looks like you're also conflating two different items. One is a pure research task of trying to make something that is fun. The other is implementing those concepts. The first is an unpredictable step that in game development usually happens in pre-production. The second is already after people have played with the concepts and played with them a bit, implementing them into the game is something that is direct from notes and earlier exploration, and often with one or two iterative steps and that's it. The two are different.

I think it out, code it, write test cases, and pray I didn't miss anything. Sometimes I get something to work but later think of a far easier and/or faster wat to do it and end up rewriting it.

Genesis111 said:
Just wondering if anyone can share their tips or process of how they go about validating their own custom algorithms before writing a single line of code.

I almost never do this, beside some vague and coarse initial idea combined with intuition about how it should work.

I could eventually do some figures / equations / flow graphs on paper, but that's some work.
I prefer to write code right away instead, even if i know i'll rewrite / replace it later most probably. That's also some work, but i already have some code which i'll keep.

I'm also a very visual coder, which means i add a lot of temporary debug visualization and GUI, so i can test and verify or detect special cases. This makes the code a mess, but it makes things much easier.
Once it works robustly, i remove the debug code and eventually refactor.

This topic is closed to new replies.

Advertisement