Author Topic: Class Constructor questions  (Read 8439 times)

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Class Constructor questions
« on: February 29, 2016, 04:22:32 AM »
I understand that a class constructor is a special member function that is automatically called whenever an object of the class is declared. The purpose from tutorials that I've read is that the constructor takes the formal parameters and utilizes them in its function definition for the constructor to initialize the member variables for the class. This is often done because the class's member variables are private, and thus cannot be initialized with a value unless it is done by a member function.

So my question is this: If you make your member variables for a class public instead of private, would you still use a constructor, or would the constructor in that case be excess/worthless code?

I know that most tutorials suggest that member variables should be private so that other things can't change their values except member functions. However, if you code it carefully so that only functions that you want to allow it used for can use it, what else could possibly change their value without the programmer's consent? (What I mean is that nothing in a program, no step or calculation, is performed unless the programmer manually types in that bit of code. So, if a member variable was made public, what could change it's value other than the code the programmer codes in?)
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #1 on: February 29, 2016, 10:12:20 AM »
If you're working on a project with a team of programmers, chaos ensues. ;)

The public/private distinction is particularly important for public APIs that are used by thousands of programmers, but only maintained by a few. It keeps support costs down when people aren't messing with internal details that are subject to change.


Usually structs have all members public, while classes have all member variables private. If you need access to a class's private members, usually a public accessor method is written.

There is no real difference between a struct and a class in C++, only the default visibility changes (public for struct, private for class), and possibly some name mangling differences. They can both have member functions, member variables, public and private members, constructors, destructors, and overloaded operators.

With that said, it's not unusual for a struct, with all public member variables, to also have a constructor. It's a convenience method really, that initializes the struct. If there are many fields, it can set them all, and it's free to set fields according to complex interactions if desired. It could be that values are supplied for only some members, and then calculated for others. It could be you're initializing using overloaded constructors, each taking a different set of parameters. Is a Rect defined by 4 coordinates, or a point and 2 dimensions, or by 2 points, or by another Rect? You can define a constructor for each case.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Class Constructor questions
« Reply #2 on: February 29, 2016, 06:45:11 PM »
Thanks for the indepth reply, Hooman.

If there are no differences between structs and classes, why do you have to use a different method of initializing the variables? For structs, something as simple as  "Example x = {5, 5, 2} where x is an object of the struct Example" can be used to initialize the three member variables in a struct, but to do the same with a class, you need to use a constructor? Or am I missing something?

What about inheritance (ie class inheritance or struct inheritance)? Do both provide inheritance to childs in the same manner, or is there a difference where only specific things get inherited?
===================

Well what about leaving the member variables as public, but not visible to most people? What I mean by this is that the interface for a class will include the member functions and comments explaining how to use them properly, generally with pre/postconditions, while the implementation contains the member variables and the definitions for the member functions. If one left those member variables public within the implementation, essentially to anyone that didn't know how the implementation was made they wouldn't know if those variables were private or public and thus reduce the amount of chaos. In theory.

I ask because a hot topic of today's world is modding and making code moddable to create mods. Don't you have to make your member variables public OR have a friend function that can access those member variables that are private to allow for modding?

I also note that a friend function is basically useless if the member variables are public, as the friend function is a specially named function that can access and mutate the private member variables outside of the class.
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Class Constructor questions
« Reply #3 on: February 29, 2016, 07:34:52 PM »
Structs come from C. Classes are basically an extension to Struct.

Struct's are by definition public. Classes are by definition private.

Or something like that.

Basically, use a struct if you're not planning on adding any member functions. Otherwise use a class.

Declare all member variables private and provide access functions (getter/setter).

Sound to me like you may need to pick up a C++ book and do a bit of reading. Not so sound like I'm saying RTFM but... a good C++ book will answer all of these questions.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Class Constructor questions
« Reply #4 on: February 29, 2016, 11:46:12 PM »
Well, I clearly don't have a good C++ book. Though having tried multiple times to learn from it, I kind of knew that already. The book I'm using is an old C++ textbook from a first-year C++ course I took a while ago. It is confusing as hell as it doesn't explain a lot of things and focuses on certain topics in great detail (ie strings and arrays) but then barely covers other things (ie pointers and classes). Then again, it does however explain certain things better than online tutorials (ie procedural abstraction, abstract data types, separate compilation and namespaces) which is why I haven't discarded it and avoided it completely.

Are there any specific C++ books that you'd recommend, leeor_net? I've tried looking around for a C++ book, but the only ones I can usually find are either C++ textbooks (which are pricy as feck) or basic self-teaching C++ books that are about as useful as online tutorials. Hence why I'm asking the questions here. If I had a good C++ book to look up the majority of my questions that would be great and that way I can then ask more specific questions here, as you guys are very knowledgeable.
« Last Edit: February 29, 2016, 11:50:34 PM by lordpalandus »
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #5 on: March 01, 2016, 01:35:40 AM »
Quote
If there are no differences between structs and classes, why do you have to use a different method of initializing the variables? For structs, something as simple as  "Example x = {5, 5, 2} where x is an object of the struct Example" can be used to initialize the three member variables in a struct, but to do the same with a class, you need to use a constructor? Or am I missing something?

Why not try it both ways with both classes and structs and see what happens? Remember to use public in the class to keep things the same. Note that a constructor is more powerful than an initializer list for public members.

Inheritance works the same for both classes and structs. Inheritance is actually quite simple. Use the same memory layout as the parent, and extend it by adding new fields at the end. If there are virtual functions, use the same virtual function table layout as the parent and extend it by appending new virtual functions to the end, or overwriting the entries for overridden methods. I can provide more details if you'd like.


In the OP2 SDK header files, I left a few private details as public, just because we could. Since the code is already compiled and the source code is lost, there is little chance of the private details ever changing. I'm not sure it really helps modding. Modding is generally aided by being able to replace components, or insert new components. This is more about code structure, and support for hooks into the app being modded than by public/private access to data. In the case of Outpost 2, the game didn't ship with any header files, so it's essentially all private. That doesn't stop modding. Sometimes the code structure makes it difficult though.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Class Constructor questions
« Reply #6 on: March 01, 2016, 06:05:28 PM »
Teach yourself books is pretty much what you're going to be looking at BUT keep in mind that often times these books will have information and will go into detail that online tutorials don't go into. Additionally, I've found a lot of online tutorials either severely lacking or straight up wrong.

Textbooks for CompSci courses I've found... also lacking. They go almost into too much detail as it's more about learning the science of computer programming than it is practical application. Unless you're looking at inventing new algorithms and new approaches to solving problems, you'll be much more interested in how to practically apply what is learned via computer science.

These are the books I would highly recommend you look at:

Sams Teach Yourself C++

Effective C++ 3rd Edition

Effective Modern C++

This is one I've been meaning to read but never have so I can't personally vouch for it but chances are it will be very helpful. A lot of people don't like the STL but the STL provides a lot of extremely useful algorithms and containers that solve a lot of the problems that you may already be facing:

Effective STL
« Last Edit: March 01, 2016, 06:10:08 PM by leeor_net »

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Class Constructor questions
« Reply #7 on: March 01, 2016, 06:31:00 PM »
@Hooman; I'll have to try that out. Thanks for the information! Well for modding, what would you describe something like multitek.txt where you can modify values and those have an effect ingame? Aren't those values member variables of some class or they just regular variables? What do you mean by hooks in the code (I understand the concept, but have no idea how one would code a "hook" in); I ask because I'm very interested in making a game moddable as it really helps to extend the life of a game?

I do have another smaller question, that has bugged me for a while, that you could most likely answer. Why is it for classes and structs, it has a semicolon ";" at the end of the second brace "}", but for loops, functions, and if-else that also use the { and }, there is no semicolon (well, except the do while loop of course). I know that the ; is an executable statement and can actually exist on its own as a null statement (why one would do that is beyond me) so I know that it is saying that the }; is an executable statement. I just don't understand why it is there for structs/classes, but not other code that uses the { and }?

