• 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
BaneTrapper

Help calculate this easyer, or more efficient way

10 posts in this topic

Hello.

Reason:

Currently i am balancing the game i am working on.

 

What i want to achieve:

i am trying to find a formula that will be more efficient then this peace of code

/* Example values
int calcRT = 0;
int statRT = 9;
*/
int tax = 0;
for(unsigned int n = 0; n < unit.statRT; n++)

{

    unit.calcRT -= 100 - tax;

    tax += 5;

}

What i want is for each statRT to reduce calcRT by 100, but each one after that to give by 5 less so.

If statRT = 1, calcRT = -100;(100)

if statRT = 2, calcRT = -195;(100 + 95)

If statRT = 3, calcRT = -285;(100 + 95 + 90)

if statRT = 10, calcRT = - ;(100 + 95 + 90... + 65 + 60 + 55)

 

What syntax i am looking for

/* Example values
int calcRT = 0;
int statRT = 9;
*/
calcRT = statRT * (100 - (5 * statRT));
0

Share this post


Link to post
Share on other sites

calcRT = max(statRT - 1, 0)*5-statRT*100

perhaps

EDIT:

You might want to set an upper bound for statRT inside the max, because else it would go like ...+ 65 + 60 + 55... + 5 + 0 -5 which you probably dont want to happen.

EDIT2:

Oh wait that doesnt seem to work... :c

Edited by Waterlimon
0

Share this post


Link to post
Share on other sites
Are you looking for a formula that gives the same results?
calcRT = -100 * statRT + 5 * statRT * (statRT - 1) / 2;
Edited by Álvaro
1

Share this post


Link to post
Share on other sites

Are you looking for a formula that gives the same results?

calcRT = -100 * statRT + 5 * statRT * (statRT - 1) / 2;

Well that reproduces the values / value i am looking for.

Much respect, thank you for this.

 

 

calcRT = max(statRT - 1, 0)*5-statRT*100

 

perhaps

 

EDIT:

You might want to set an upper bound for statRT inside the max, because else it would go like ...+ 65 + 60 + 55... + 5 + 0 -5 which you probably dont want to happen.

EDIT2:

Oh wait that doesnt seem to work...

Its ... not ... correct

Edited by BaneTrapper
0

Share this post


Link to post
Share on other sites

Use Alvaro's formula (although watch out for the behaviour when statRT is bigger than 20, may want to cap it instead of going negative).

 

The pattern is -100, -200 + 5, -300 + (5 + 10), -400 + (5 + 10 + 15), ...

 

which is -100 * statRT + 5 * (Sum (0 to (statRT-1)))

 

And since Sum(0 to X) is 0.5 * X * (X+1), Sum(0 to (startRT-1)) = 0.5 * statRT * (statRT - 1)

 

which gives Alvaro's formula

 

EDIT: You probably don't want to cap anything when statRT is > 20, since the formula gives a nice (parabolic) curve.

Edited by Paradigm Shifter
0

Share this post


Link to post
Share on other sites

And here's something about how the maths for the sum works...

 

What is the area of an N * (N+1) rectangle?

 

XXXXXXX

XXXXXXX

XXXXXXX

XXXXXXX

XXXXXXX

XXXXXXX

 

if N = 6, area is 6 * 7 = 42.

 

What use is that?

 

What is the area of this shape?

 

X

XX

XXX

XXXX

XXXXX

XXXXXX

 

Answer: if you rotate a copy of it 180 degrees and line it up it forms a 7 * 6 rectangle (using O for the copy of the shape)

 

 

XOOOOOO
XXOOOOO
XXXOOOO
XXXXOOO
XXXXXOO
XXXXXXO

Which works for any size N, so the area of the shape is 0.5 * N * (N+1)

0

Share this post


Link to post
Share on other sites

Lookup table vs. simple formula? Simple formula for the win...

I am not sure. If you can make the table visible to a game designer, he can tweak it any way he wants.
0

Share this post


Link to post
Share on other sites

I suppose...

 

If I was living in some magical world in which designers actually tweaked values ;) (And not, hey that ends with a 7, that doesn't look neat, make it end with a zero instead, for no apparent reason).

 

Anyway you gave the correct answer and I explained some of the maths so we both win! Would probably help if we knew what the values were meant to represent in the game.

0

Share this post


Link to post
Share on other sites

Lookup table vs. simple formula? Simple formula for the win...

I am not sure. If you can make the table visible to a game designer, he can tweak it any way he wants.

Also it would allot bigger depth for the system.

But, it would also require more time to manage witch i lack sadly.

0

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