Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 314 315 [316] 317 318 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 907304 times)

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4725 on: July 23, 2013, 11:04:34 am »

If you want to stick with maps, you could use a std::multimap, and use the node as the key.
And that wouldn't even make sense, because I only stick nodes in the priority queue twice because it would take too long to find the first copy of the node again.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4726 on: July 23, 2013, 11:34:46 am »

Quote
gradients
I thought of that, too, but I have too many ports. Something like 150.

Quote
priority_queue
Yeah, think I always remove the node to inspect it anyways, so it won't matter greatly.

Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4727 on: July 23, 2013, 01:22:00 pm »

Quote
priority_queue
Yeah, think I always remove the node to inspect it anyways, so it won't matter greatly.
No, the priority_queue is the openset, and if you remove and inspect one, it goes into the closedset. And if you inspect a node, you don't update its own f_value, but the f_values of the neighboring nodes.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4728 on: July 23, 2013, 04:49:57 pm »

My eyes have been looking at this project too long. I can't find the source of the undefined reference errors. Help, please.

Also I know I'm probably doing everything in the worst way possible, but my goal is to get something *working* first, and I have a roadmap for that.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4729 on: July 23, 2013, 04:55:22 pm »

My eyes have been looking at this project too long. I can't find the source of the undefined reference errors. Help, please.

Also I know I'm probably doing everything in the worst way possible, but my goal is to get something *working* first, and I have a roadmap for that.
Can I have an errorlog please?
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4730 on: July 23, 2013, 05:07:51 pm »

It's on my clipboard. I forgot to add it to the post. /me facepalms