@leeor_net; Thanks for the book suggestions. I'll have to check if my local bookstore or library has any of them; if not, I'll have to look into ordering online.


Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #8 on: March 02, 2016, 12:25:59 PM »
Well for modding, what would you describe something like multitek.txt where you can modify values and those have an effect ingame? Aren't those values member variables of some class or they just regular variables?
That's a data file. How it gets loaded into memory and the structure of the program is a completely different question. I would choose to store the tech info as members of a struct (or class), and have an array of such structs. The tech data will be present throughout the level, and is of likely variable size, so it's more likely to be stored in a data structure on the heap, rather than local or global variables. Consider for a moment how you would store that data as non-member variables? It almost doesn't make sense when you consider how much data is being loaded. You would need a lot of variables to store that much data. Trying to store the data without a systematic way of putting it into data structures would be a nightmare.

Quote from: lordpalandus
What do you mean by hooks in the code (I understand the concept, but have no idea how one would code a "hook" in); I ask because I'm very interested in making a game moddable as it really helps to extend the life of a game?
Pointers.

It's very easy to replace a pointer. It could be a function pointer, or an object pointer. It can be a simple atomic memory write to replace an entire component of a game. The game might even be designed with extensibility in mind and allow for registration of event listeners. That might be implemented as having a method to add a pointer (to a function or an object) to a list of event listeners. When an event happens, all listeners are notified, either by calling the function, or calling a method on the object.

