• 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.
  • entries
    432
  • comments
    1166
  • views
    759342

More ANL refactoring

Sign in to follow this  
Followers 0
JTippetts

815 views

I've been working on fleshing out island generation in GC. The current generator is kind of a legacy holdover from much earlier versions of GC; the basics of it were in the very first prototype that started this project. (Crikey, I had to scroll back through my journal for a long ways to get to that. Has it really been over two years since I started this thing?)

In the process of fleshing things out more (adding more resource types, playing with spawn-point distribution for certain map types, etc...) I've taken the opportunity to do some edits to the Accidental Noise Library. Some pretty major ones.

First of all, I fixed up constructors for all the module types. Many of them were missing some constructors that make it easier to construct objects quickly and efficiently; in their absence, construction of certain modules was a tedious affair of constructing then calling methods to set members. I've added in constructors for most of the options on most of the modules, so that for the majority of constructs you can construct your modules fully in a single call.

Secondly, I've changed the internal structure of all modules to use smart pointers rather than raw pointers. This changes allows me to construct entire module chains without having to store pointers to all of the child modules in a structure somewhere. Now, I can build the chain then just keep a pointer to the root module of the chain. Saves me a lot on book-keeping.

Thirdly, I've implemented a class for elegantly constructing chains of modules with the possibility of storing pointers internally to all the child modules. (If you want to re-seed modules individually without re-seeding the entire structure, this is the way to go.) I constructed an interface that allows me to do chained construction of modules an a fairly elegant manner. This has made it easier to build elaborate function chains in C++. (This sort of functionality was available for a long time in Lua, due to a wrapper script class I wrote. The new method replaces this, though.)

Now, in C++, I can construct a chain of modules like so: anl::CTreeContainer tree; tree .sphere ("Sphere", 1.0,0.0,0.0,0.0) .fractal ("FBM1", anl::FBM, anl::GRADIENT, anl::QUINTIC, 8, 2) .autoCorrect ("FBMAC1", "FBM1", -0.25, 0.25) .fractal ("FBM2", anl::FBM, anl::GRADIENT, anl::QUINTIC, 8, 2) .autoCorrect ("FBMAC2", "FBM2", -0.25, 0.25) .translateDomain ("T1", "FBMAC1", 0.125, 0.125, 0.125) .translateDomain ("T2", "FBMAC2", -0.125, -0.125, -0.125) .translateDomain ("Turb", "Sphere", "T1", "T2", 0.0) .rgbaImplicitGrayscale ("RGBA", "Turb"); auto m=tree.getRGBAModule("RGBA");I've never been a huge fan of that type of chained calling, but in this case it is quite a bit more concise.

