Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


swiftcoder

Member Since 03 Jul 2003
Offline Last Active Today, 10:06 AM

#5193108 A Complete "English Word List"

Posted by swiftcoder on 16 November 2014 - 11:26 AM

I take it that by 'all words' you only want words in English?

On any Mac/Unix/Linux install you should have a file at /usr/share/dict/words, intended for use by spellcheckers and similar programs. It should contain most legal spellings in the English language (mine contains 235,886 words).


#5191520 using method pointers instead of objects with state pattern?

Posted by swiftcoder on 06 November 2014 - 08:25 AM

I'm overriding the state by using different methods.

 
Consider the following definition:
struct A {
    virtual void operator () () = { //... };
};

struct B : public A {
    virtual void operator() () { //... };
};

B b;
A &a = b;
a();
And now consider instead:
typedef void (*A)();

void B() { //... }

A a = B;
a();
Same end result, different construction.
 
Polymorphism in C++ (at least as viewed from a high level) amounts to looking up pointers in tables - you are just managing the lookup yourself.
 

This eliminates the allocation of new objects every state change and the copying of data between states.
The drawback of course is that all of the state specific variables are now crammed into one object.
Oh, i forgot to mention the benefit of not having an entire directory full of source files (1 .h and 1.cpp file for every state).

You can achieve all the same advantages by (a) creating a StateHolder object that stores the variables for all states and is passed to each new state by reference (thus avoiding the copy), and (b) by writing all your state objects in one file - there is nothing in C++ that mandates one file per class.


#5191360 using method pointers instead of objects with state pattern?

Posted by swiftcoder on 05 November 2014 - 11:38 AM


What I've done is basically changed this so there is only ever one state object that inherits from the base state object and gives us method pointers.
The method pointer is the state basically. When the current state wants to move to another state it gives us the next method pointer.

Congratulations, you've re-invented polymorphism.

 


should this thread be moved into [coding horrors]?

Quite possibly smile.png




#5191219 Mutiple VAOs and VBOs

Posted by swiftcoder on 04 November 2014 - 04:52 PM


If you're an advocate for VAOs then that's fine and I don't have anything against them. If they have a real world impact then I'm all for it but why dismiss a valid point that the benefit is not always there?

If you had reproducible data demonstrating that correct use of VAO resulted in decreased performance, I wouldn't have a problem with your statement.

 

But since your data indicates it to be a wash in your case, and existing benchmarks note measurable performance gains, I'd prefer that we continue to teach best practices.




#5191155 Mutiple VAOs and VBOs

Posted by swiftcoder on 04 November 2014 - 12:08 PM


In practice though I tend to believe in what I see and not what I "think" makes sense.

Sure, various drivers don't derive any measurable performance benefit from VAOs. There are also still drivers where immediate mode + display lists are still the performance path.

 

Which is why I'd rather you weren't handing out advice based on generalizing results on a limited set of hardware/drivers.




#5190906 how to remotely configure app starter packs?

Posted by swiftcoder on 03 November 2014 - 08:20 AM

Why do you want to provide different users with different advantages based on demographics?

 

This seems blatantly unfair to anyone who happens to fall outside of your favoured demographics, and likely to result in a lot of people lying on signup to fall into a favoured demographic...




#5190902 What can I improve in this code

Posted by swiftcoder on 03 November 2014 - 08:00 AM


I would return a signed int, and "-1" if the item isn't there.

It's also fine to return -1 as an unsigned int to indicate an error condition.

 

The value of -1 cast to an unsigned int is 0xFFFFFFFF, which is an easy error condition to test for, and highly unlikely to be a valid array index in a 32-bit program.

 

You'll find this pattern all over the std library, in the form of static_cast<size_t>(-1).




#5190731 Why don't you use GCC on windows?

Posted by swiftcoder on 02 November 2014 - 08:02 AM


but as long as Windows doesn't work out of the box...

Hang on, hang on... There are two entirely separate versions of clang for windows: clang-cl, which attempts to be drop-in replacement for Microsoft's compiler, and 'clang-on-mingw', which is a vanilla GCC-like clang build.

 

The former is very much a work in progress, as it needs to implement support for all the non-standard things Microsoft's compiler implements. The latter worked just fine last time I checked (although 64-bit support for the standard library may be shaky).




#5190389 ENet packet question

Posted by swiftcoder on 31 October 2014 - 09:08 AM


data.insert(data.end(), id, sizeof(id));

This line does not insert 4 chars containing the relevant bytes from 'id'. Instead it inserts 'id' chars which all contain the same value 4 - i.e. sizeof(id).




#5190370 Naming rarities in a collectible card game

Posted by swiftcoder on 31 October 2014 - 08:10 AM


The theme is gangsters and the underworld.

I take it that is 'underworld' in the criminal sense, not the mythological sense? In that case, I wonder if names like mythical and legendary may be a poor fit for the theme.

 

One avenue you might consider would be to model your rarities on weapon licensing, something like: Legal, RestrictedExport Controlled, Military Use Only, and Banned.




#5190356 Why don't you use GCC on windows?

Posted by swiftcoder on 31 October 2014 - 07:30 AM


Yea like on OSX...they simply linked gcc to clang

That's explicitly how clang is designed: to be a drop-in replacement for GCC. And for maybe 90% of common software, it makes no difference.

 

Unfortunately, clang is stricter than GCC when it comes to various language quirks, and *way* stricter than Microsoft's compilers, which leaves a significant body of older and/or poorly-written software that doesn't cleanly compile with Clang.




#5190342 Why don't you use GCC on windows?

Posted by swiftcoder on 31 October 2014 - 06:45 AM


If clang was the default on Linux distributions, you would use clang, not GCC.

And honestly, that day is not far off. There's already talk about making clang the default compiler in a number of linux distribtions.




#5190341 synthetic instruments tutorials?

Posted by swiftcoder on 31 October 2014 - 06:43 AM

Another interesting reference is the (insanely long) Synth Secrets series, which goes into a lot of detail about the theory underlying analogue and digital synths.




#5190273 Would this c pointer work as a float buffer?

Posted by swiftcoder on 30 October 2014 - 08:10 PM


Unless the non-OO portions of Objective C have strayed far from the C roots...

Objective-C is quite literally the Smalltalk object and messaging semantics welded on top of plain old C.

 

In other words, all the parts that look like C, work exactly like C.




#5190229 Naming rarities in a collectible card game

Posted by swiftcoder on 30 October 2014 - 03:28 PM

Other common rarities are LegendaryExotic and Unique (assuming that there are 1-of-a-kind cards in your game).






PARTNERS