An important topic for this is interfaces. An interface as basically a class that contains no data members and only pure virtual functions. Another class then inherits from the interface and provides an implementation for those virtual functions, as well as defines the needed data members. Any class that implements the same interface can be used in place of any other class implementing that interface.

The COM (Component Object Model) documentation actually gives a very good description of interfaces, which are really at the core of COM. COM has been deprecated though, and all the other gory details outside of interfaces are not quite so useful now. The interface part is still quite useful and widely applicable. They are a fundamental programming concept. The rest, GUIDs, registration, instantiation, error handling, late binding, interprocess communication, and so on, not so much. Those are just the gory details of the COM implementation, which attempts to solve all kinds of problems you likely won't encounter.


As for the semicolon thing, well I suppose because that's simply how the grammar was defined. The semicolon ; is a statement terminator. The braces {} as used in an if/else statement, or a for loop, are a compound statement. The braces already implicitly terminate a compound statement, which grammatically groups a bunch of statements into one (compound) statement. Contrast it with an if/else statement that doesn't enclose the branches in a compound statement, and does need a semicolon to terminate the branch statements.

I guess one simple rule, is whether or not something can follow the close brace. For if/else and for loops, or function bodies, no there is nothing that can grammatically follow which applies to the brace block. For struct and class definitions, you can also declare a variable of that type at the same time, and so you need the semicolon to close it off. Similarly, a do/while loop has the post-test condition after the closing brace, and needs a semicolon.

As an exercise, try writing a double nested if/if/else with/without blocks and semicolons. Those semicolons can change the meaning of the code, possibly causing it to not compile.

