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

formalproof

Members
  • Content count

    96
  • Joined

  • Last visited

Community Reputation

165 Neutral

About formalproof

  • Rank
    Member
  1. I recently managed to get a cheap copy of Charles Petzold's Progamming Windows, 5th Edition (1998). I haven't really kept up with times all that well. So my question is: is this book, and the Win32 API in general, still relevant and useful?   I'm pretty sure that programs using the Win32 API described in the book are still compatible with modern versions of Windows. But has the API changed much since 1998? Will I get suboptimal performance or miss some important operating system features if I use the API calls described in the book?   The reason for my interest in Win32 API is that I'd like to be able to program with the minimal amount of abstraction layers (such MFC, .NET or the standard C/C++ IO libraries). That way, I get to know what my program really is doing under the hood. I am also involved in some research projects where speed and efficiency are critical, and I suspect I may have to write a very high-performance Windows program in the future. For this purpose, I suppose C and Win32 are still the way to go?
  2. [quote name='ApochPiQ' timestamp='1341960734' post='4957812'] The technical term for this is "[url="http://en.wikipedia.org/wiki/Endianness"]endianness[/url]". [/quote] Ok, seems I made an embarassing mistake in understanding what little endian means [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] So in a little endian system, val = 0xAABBCCDD is stored in memory as: 0 1 2 4 DD CC BB AA That would explain why vec[0] == 0xDD, etc. Thanks!
  3. I'm working on a project where I need to convert the bit pattern in an integer type to an array of chars (bytes), and vice versa. I'm wondering why this conversion always seems to "reverse" the order of the bytes. For example, when converting val = 0xAABBCCDD to an array of chars, the first element of the array will be 0xDD, the second 0xCC, etc., although I'm using a little endian system. For me, the logical order would be 0xAA, 0xBB, 0xCC, 0xDD, because that is the order in which the bytes of val are stored in memory, isn't it? Here is the code: [code] #include <iostream> #include <vector> using namespace std; int main() { int one = 0x1; cout << "The system is " << (((one << 1) == 0)? "big endian" : "little endian") << endl; // This will output "little endian" on my system vector<char> vec; vec.push_back(0xAA); vec.push_back(0xBB); vec.push_back(0xCC); vec.push_back(0xDD); unsigned long* ul = reinterpret_cast<unsigned long*>(&vec[0]); cout << hex << *ul << endl; // Why does this output 0xDDCCBBAA? unsigned long n = 0xAABBCCDD; vector<char> w; w.assign( reinterpret_cast<char*>(&n), reinterpret_cast<char*>(&n) + sizeof(unsigned long) ); for(int i = 0; i < w.size(); i++) { cout << hex << (int)(unsigned char)w[i]; // this cast is because we want to print the bit pattern of w[i], not the character } cout << endl; // This will output in the "reverse" order as well: 0xDDCCBBAA0000 } [/code] So I'm asking whether someone can explain to me why the order of bytes after conversion is 0xDDCCBBAA and not 0xAABBCCDD? Btw, if you know a better way to convert between an integer type and a vector of chars, or notice any other stupidities in my code, please let me know.
  4. Quote:Original post by Sneftel Not sure what you mean by "overkill". overkill = not much additional benefit compared to simpler system
  5. Thanks to both of you. Quote:Original post by Sneftel By the way, if you're doing events, and you're already using boost, take a look at boost.signals2, a signal/slot system which is already integrated with shared_ptr/weak_ptr for that sort of connection management. This would have been my second question: would you recommend using the boost signal library instead of my own notification system? I'm concerned it could a little overkill. Which approach would you take yourself?
  6. In my single player RPG (C++/Boost/Allegro), whenever a character dies, everyone who was targeting this character must be notified so that the AI can change its behaviour. I'm thinking of giving each character a list of other characters who are targeting it (a list "targeters"), and then broadcasting a message to each of them when the character dies. All my pointers are boost::shared_ptrs, and all characters are created on the heap. class Character { //... // List of characters who target this character std::vector< boost::shared_ptr<Character> > targeters; // Iterates over targeters and tells everyone this character died void broadcastDeath(); //... } // Called when this starts fighting target void Character::startFighting( boost::shared_ptr<Character> target ) { this->fightingTarget = target; target->addTargeter( this ); // here's the problem this->pushAiState(ais_fight); } Since I cannot directly get a shared pointer from this, would this be a valid situation to use boost::enable_shared_from_this? I could also make the targeters vector save raw pointers, but I don't like this idea. There may be other situations where I need take a member from the targeters vector and pass it to a function which takes a shared_ptr as an argument. Also, I'm not sure if it's safe to have a vector which saves a raw pointer to X and at the same time have other vectors which save shared_ptr to X (all the other "list of characters" vectors in my game save shared_ptrs). What would you do in this situation?
  7. Quote:Original post by ApochPiQ First of all do a clean rebuild of the project and make sure that you don't just have some corrupted files floating around in the build cache. This is generally the first port of call when dealing with mystery bugs, because you want to rule out the possibility that it isn't in fact your fault [wink] Thanks a lot -- doing a clean rebuild solved the first kind of problem. I'm now trying to see if there is a regular bug (not memory corruption) causing the other errors; I'll come back to you later when I know more. Just one question at this point: since Visual C++ obviously made a mistake and had a corrupted file in cache, does this mean it is likely to do it again, and could there be a specific reason for it, or does the corruption just happen at random?
  8. I'm writing a single-threaded, single-player game with Visual C++, Allegro and Boost. Some time ago I started to get some really weird access violations. I've tried to track back the changes I have made but I have found nothing which could cause them. For example, although I have not changed executable lines 1 to n-1 at all, I now get an error on line n (I did, however, change some of the #includes and the other files). I always encapsulate memory allocations inside shared_ptr's, like this: boost::shared_ptr<Sprite> sprite = boost::shared_ptr<Sprite>( new Sprite(32, 32) ); This is where one of the errors occurs. The Sprite constructor finishes, but the shared_ptr constructor gives an error: "0xC0000005: Access violation writing location 0xcdcdcdd1." Before now, everything worked perfectly, and I did not change any line which is executed before this one. The other errors I'm getting are weirder. For example (the following code also worked perfectly before I started getting the memory errors): bool Spell::isOnTarget() { // targetCharacter is of type boost::shared_ptr<Character> // x, y and targetCharacter are member variables of Spell if(( x == targetCharacter->x ) && (y == targetCharacter->y )) return true; else return false; } This never returns true, even when the coordinates are equal; I've tested situations when the spell should definitely be on target. When debugging with VC++, I can even check from the local variables window that x and targetCharacter->x, etc. are equal, yet, the condition still evaluates to true. If I change the code to this: bool Spell::isOnTarget() { int tempX = targetCharacter->x; int tempY = targetCharacter->y; if(( x == tempX ) && (y == tempY )) return true; else return false; } then it works. All this doesn't seem to make any sense. Probably the heap gets corrupted somehow, but I don't have any experience debugging memory corruptions, so I don't know what to do. All calls to the new operator are encapsulated in boost::shared_ptr constructors, so they shouldn't be any memory leaks. I've tried rebooting Windows XP, but it didn't help either. My game runs in a single thread, although I think some Allegro timer routines run in a separate thread. Which steps should I take to debug this? [Edited by - formalproof on July 7, 2010 4:17:46 PM]
  9. Quote:Original post by rip-off With practise, it is easier to remember the structure of programs. One skill that has come in useful time and time again is reading foreign code, as in code you didn't write. I honed that skill over many years on these forums - inferring architectural details from a beginners post is often required when important details are omitted by the beginner. If you can dive into anyone elses code, of varying quality, it becomes quite easy to navigate your own quickly. I'd love to learn to read code efficiently. I have tried to look at a few open-source RPG projects (which tend to be large, and not well documented), and I've found it extremely difficult to grasp the overall architecture. Especially since today complexity is divided into small parts, which means that you have to read and cross-reference N functions / source files to understand one algorithm.
  10. Quote:Original post by Telastyn Not in my experience. They quickly go out of date, don't show actual interaction between portions of code, and generally aren't accurate or useful abstractions. Let's say you have a large project, and you have not been developing it for several months. You have forgotten much of its architecture and how it works. What is the first thing you do in this situation? Do you simply read through all the relevant code files? Isn't that too many files to read? How many files do you have to read in average to get a good grasp? Do you use any additional tools at all to help refresh your memory?
  11. Quote:Original post by owl Ideally, you would have the entire design document of the application you are coding. The complete description of every functionality required. And the development divided in stages that are done when you code, test and debug the last routine in each one. That way you will always know where you are, what to do and how much is left to be done. I have found that designing everything in advance is a waste of time in my situation. Perhaps it works for professionals who have done everything already a million times, and know what works and what is doable. But for someone who is still learning, it is impossible to find a good design before seeing how the program develops. Especially in a game project, where it's very hard to predict what is going to be fun and what is not.
  12. Quote:Original post by Telastyn Quote: How do you maintain the big picture of your code structure while coding? I don't. Keeping details in your head gets harder as you get older, and even mildly complex programs are too complex to hold all the details in mind. Abstraction is your friend. While coding, you should only need to be aware of the things directly relevant to that code. Having a good design helps. Having good intellisense helps a lot. Having consistent naming and coding patterns help. Of course, in an ideal world your code is written so clearly that you don't need diagrams, or even comments. But we do not live in an ideal world. Like you say, abstraction is important. Aren't diagrams just that - useful abstractions? Since I'm writing a relatively large game in my free time (with long breaks between), what I need most is a quick way to refresh my memory about my program's architecture, interactions, sequences, etc. Doing this by reading my code is a pain, since it's a lot to read, and admittedly the code is often unclear and hard to grasp. (In an ideal world, I would refactor it and make it clear, but I have found that perfectionistic refactoring is rarely a good idea, since it takes way too much time. Besides, when I add new features, the new code will again be bad, so I there will always be unclear code in my project anyway.) Diagrams would be the perfect solutions for this, since they allow to understand the structure at one glance. But until now my attempts at creating useful diagrams have been unsuccesful, and I'm not sure how I can learn this. Watching how professionals do this would be very educational, but I don't have this opportunity in real life. Are there some online material or books available about this?
  13. I have the problem that I often lose the big picture of my program structure while coding. The best solution would naturally be to draw diagrams. I believe especially sequence diagrams would be useful, since my programs (usually games) tend to have complicated sequences and subsystem interactions. Until now, I've simply left some notes about the structure as comments in the code itself, but these are not practical, since you need to browse through the code to find them. However, when I try to draw such diagrams, it takes way too much time, and it's too time consuming to change the diagrams when the code changes. My question is, how do you solve this problem? How do you maintain the big picture of your code structure while coding? Which tools do you use to draw diagrams? Which diagram types do you use? How do you keep all your diagrams organized so that you can cross-reference them easily? How do you keep your diagrams up to date when the code changes?
  14. Sorry about frasing my question in an unclear fashion. I forgot to say that I do not know which intervals weapon, strength and dexterity are from. (i.e. I want my solution to be general and not dependent on these intervals). Quote:Original post by schattenmaennlein You want the damage to be 0-20%*Strength + 0-20%*Dextery + 0-60%*Weapon? Damage = Rf(0,0.2) * Strength + Rf(0,0.2) * Dextery + Rf(0,0.6) * Weapon; Because of the different ranges, this is not correct. For example, if we have the following ranges: weapon : [1,100] str: [1,20] dex: [1,20] And for example weapon=70, str=20 and dex=9. (i.e. str is maximal) And let's say the RNG Rf(0,0.2) returns 0.1, Rf(0,0.2) returns 0.1 and Rf(0,0.6) returns 0.3 Then damage is = 0.1*20 + 0.1*9 + 0.3*70 = 2 + 0.9 + 49 = 51.9 See the problem? The strength component is only 2, which is just about 4% of the total, although strength was at maximum! And the dice wasn't even especially bad (it was average). However, I was able to find a satisfying solution to the problem. Let's say the possible range of values in the game is: wpn: [1, wpn_max] str: [1, str_max] dex: [1, dex_max] i.e. str_max is the maximum strength possible in the game. And the attacking character has the following values: wpn = w str = s dex = d Then we define three random variables with uniform distribution: X_1 = {1,...,w} X_2 = {1,...,s} X_3 = {1,...,d} In the whole game, the maximum for the sum these random variables is: max = wpn_max + str_max + dex_max However, the maximum for our specific character is: total = w + s + d Our task was to construct a damage function such that "weapon contributes at most 60% of the damage, strength and dexterity both at most 20%, and the damage must be a value from [1, d_max]." The solution is: (assuming X_1 = x1, X_2 = x2, and X_3 = x3) char_damage = (x1)/(w)*0.6*total + (x2)/(s)*0.2*total + (x3)/(e)*0.2*total final_damage = (char_damage / max) * dmg_max The idea is not to look at absolute values, but at the "goodness" of each value, i.e. how far away it is from its maximum. First we compute how good the value is for this character, and then how good it is for all possible characters. It took me several hours to come up with this (I know, I'm stupid), but I did a few tests and it seems to work. I can make it even more general if I replace the percent factors (0.6 etc.) with variables. This is not only useful for damage computation, but for all kinds of RPG character ability checks. The main advantage is that you can formulate RPG rules in an intuitive fashion "lock pick skill determines 80% of the success, and dexterity 20%", and by setting a few variables you already have a complete rule. Do you think my approach is correct? Can you see any mistakes or problems with this?
  15. I'd like to state some rules of my RPG in the following way: "Each time a character lands a hit, the weapon modifier should determine up to 60% of the damage, strength should determine up to 20% and dexterity up to 20%. The damage must always be an integer from [dmg_low, dmg_high]." Is there a general formula for doing this computation? I know, my formulation of the goal isn't probably the best, and has several different interpretations. For example, where does the random element come in? (We don't want the game to be deterministic). One possible way is to define 3 random variables: X1 = {0,...,weapon} X2 = {0,...,str} X3 = {0,...,dex} (weapon is the character's current weapon modifier, etc.) With every value being equally possible, i.e. P( X1=i ) = (1/weapon) (in other words, X1 is simply a fair (weapon)-sided dice.) So the best possible result is that every random variable gives the maximum value: max = weapon + str + dex And now I want to create the damage function D, such that X1 contributes 60% to the value of D, X2 contributes 20% and X3 also 20%. Additionally, D needs to be an integer from [dmg_low, dmg_high]. D(X1,X2,X3) = ? How can I do this? It sounds simple enough, but I'm out of ideas.