@Ell The more important question is: Do I feel like spending my precious free time by listening to your problems?:) Try me, maybe it's an interesting problem. But please don't be offended when I prefer to go to bed. It's 10pm here and I've had a long and quite, erm, interesting day.
Also, it seems wrong from a design POV to have monsters have a coordinate attribute. The room I'm currently in is not some property of me, like my sex or the color of my eyes.
@sbi so then how do I change the key of the mappedtype from a function inside mappedtype, where there is no access to the map
and I would argue that the room you're in is a property of you, why wouldnt it? if you can change it - by walking into a different room - why isnt it a property?
@Ell When I am moving from one room of my apartment to another, I am changing the properties of those rooms ("room is now empty", "someone is in this room now"). I can do this myself because I have access to the apartment. I know its layout, I can even change it ("grab that end of the couch, please, we're carrying it to the next room").
@Ell If the objects in your game have a position attribute, you don't need that map representing the space. You could just iterate over all the objects, check their coordinates, and display them at the right place.
However, then it would be hard to find out if any object is at a specific location, because you'd have to enumerate the list of objects. So I think it makes more sense to have a data structure that represents the game's space and position the objects in there.
@Ell In order to move something from one coordinate to another, the entity doing the moving, be it an algorithm in the object's class or somewhere else, needs access to the coordinates.
IMO updating the game should be done from a function that's part of the game. It might delegate the algorithmic work to decide which way an object will move to a member function in the object's class, but then it needs to pass all necessary information (like a callback "call this if you want to know whether a direction is currently possible") to that member function.
IIRC, when I made a game like this, an object's update() function would only decide whether the object would want to go up, down, left, or right. It would then call back (into the map, ultimately, but it wouldn't know that) to ask whether it could go there. If not, it would pick another direction.
@Ell It's one design goal to put the knowledge about an object, including its movement pattern, into the object itself. Another, conflicting POV, however, is the pawn-player model: A player moves the pawn. A perfect design would, IMO, combine these two conflicting goals. A pawn doesn't moves on itself, it is moved. However, how it moves is encoded in it being a pawn, and it would be nice to store this in the object.
In an ideal design, the pawn wouldn't even know there's a chessboard. All it knows is that it would like to go, erm, "up", or, if for some reason that isn't allowed, it might prefer to go "right", etc.
@Ell Have you ever tried to play one of those chess games where humans are used as chess pieces on a big "board"? Those humans do not act autonomously, they are directed by two players. The reason is that 1) you need a centralized intelligence, and 2) you don't have an overview of the board when you're on it.
@Ell I suppose it would. I'm hazy on their rules, though.
@Ell I dunno. But how is that relevant? Most programmers prefer Java to C++. Does that make them right? :)
Can I achieve the same effects without the C++ header <initializer_list>?
Does class initializer_list have to live in namespace std (does the compiler require this)?
I'm fine with a solution that works on the big five (GCC, MSVC, Intel, Clang, Comeau)
for struct A { A(int, string, tuple<int, bool>); } we can say A a = { 1, "foo", { 42, true } }; and that's perfectly fine. no initializer_list<> anywhere.
@JohannesSchaublitb ouah's comment covers the case for integers. It "looked" like your comment also included "all data type" which would imply floating-point as well? Then you deleted it.
hmm tdm-gcc says "It combines the most recent stable release of the GCC toolset with the free and open-source MinGW or MinGW-w64 runtime APIs to create a LIBRE alternative to Microsoft's compiler and platform SDK."
@StackedCrooked: yeah more often you send in complete patches, which gp unanswered for about a year, until all at once they turn up in the changelist and you don't get credited ;)
I am looking for an optimal pattern for partial re-initialization of a C++ object.
With partial re-initialization I mean that some members (step_param in the code example) need to keep its values and other members (value in the code example) are re-init'ed.
Important point: The bloat and red...
In computer science, an abstract syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it does not represent every detail that appears in the real syntax. For instance, grouping parentheses are implicit in the tree structure, and a syntactic construct such as an if-condition-then expression may be denoted by a single node with two branches.
This makes abstract syntax trees diff...
@unNaturhal use google docs drawing, and make a picture of the structure of 2+3*4
there are many ways to depict it
one is as the usual tree with root in the air
the convention with root in the air wasn't introduced until the early 1970's, though, so you might choose to draw it with the root down (as Donald Knuth did originally)
or you can draw it as circles within circles. the biggest circle is the full expression.
or you can draw it like the DOS tree command's output.
which is pretty much like the folder list in the left pane of any Explorer-like GUI shell
Yes but... There are too many difference between what you say and what is written on my book. It makes an example of parse tree that is totally different by what you explained