Also as an exercise, try looking up the do/while(0) macro idiom, which wraps the contents of a macro into something statement like that must be semicolon terminated. It's important when trying to use some macros in the context of an if/else statement. The repercussions become clear after playing with the above exercise.
« Last Edit: March 02, 2016, 12:29:03 PM by Hooman »

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Class Constructor questions
« Reply #9 on: March 02, 2016, 01:01:38 PM »
Well as there is a fixed number of technologies (ie no Endless Tech like in Sid Meier's games) I could see just storing them in Arrays of Fixed Size. You know beforehand how many techs are available, and you know the values of those techs, so I'd think a fixed size Array or Multidimensional array should be sufficient. So no, I don't see the problem you are pointing to. Unless I'm missing something, each technology has a name that could be associated with a specific place in an array, and then you'd just fill out the numbers for that place in the array. When the game performs that tech, it finds the values at that specific point in the array and loads the research time, max scientists, etc... I personally don't see the problem that you are seeing. That may be because I'm a noob, but I feel you need to explain why it would be so hard to do just use fixed size arrays?

What is the heap? A term I keep seeing, but not sure what it is. I'm assuming it has to do with memory, but what, I dunno?

Thanks for the indepth reply again, Hooman.

LOL, I am actually modding a game that does use the COM implementation. I actually think that having those gory details for trying to solve problems is actually a good thing. I'd rather have an error report than just a simple CTD or game freeze. Much easier to find the problem that way too.

Okay, a better question with modding in mind. How can modding be supported without making the game unstable by having the presence of mods? I ask because a game like Fallout or Elder Scrolls gets more unstable as more mods are added. And as that is one of the big games for offering modding support, how does one avoid game instability with added mods. Generally if mods conflict or lack dependencies the game crashes to desktop immediately, but why do the mods cause instability otherwise?
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1267
Re: Class Constructor questions
« Reply #10 on: March 02, 2016, 04:28:46 PM »
Okay, a better question with modding in mind. How can modding be supported without making the game unstable by having the presence of mods? I ask because a game like Fallout or Elder Scrolls gets more unstable as more mods are added. And as that is one of the big games for offering modding support, how does one avoid game instability with added mods. Generally if mods conflict or lack dependencies the game crashes to desktop immediately, but why do the mods cause instability otherwise?
That's largely due to their sloppy plugin loader implementation which has always (ever since TES3) required third party workarounds like merged patches made with e.g. Wrye Mash or TES5Edit, mod load order sorting utilities like BOSS, etc. Mods introducing tons of extra global scripts can potentially cause issues, changing vanilla scripts can possibly break things, and with the complex open world environments of those games it can be hard to test for all the edge cases. Probably the biggest thing to worry about here is extra memory use, as the game will crash if it exceeds 4 GB (or 2.5 GB pre-TES5 without using a 4 GB LARGEADDRESSAWARE flag patcher). I've played extremely heavily modded Skyrim and it was pretty stable, but you have to jump through the hoops of making a merged patch and properly sorting the mod load order to get it that way.
Typical Bethesda modding (as in mod plugins) has nothing to do with inserting code hooks. On the other hand, the way Skyrim Script Extender (and its equivalents for the other Bethesda games) is implemented makes heavy use of code hooks, as that's the only way to extend the capabilities of things that are hard coded.
« Last Edit: March 02, 2016, 04:31:04 PM by Arklon »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #11 on: March 03, 2016, 12:02:30 AM »
You could use a fixed sized array, yes, but it's a bad solution. One of the reasons why, is because it limits modding. By fixing the array size up front, you've imposed a limit on all future mods that can be written.

I guess a question to ask here, is what does fixing the size get you? That you can store the data globally, on locally?

I don't think storing fixed array of tech data locally makes sense due to visibility reasons. Sure you could have a function with a large local array for tech data, load it, and then call functions to initialize and play the game, passing a pointer to the array, but that's a bit of an awkward structure, especially when you consider message handling and how the user interface interacts with the game. You'd need the message pump for the game in one of the called functions, but you'd have needed a message pump earlier to get to a point where a level is chosen and a tech tree is loaded.

Having global access to tech data seems to make some sense, even though programmers generally try to avoid globals as much as possible. They're harder to debug when there are problems. They also lead to a less encapsulated design. A tech tree is a fairly isolated component though, so it's not a terrible choice. There isn't really a whole lot of difference between storing the data globally in a fixed array, or having a global pointer to an array of dynamic sized data.

At any rate, the original question was about member variables or regular variables. If you're using an array, it makes the most sense to have an array of structs, in which case the data is stored in member variables of those structs. This is independent of where the data is stored. An array of structs is still an array of structs whether it's stored globally, on the stack, or on the heap.


The heap is an area of memory used for dynamic memory allocation. All the non-fixed size stuff goes there, as well as any data whose lifetime is not global or static and not tied to the lifetime of a function. It's where the memory for malloc/free or new/delete comes from. There is also a heap data structure, which can be used to manage dynamic blocks of memory (among other things), although there is no requirement that dynamic memory is managed with a heap data structure. Still, it's common to refer to dynamic memory as the heap.


I tend to feel the gory details of COM lead to more problems than they solve. For most programs, the flexibility of COM is not needed. Most objects are used in-process, so out-of-process support, marshalling of data, and the error code return values are all unneeded work and complication for the vast majority of programs. It also complicates error reporting quite considerably, and really doesn't lead to better error messages.

As for stability, that's always a potential issue for in-process mods. If mod code is running inside your process, it's essentially indistinguishable from the original process, so any flaws in the mod code can cause the whole process to crash. There are ways to sandbox things, but that's a whole other topic. Sandboxing is easier when there is minimal interaction between components. Think of a web browser with tabs. Chrome uses a different process for each tab to keep them isolated. Each tab is essentially another instance of the program. This can improve stability, but it's also useful for security, as the tabs are not supposed to talk to each other. This is somewhat contrary to mods where you do want interaction.

For proper isolation of mods, (assuming native code) you'll need some kind of inter-process communication mechanism. As just stated, yes, such a mechanism is available from COM, but I'm not sure if it was ever the best solution. Plus, COM is now deprecated. That and it would also tie your code to the Windows platform.


If you want mods, learn about interfaces. If you want stability, learn about sandboxing. If you want sandboxing with native code, learn about interprocess communication. You can also do sandboxing with scripting languages or similar that can offer greater guarantees, without having to resort to separate processes.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Class Constructor questions
« Reply #12 on: March 03, 2016, 02:09:19 AM »
Good point well made. Yah, a fixed array would make things very difficult for modding.

Wouldn't an array of structs suffer from the same problem as an array of fixed size? Or is an array of structs a vector?

Yes, I have noticed the textbook and tutorials saying to avoid global variables as much as possible due to the problem that since it can be used in multiple areas, it might cause a problem in one area of the code base but cause no problem in another area of the code base. Most of the time "they" suggest to have a locally declared variable that stores the value that a global might so that it is easier to debug.

Oh that thing. The freestore (the term the textbook uses and the term I see more frequently on tutorials) is another word for the heap... right? Or is the freestore something else?

Terrible error messages... *cough* Error 37 *cough*

Okay, when I next do more C++ learning I'll likely take a look into interfaces, sandboxing, and interprocess communication. Right now I'm focusing on learning UE4 to make a simple RTS, but after I succeed (or fail) at trying to do that I plan on doing more C++ learning. Right now, I understand enough of it to know how to crudely use classes, structs, functions, function definitions, loops, if-else, etc... which should be sufficient for making something simple, but it won't be sufficient if I want to make a more complex RTS.
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #13 on: March 03, 2016, 04:59:20 AM »
An array of stucts might be fixed sized or dynamic sized. The struct is the element type, not something to do with the size or dimension.
Code: [Select]
struct TechInfo
{
  int techId;
  int category;
  int lab;
  int cost;
  // ...
};

TechInfo fixedArray[1024];
TechInfo *dynamicArray = new TechInfo[size];

A vector is a templated class, which is intended to work as a safe array. This is much like how pointers get wrapped into template classes known as smart pointers. Vectors are intended to allow for easy resizing and protect against out of bounds access (sometimes).

The freestore is the heap. That's probably a better name for it actually. Freestore is more descriptive of its use, while heap is a typical implementation detail.

COM can produce such wonderful error return codes as 8877010e. I'd say that's even worse than Error 37. You'd have to break the COM error codes into bit fields, and then look up each field. With Error 37, that's just a single table lookup. That isn't nearly so bad.


If I were you, just stick with interfaces, and forget about the other topics for now. Interfaces alone can take a while to get, and will be immediately useful. Interfaces allow you to do new things, and express other things more simply and cleanly. The other topics are more about doing the same thing you already know how to do, but with greater stability guarantees. You can leave such things for later, when you actually have something to mod, and you're encountering stability problems.

Btw, learning low level details of how interfaces work will teach you a great deal about how classes and structs work. Indeed, an interface is just a class with restrictions imposed on it.

Interfaces are also quite important for UI work, and things like unit hierarchies for games.
« Last Edit: March 03, 2016, 05:12:10 AM by Hooman »

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Class Constructor questions
« Reply #14 on: March 15, 2016, 03:50:59 PM »
Quote
but it won't be sufficient if I want to make a more complex RTS

-smh-

It won't be sufficient for building an RTS period. I mean, I suppose you could but you'd probably end up with something like StarCraft (read the post mortems on StarCraft... it's a wonder the game runs at all let alone put Blizzard on the map).

You really need to start thinking smaller. RTS may be the goal but you're never going to reach it until you've learned the basics of how these things work together and the basics of game development.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #15 on: March 16, 2016, 12:54:08 AM »
I've heard of a book titled "The Magic of Thinking Big", so who knows. I haven't read the book, but from what I understand of the premise, having a big important project can be more motivating.

As long as you're learning and progressing on something, that's the important part. I generally like to think of small problems that are immediately actionable, but it's also nice when that small problem fits inside some larger purpose.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Class Constructor questions
« Reply #16 on: March 16, 2016, 03:14:18 PM »
Hooman, there's also the problem of thinking too big. Lordpalandus, this is not me attacking you, I'm paraphrasing what someone else said (you seem to have a better grasp on reality than they did.)

Quote
I'm going to make a new Outpost using Unity! Then I'm going to sell it and we'll all make a lot of money! And I know what I'm talking about because I made a mod for StarCraft 2 and it was 30,000 lines of code! -squee-

Child, sit down and shut up. 30,000 lines of code is a joke. I can do that in about an hour if I really put my mind to it. Hell, NAS2D is 30,000 lines of code. You built your mod using a game engine THAT WAS ALREADY FINISHED.

In this case, it's a matter of setting realistic goals. They don't have to be tiny baby steps, that may not accomplish anything, and you don't need to be a C++ guru to program a game (Hell, again, look at the StarCraft post mortem, that code base was a friggin disaster). But still need to be within reason.

AAA RTS modern engine in a year with someone who's never completed any game of any sorts is thinking too big.

Having a small RTS prototype using UE4 within a year... that's reasonable. And I think very doable though with limited experience can be very challenging.
« Last Edit: March 16, 2016, 03:59:26 PM by leeor_net »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #17 on: March 17, 2016, 02:42:28 AM »
I once knew a megalomaniac in high school that was intent on taking over the world. He once said something that kind of stuck with me:
"I'd rather have delusions of grandeur than delusions of adequacy"

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Class Constructor questions
« Reply #18 on: March 17, 2016, 03:36:34 PM »
Why have delusions at all when you can live in reality?

Funny thing... a lot of people thought I wanted to take over the world. I was voted most likely to do so.

Reality is... I'd be more likely to hit the reset button and liquify the surface of the planet than anything else.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Class Constructor questions
« Reply #19 on: March 17, 2016, 05:42:03 PM »
@leeor_net and Hooman;
Yes I did read that post (I think on Polygon?) several months... or was it a year ago... can't remember. Anyway, starcraft was a trainwreck of code barely held together that somehow worked and somehow made them successful.

Yes, as I'm working on a very simplistic RTS (if you could it even that) I'm realizing that even getting an AI to do what one thinks is a simple task (ie send units to enemy base), is actually a huge number of steps, which has resulted in me focusing more on the base building aspects rather than AI right now. AI is giving me a headache, so my initial prototype won't include it. I feel even getting the basics of base building (ie gather resources, spend resources, build structures, sell structures and repair structures) to work is sufficiently complicated a task for me right now. I've tried to break my tasks down to a simple enough level that they are actionable and that I can write up a procedure of steps in English and convert those steps into code, graphics, and sound. My first prototype may not be much to look at or won't have "gameplay (as most people understand it)" but it will do want I want it to do, which is be a stepping stone to other things.

I feel there is nothing wrong in thinking big. Just use "Top-Down" design to break your big dreams into small enough SMART goals or steps that are actionable and doable. If you can't break your big dream down into the small steps needed to complete it then yes, you are a dreamer without any concept of the difficulties in implementing it in reality. However, I would say that those who can break up their big dreams into the necessary steps to complete them, CAN make those dreams a reality. All the major leaders in science, philosophy, politics, etc... who could dream big and turn those dreams into reality knew how to break their big dreams up into small enough actionable steps. I'm realizing more and more the difficulties in breaking things down into small enough actionable steps, but I'm figuring out how to do it and things are starting to come together.

The problem I'd say isn't that thinking TOO BIG is the problem. I'd say not knowing how to break down something into actionable steps is the problem. If you don't know how to break something down into actionable steps, it doesn't matter how big it is, as you won't accomplish anything anyway. It comes down to a matter of problem solving, adaptation, a desire to seek success, a desire to learn and the ability to break big things apart into smaller things into you have small enough things that can be built individually and then put together later.

Finally, those who wish to live in reality don't dream don't adapt and don't play video games :P

If you pressed the reset button and killed off the entire planet, you would rule the world, as you'd be the only one left. XD
« Last Edit: March 17, 2016, 05:47:19 PM by lordpalandus »
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Class Constructor questions
« Reply #20 on: September 30, 2016, 10:17:37 AM »
Quote
Finally, those who wish to live in reality don't dream don't adapt and don't play video games :P

Living in reality simply means I know my limits, I know my skills and I know what's doable and what's fantasy.

Quote
If you pressed the reset button and killed off the entire planet, you would rule the world, as you'd be the only one left. XD

No no, I'd be killed too. And that would be the point.

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Class Constructor questions
« Reply #21 on: September 30, 2016, 05:47:33 PM »
Depends where the Reset switch is :P

There was this Outer Limits episode where all the world's nukes detonation was tied to these dead mans buttons. If they didn't hit the buttons in time all the nukes would go off. And the people in charge of those buttons were about 2 km below the surface. If they don't press those buttons, world goes boom. They were called Dead mans switches as if they died, then no one could activate the buttons and the world would go boom.

Not quite the same, but still, the person touching the reset button doesn't necessarily have to die after pressing it.
« Last Edit: September 30, 2016, 05:50:11 PM by lordpalandus »
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Class Constructor questions
« Reply #22 on: October 02, 2016, 11:34:27 AM »
I remember that episode. That was a fun one.  An alien race was on their way, and should they have intentions to destroy or enslave Earth, a doomsday device was generated. If people weren't kept alive and free, continually deactivating the system, the world would be destroyed, rendering it unsuitable for the aliens. The ploy was to disincentivize enslaving humanity, or killing people off just to have a resource rich world to colonize.

Quote
Living in reality simply means I know my limits, I know my skills and I know what's doable and what's fantasy.
Do you really know your limits leeor_net? Do you really know your ... outer limits?  :D


As for what they should really have done for that dead man's switch, please see Red vs Blue: The Joy of Toggling. That might be a little more failsafe.  ;)