Code: [Select]
/tmp/ccqxHCBt.o: In function `ZN3Foo7objnameEv':
/home/Mego/Reflect/main.cpp:10: undefined reference to `Reflect::Member<std::string>::getdata() const'
/tmp/ccYFiwQc.o: In function `ZN7Reflect11ReflectBaseC2ESs':
/home/Mego/Reflect/ReflectBase.cpp:6: undefined reference to `Reflect::Member<std::string>::Member(std::string, Reflect::ReflectBase*, std::string)'
/home/Mego/Reflect/ReflectBase.cpp:6: undefined reference to `Reflect::Member<std::string>::~Member()'
/tmp/ccYFiwQc.o: In function `ZN7Reflect11ReflectBaseD2Ev':
/home/Mego/Reflect/ReflectBase.cpp:12: undefined reference to `Reflect::Member<std::string>::getdata() const'
/home/Mego/Reflect/ReflectBase.cpp:11: undefined reference to `Reflect::Member<std::string>::~Member()'
/home/Mego/Reflect/ReflectBase.cpp:11: undefined reference to `Reflect::Member<std::string>::~Member()'
/tmp/ccYFiwQc.o: In function `ZNK7Reflect11ReflectBase7objnameEv':
/home/Mego/Reflect/ReflectBase.cpp:16: undefined reference to `Reflect::Member<std::string>::getdata() const'
collect2: error: ld returned 1 exit status

olemars

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4731 on: July 23, 2013, 05:32:41 pm »

Template function definitions in a cpp file, probably. Noone told you templates are Satan's offspring?
« Last Edit: July 23, 2013, 05:37:07 pm by olemars »
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4732 on: July 23, 2013, 08:37:15 pm »

Magma: Okay then, missed your edit. So if I should use a heap, would make_heap suffice, on a vector? In that case, how would I cross reference it to a map without having to remake the whole heap each time...? References definitely will break, while iterators could break.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4733 on: July 23, 2013, 09:05:42 pm »

Magma: Okay then, missed your edit. So if I should use a heap, would make_heap suffice, on a vector? In that case, how would I cross reference it to a map without having to remake the whole heap each time...? References definitely will break, while iterators could break.
If you want to cross-reference the heap with a map, you'd need a full-featured heap with map coordinates as data keys and the f_value as priority, and you'd need to synchronize the heap with a map that stores the heap index of every node in the corresponding node field, which means that every addKey(), siftUp() or popFirst() operation on the heap needs to update the map as well. You'd need to write the entire data structure from scratch.

This would allow you to quickly (O(1) quickly) find an element in a heap and update its f_value, but given the nature of your data, it seems that this is actually not really worth the effort. What I'd suggest you do instead (and this is probably even faster than the other method) is just store all your f_values in a heap<pair<f_value, coordinates> > with the possibility of duplicate entries. You'll need a map<coordinates, f_value> to avoid putting too many duplicates of nodes into the heap (you only want to add to the heap when your f_value is a new minimum), and a map<coordinates, bool> to flag a node as belonging to the closed_set when you first pull it out of the heap, which allows you to ignore all further occurrences of the node in the heap.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4734 on: July 23, 2013, 10:53:55 pm »

Template function definitions in a cpp file, probably. Noone told you templates are Satan's offspring?

I made a pact in order for this to work, so that shouldn't be an issue. What's wrong with template function definitions in a cpp file that could cause undefined reference errors?

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4735 on: July 24, 2013, 12:30:32 am »

Magma: Okay then, missed your edit. So if I should use a heap, would make_heap suffice, on a vector? In that case, how would I cross reference it to a map without having to remake the whole heap each time...? References definitely will break, while iterators could break.
If you want to cross-reference the heap with a map, you'd need a full-featured heap with map coordinates as data keys and the f_value as priority, and you'd need to synchronize the heap with a map that stores the heap index of every node in the corresponding node field, which means that every addKey(), siftUp() or popFirst() operation on the heap needs to update the map as well. You'd need to write the entire data structure from scratch.

This would allow you to quickly (O(1) quickly) find an element in a heap and update its f_value, but given the nature of your data, it seems that this is actually not really worth the effort. What I'd suggest you do instead (and this is probably even faster than the other method) is just store all your f_values in a heap<pair<f_value, coordinates> > with the possibility of duplicate entries. You'll need a map<coordinates, f_value> to avoid putting too many duplicates of nodes into the heap (you only want to add to the heap when your f_value is a new minimum), and a map<coordinates, bool> to flag a node as belonging to the closed_set when you first pull it out of the heap, which allows you to ignore all further occurrences of the node in the heap.
This data structure thingy sounds out of my league. D: Not only do I not know how to code a heap from scratch, I also don't know the rationale for those choices you outlined...

I think I need to think about this a bit. =~=
« Last Edit: July 24, 2013, 12:34:34 am by Skyrunner »
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

gigaraptor487

  • Bay Watcher
  • Escaped Lunatic now civilised
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4736 on: July 24, 2013, 03:26:37 am »

if anybody is interested in a game jam there is a week long one in august on gamedev.net

http://www.gamedev.net/topic/645699-upcoming-unofficial-gamedev-competition/
Logged
Hehe, you thought there would be an interesting sig here

I now run a program which brings old multiplayer games back to life : click

olemars

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4737 on: July 24, 2013, 03:10:23 pm »

Template function definitions in a cpp file, probably. Noone told you templates are Satan's offspring?

I made a pact in order for this to work, so that shouldn't be an issue. What's wrong with template function definitions in a cpp file that could cause undefined reference errors?

Template functions are generated as needed per compilation unit (based on the template function definition), and you include the header so the places which would trigger the template can't actually see the template definition. I've seen various workarounds for this, most of them causing tears of blood like including the cpp instead of/as well as the header. The lesser evil is to move the definitions to the header.

edt: Explained in a vitriolic manner here. Read it, all of it. Especially 35.13.
« Last Edit: July 24, 2013, 03:16:28 pm by olemars »
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4738 on: July 24, 2013, 03:24:23 pm »

I have an idea for a program/game/sim that no one has done before as far as I can tell. No amount of googling has shown even a single prior reference for something even remotely like it. As this may be my very first truly original idea that I can capitalize on... i wont be sharing it until it can be demo'd.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4739 on: July 24, 2013, 03:26:22 pm »

Not publically, maybe. But I'd recommend sharing it with SOMEONE you trust before going through all the work of a demo.
Logged
Pages: 1 ... 314 315 [316] 317 318 ... 796