The CTreeContainer class implements factory methods for each of the module types (with overloads for all parameter possibilities) allowing you to build your chain in place. Most of the parameter inputs to a module can be either double-precision constants or the output of other modules, so the parameterization of the factories reflects this. In the above, I construct first a Sphere with a radius of 1 centered at (0,0,0). Then I construct two FBM fractals, and tie them to AutoCorrect modules to fix their output into the range [-0.25,0.25]. Then, I feed the output of those to some TranslateDomain functions, to shift them to different parts of the fractal. (If you don't want to reseed anything, this is a good way of removing correlation from different fractals, which are all constructed with the same internal seed.) Finally, the two corrected and translated fractals are used to apply turbulence to the output of the sphere in another TranslateDomain function, the result is fed to an ImplicitGrayscale adapter which converts the double output of the noise modules to an RGBA value, and the tree is queried for a pointer to this root module.

Now, in the course of all of this I stumbled upon a problem. As I mentioned before, most of the modules are very parameterized. Inputs can be either double constants or other modules. This means, though, that the process of building constructors is... messy.

Consider, for example, the CRGBASelect module. This module takes two RGBA inputs as colors to select between, and provides inputs for Control (value that determines the selection mix amount), Threshold (marks the center point of the transition range) and Falloff (specifies the width of the soft blend transition range between the two input colors). Either RGBA input can be either a color constant or the output of a module chain with an RGBA module at the root. Either of the Control, Threshold and Falloff inputs can be either a constant double value or the output of an implicit module. This means that in order to provide full constructors for the object, I have to provide 2[sup]5[/sup]+1 (or, 33) separate constructors.

(Beware. Ugly code ahead.)
[spoiler] CRGBASelect(SRGBA low, SRGBA high, double control, double threshold, double falloff); CRGBASelect(SRGBA low, SRGBA high, double control, double threshold, std::shared_ptr falloff); CRGBASelect(SRGBA low, SRGBA high, double control, std::shared_ptr threshold, double falloff); CRGBASelect(SRGBA low, SRGBA high, double control, std::shared_ptr threshold, std::shared_ptr falloff); CRGBASelect(SRGBA low, SRGBA high, std::shared_ptr control, double threshold, double falloff); CRGBASelect(SRGBA low, SRGBA high, std::shared_ptr control, double threshold, std::shared_ptr falloff); CRGBASelect(SRGBA low, SRGBA high, std::shared_ptr control, std::shared_ptr threshold, double falloff); CRGBASelect(SRGBA low, SRGBA high, std::shared_ptr control, std::shared_ptr threshold, std::shared_ptr falloff); CRGBASelect(SRGBA low, std::shared_ptr high, double control, double threshold, double falloff); CRGBASelect(SRGBA low, std::shared_ptr high, double control, double threshold, std::shared_ptr falloff); CRGBASelect(SRGBA low, std::shared_ptr high, double control, std::shared_ptr threshold, double falloff); CRGBASelect(SRGBA low, std::shared_ptr high, double control, std::shared_ptr threshold, std::shared_ptr falloff); CRGBASelect(SRGBA low, std::shared_ptr high, std::shared_ptr control, double threshold, double falloff); CRGBASelect(SRGBA low, std::shared_ptr high, std::shared_ptr control, double threshold, std::shared_ptr falloff); CRGBASelect(SRGBA low, std::shared_ptr high, std::shared_ptr control, std::shared_ptr threshold, double falloff); CRGBASelect(SRGBA low, std::shared_ptr high, std::shared_ptr control, std::shared_ptr threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, SRGBA high, double control, double threshold, double falloff); CRGBASelect(std::shared_ptr low, SRGBA high, double control, double threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, SRGBA high, double control, std::shared_ptr threshold, double falloff); CRGBASelect(std::shared_ptr low, SRGBA high, double control, std::shared_ptr threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, SRGBA high, std::shared_ptr control, double threshold, double falloff); CRGBASelect(std::shared_ptr low, SRGBA high, std::shared_ptr control, double threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, SRGBA high, std::shared_ptr control, std::shared_ptr threshold, double falloff); CRGBASelect(std::shared_ptr low, SRGBA high, std::shared_ptr control, std::shared_ptr threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, double control, double threshold, double falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, double control, double threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, double control, std::shared_ptr threshold, double falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, double control, std::shared_ptr threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, std::shared_ptr control, double threshold, double falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, std::shared_ptr control, double threshold, std::shared_ptr falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, std::shared_ptr control, std::shared_ptr threshold, double falloff); CRGBASelect(std::shared_ptr low, std::shared_ptr high, std::shared_ptr control, std::shared_ptr threshold, std::shared_ptr falloff);[/spoiler]

I hate this. Granted, it was easier to just write a quick Lua script to generate all of the constructors, but it still seems like such a waste to me. Unfortunately, my C++ foo (which was always relatively weak) has grown even weaker in my years of working mostly with Lua, so I just can't quite wrap my head around a more elegant method of handling this.

If anybody reading this knows a more elegant solution to this problem, I'd like to hear it. I probably won't upload this new version until I've fully researched this problem and am satisfied I have the best answer.

A final change I have made is to eliminate/consolidate some modules. As the library grew, I would add modules as I needed them so that I ended up with a lot of separate modules for basic functions such as cos, pow, abs, etc... It's unnecessary to have separate functions for these, though, so I consolidated them into a single Math module, with the operation controlled by a parameter.

Anyway, that's what I've been up to. I haven't done anything of a cool visual nature since the last screenies were posted. I thought about posting some screenies anyway, but I figured it would be pretty pointless.

0
Sign in to follow this  
Followers 0


4 Comments


Be interested to see this in action... meaning you have the on the fly ability to generate the islands now!!! show many different island types. Keep up the cool ideas and work!!

0

Share this comment


Link to comment

Please post some screenies anyway.

 

Since you prefer Lua you could keep the use of C++ restricted to only the internals of a module, outline the rest in Lua and use the Lua registry or some other serialization process (e.g. protocol buffers) to pass data in and out. I've always found C++ to be too rigid to allow for a convenient JSON-like method of chaining parameters.

0

Share this comment


Link to comment
Well, I'm working on a container to load and save tree structures to YAML. yaml-cpp, which I used in some previous experiments, is a pretty handy little library for such things and is making it pretty easy.
0

Share this comment


Link to comment

When do you plan to release this refactored ANL version? Anytime soon? Also I'd really suggest using github or bitbucket (or something similar) rather than sourceforge for hosting the project.

0

Share this comment


Link to comment

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