• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
MilchoPenchev

Eight, Nine, Ten...

32 posts in this topic

edit:
Oh gosh, I didn't even realize the TEN issue... That's horrible.

That edit made my day :D - that is exactly why this is so scary.

0

Share this post


Link to post
Share on other sites

Could be binary coded decimal... [snip]

 

That sounds so convoluted it requires its own thread. 

Unfortunately that wasn't the case here - this code, according to a colleague who originally fixed it - caused a fatal crash in the software. 

0

Share this post


Link to post
Share on other sites

Obvious, the coder has 8 fingers on each hand

Edited by Tournicoti
2

Share this post


Link to post
Share on other sites

Obvious, the coder has 8 fingers on each hand

... maybe the use of named constants is what was at fault here ...

...
#define FOURTY_TWO (042)
#define NINETEEN_EIGHTY_FOUR (NINETEEN, EIGHTY, FOUR)
...
0

Share this post


Link to post
Share on other sites

That's even worse!!!

This used to happen to me when I was trying to align constants properly. Nowadays I just put spaces instead, been burned too often by this damn octal notation "feature" which I'm guessing nobody actually uses, except the odd raw socket hacker (if even). Permission bits are another one, but constants for those are already defined anyway.

0

Share this post


Link to post
Share on other sites


That's even worse!!!

This used to happen to me when I was trying to align constants properly. Nowadays I just put spaces instead, been burned too often by this damn octal notation "feature" which I'm guessing nobody actually uses, except the odd raw socket hacker (if even). Permission bits are another one, but constants for those are already defined anyway.


at one point I made things more orthogonal (for my script language) by adding several number notations:
0b... //binary
0c... //octal
0d... //decimal
in addition to:
0x... //hexadecimal

then got into a big mental debate as to whether or not to keep '0' by itself as an octal prefix, make it decimal, or maybe just deprecate it and issue a warning...

note, '_' is also a spacer, so:
0d999_999_999
is the same as:
999999999

likewise:
0x5CD13A42_3B9AC9FFL
or:
999_999_999_999_999_999L
or:
0x0DE0_B6B3__A763_FFFFL
0

Share this post


Link to post
Share on other sites

Octal was big back in the day when C was being made, maybe even moreso than hexadecimal. These days nobody really uses it since it can't be aligned nicely to 8-bit (some computers back then had words with a bit count multiple of 3, so octal probably made a lot more of sense).

0

Share this post


Link to post
Share on other sites

Still trying to figure out the reasoning behind that. Is that what happens when your code analysis tool complains about "magic numbers" and somebody just decides to "fix it"?

 

Because having one such tool complain about '0' being a "magic number" really made me question the worth of that tool and what the creators' code would look like.

0

Share this post


Link to post
Share on other sites

But they could have made it useful by adding pluses!

#define ONE     +1
#define TWENTY  +20
#define HUNDRED +100
 
// Here's a little example
#include <iostream>
 
int main()
{
    int x = ONE;
    std::cout << x << std::endl;
 
    x = ONE HUNDRED;
    std::cout << x << std::endl;
 
    x = ONE HUNDRED TWENTY;
    std::cout << x << std::endl;
 
    x = ONE HUNDRED TWENTY ONE;
    std::cout << x << std::endl;
}

 

Or even worse:

 
#define ONE     +0x001
#define TWENTY  +0x020
#define HUNDRED +0x100

 

Sadly this doesn't fully work: 

 

 

TWO HUNDRED == 102

But don't worry - we can fix it! We just need to be "clever"...

 

 

#define AND +0
#define ONE +1
#define TWO +2
#define TWENTY +20
#define HUNDRED *100
 
// Here's a little example
#include <iostream>
 
int main()
{
    int x = TWO HUNDRED AND TWENTY ONE;
    std::cout << x << std::endl;
    // prints 221
}

 

This way you even get to write grammatically correct numbers. happy.png

Edited by Bacterius
1

Share this post


Link to post
Share on other sites

*snip*

Ah, good catch!
 

I think we should pool our efforts and make a programming language where this kind of thing is sane.

I was hoping for a more concise solution, but here we go (so now you can use commas and hyphens in your numbers!):
#include <type_traits>

template <typename T>
struct Number
{
    mutable T n;
    Number(T n) : n(n) {}

    const Number<T> operator+() const
    {
        return *this;
    }

    template <typename U>
    const Number<typename std::common_type<T, U>::type> operator, (const Number<U>& num) const
    {
        return n + num.n;
    }

    template <typename U>
    const Number<typename std::common_type<T, U>::type> operator- (const Number<U>& num) const
    {
        return n + num.n;
    }

    template <typename U>
    const Number<typename std::common_type<T, U>::type> operator+ (const Number<U>& num) const
    {
        return n + num.n;
    }

    template <typename U>
    const Number<typename std::common_type<T, U>::type> operator* (const Number<U>& num) const
    {
        return n * num.n;
    }

    operator T() const
    {
        return n;
    }
};

Number<unsigned long long> operator"" _n(unsigned long long n)
{
    return n;
}

#define ONE      +1_n
#define TWO      +2_n
#define THREE    +3_n
#define FOUR     +4_n
// ... add more if you wish
#define TWENTY   +20_n
#define HUNDRED  *100_n
#define THOUSAND *1000_n
#define AND

#define TIMES *
#define MINUS -

#include <iostream>

int main()
{
    // The only real drawback is that you have to surround them with parentheses if you use ,
    int x = (FOUR THOUSAND, ONE HUNDRED AND TWENTY-THREE);
    int y = (ONE HUNDRED AND ONE);
    int result = x TIMES y;
    std::cout << x << " * " << y << " = " << result << std::endl;

    result = x MINUS y;
    std::cout << x << " - " << y << " = " << result << std::endl;
}
Edited by Cornstalks
2

Share this post


Link to post
Share on other sites

I think we should pool our efforts and make a programming language where this kind of thing is sane.

 

It's called "Cobol"...

-1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0