Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


iMalc

Member Since 05 Mar 2004
Offline Last Active May 08 2015 12:36 AM

Posts I've Made

In Topic: C++ cant find a match for 16 bit float and how to convert 32 bit float to 16...

13 April 2015 - 02:08 AM

I use a branchless table-driven implementation by Jeroen van der Zijp (http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf) which some time ago I wrapped into a class to make it as convenient as a regular float.

 

The conversions in both directions are two-liners, and the combined size of all of the lookup tables is less than 10K.

http://homepages.vodafone.co.nz/~tawa47a/Malc/Useful_Classes.htm

It's probably nearly functionally identical to Aressera's

 

Edit: Bah, Jeroen van der Zijp's original link is now not working for me.

 

Edit2: Christian Rau has since produced an even more complete version here, which is clearly also based on Jeroen's work, but is more complete than mine, with template meta-programming to avoid unnecessary conversions and such:

http://half.sourceforge.net/

Probably best just to use that one.


In Topic: A* algorithm on a top down vertical scrolling shooter?

08 April 2015 - 01:11 AM

It might be the case that the world is procedurally generated on demand.

 

In order to use A* you need to have a starting position and a goal position, and A* will give you the path from start -> finish. So if you have those bits of information and simply want to run the A* algorithm every time the exposed part of the world changes, which might be every frame, then that's do-able in general.

 

However, if as-it sounds your player is constrained such that they can only move horizontally, whilst the world moves vertically, then you have a bit of a snag because you are limited to moving in the following effective directions: up, diagonally up & left, and diagonally up & right. If the resulting path from A* contains portions which require travelling in other directions, then your player will be unable to follow the path.

 

It's at this point that I feel you will need to provide a more detailed description of the problem before we can give the right bit of advice. It might be that what you want is something very different, more along the lines of the minimax algorithm, whereby at any point in time you just want to work out which direction (left, right, or neither) is the most ... erm *productive*.


In Topic: Unused param

05 April 2015 - 01:57 PM

Unless I'm in the situation where the parameter is used in only debug or only release build, I tend to just comment out the parameter name.

 

I've also seen people just mention the variable name in the function body on a line by itself, without any cast.


In Topic: is it possible to prevent a proggram(specialy a game) to get decompiled

16 March 2015 - 02:42 AM

My take is that generally in the best case you're only going to be able to completely stop someone who is only as good a hacker as yourself.

 

But ... yes with the right outside help you can do better.

 

Still, there's always going to be someone out there with better hacking skills that whoever you learn from.

From them, your best defence is to make the reward not worth the effort. Sadly, that is not easy.


In Topic: Getting Rid of "char*"

27 December 2014 - 05:24 PM

Let's pretend it is an issue. How do you think you would solve it?

Actually, let's not pretend it's an issue, that's exactly what causes premature optimisation.

Here is the procedure to "solve it".

 

First prove it is an issue, via profiling. You've either done that and not posted results, or you haven't done that. Either way there is more work required at this step.

 

After that, your first attempt at a resolution should be to see how you can use strings less. E.g. if profiling showed that you had a bottleneck when comparing your string object IDs, then perhaps you could switch to using enumerations instead of strings. Or, if you're getting too many string copies, perhaps there are some critical places where the string is passed by value instead of const-reference.

 

The next thing to do is to look for a replacement that already exists. That may be in the form of a more-specialised part of the same library, or a whole other library. There is plenty that you can research.

 

Next, in considering whether to write your own replacement, you need to understand that in proceeding down the path of making your own, you are assuming that you can do a better job than the expert standard library writers. You are then assuming that you are in the top few percent of all C++ coders. Most people like to think that they are in the top few percent of C++ coders, but obviously most aren't. The experts are those who have first learnt to use existing tools very effectively (e.g. strings). One must learn why all the parts of the string class work as they do, in order to not fall into traps that others have already solved.

 

The final thing to understand is that even when there is a bottleneck, and even when you've done your best to optimise all related code as much as you can, there is always going to be a bottleneck somewhere. It's even possible that no matter what changes you make to a program, string handling could be such an unavoidable bottleneck (although that is generally unlikely, depending on what the program does).


PARTNERS