--- Log opened Thu Jun 18 00:00:00 2009 |
00:01 | | SmithKurosaki [~Smith@Nightstar-6508.dsl.teksavvy.com] has joined #code |
00:01 | | mode/#code [+o SmithKurosaki] by ChanServ |
00:11 | <@Derakon> | Hm. The pre-collision update code for TerrestrialObjects is 81 lines long. ¬.¬ |
00:11 | <@Derakon> | (Counting comments) |
00:11 | <@Derakon> | And I haven't even added crawling or turnaround animations. |
00:11 | <@Derakon> | At least it's usable by other objects than the player. |
00:12 | <@Derakon> | (Player logic is currently 51 lines for the entire file, which is basically all input handling) |
01:48 | | Doctor_Nick [~nick@Nightstar-7517.tampfl.dsl-w.verizon.net] has quit [Ping Timeout] |
01:58 | | Doctor_Nick [~nick@Nightstar-7517.tampfl.dsl-w.verizon.net] has joined #code |
01:58 | | mode/#code [+o Doctor_Nick] by ChanServ |
02:18 | | S_Kurosaki [~Smith@Nightstar-7213.cpe.net.cable.rogers.com] has joined #code |
02:21 | | SmithKurosaki [~Smith@Nightstar-6508.dsl.teksavvy.com] has quit [Client exited] |
02:21 | | S_Kurosaki is now known as SmithKurosaki |
02:26 | | gnolam [lenin@Nightstar-1382.A163.priv.bahnhof.se] has quit [Quit: Z?] |
02:33 | | SmithK [~Smith@Nightstar-6508.dsl.teksavvy.com] has joined #code |
03:54 | | Thaqui [~Thaqui@121.98.166.ns-22683] has joined #code |
03:54 | | mode/#code [+o Thaqui] by ChanServ |
04:02 | <@Derakon> | Well. Adding climbing back in was surprisingly trivial. |
04:02 | <@Derakon> | Just set a "justStartedClimbing" flag so I know to set the animation, and then handle completing it. |
04:23 | <@Derakon> | Whoops. http://derakon.dyndns.org/~chriswei/games/jbrl/collision/player12.gif |
04:24 | < Vornicus> | Whups. |
04:38 | <@Derakon> | Okay, now that test is successfully forcing the player into a crawl...after one frame of showing the player standing. >.< |
04:38 | < SmithKurosaki> | Is that a good thing |
04:39 | <@Derakon> | It's good that the player is forced to crawl. It's bad that they're drawn as not crawling. |
04:39 | < SmithKurosaki> | So you see half the corpse |
04:40 | <@Derakon> | Nominally the player is, in fact, alive. Undead players are a version 3.0 feature. ¬.¬ |
04:41 | < SmithKurosaki> | Well I am presuming that either a) any real person is a phaser or dead or b) they will soon be a corpse |
04:52 | <@Derakon> | Right, that's done it! |
04:52 | <@Derakon> | I hereby declare refactoring of the Player class complete. |
04:59 | < SmithKurosaki> | Time to pary |
05:00 | < SmithKurosaki> | Time to party? |
05:00 | <@Consul> | Time to dodge? |
05:02 | <@Consul> | I almost said "time to thrust" but that one goes with "time to party." :-P |
05:02 | < SmithKurosaki> | :p |
05:02 | <@Consul> | Anyway, sorry to chat and run, but it's bedtime for me. Night! |
05:05 | <@Derakon> | Night, Consul. |
05:05 | < SmithKurosaki> | Night |
05:09 | < Alek> | night for me too |
05:09 | < Alek> | oh and say hi to TF. |
05:09 | < Alek> | since currently you're more active than he is. :P |
05:09 | <@ToxicFrog> | Consider me said hi to. |
05:10 | < SmithKurosaki> | night |
05:14 | < Alek> | lol |
05:40 | | mode/#code [+o SmithKurosaki] by ChanServ |
05:41 | <@SmithKurosaki> | Sweet it works! |
05:41 | | * Reiver curses. |
05:41 | | * Vornicus finds himself stuck as to basic design for Vornball. |
05:41 | < Reiver> | McMartin, you there? I could do with a little Haskell/Theoretical Explanation help. |
05:41 | < Reiver> | I've been stumped by something all day. :/ |
05:42 | <@SmithKurosaki> | Vornicus: are you talking graphics, UI? |
05:42 | < Vornicus> | No, I'm talking the back end. |
05:42 | <@SmithKurosaki> | Ahh, I wish I could help, but sadly, I don't think I am hardcore enough yet |
05:43 | < Vornicus> | What I should really do is sit down with a design patterns book and a notebook and just draw for a while, but I don't actually have a design patterns book. |
05:44 | <@SmithKurosaki> | I am pretty good at coming up with random ideas. Can you give me details and what you are trying to design. If I can't help, I'm sure someone else in the chan can :) |
05:47 | < Vornicus> | It also doesn't help that I've never actually written a time-sensitive event loop before. |
05:48 | <@SmithKurosaki> | Ahh, I haven't either. Sorry |
05:48 | | * Vornicus therefore has to poke somebody who has some idea what's going on. Namely: McM and Der. |
05:48 | <@Derakon> | You want help with, what, your basic main loop? |
05:49 | < Vornicus> | Essentially, yes. |
05:50 | | * Derakon pastes JBRL's game loop here: http://paste.ubuntu.com/198187/ |
05:50 | <@Derakon> | This is overcomplicated to start, but you can see the overall structure. |
05:50 | <@Derakon> | while 1: process input; update physics; draw; sleep; |
05:51 | | * Derakon eyes line 22, fixes to be non-idiotic. |
05:51 | < Vornicus> | Okay, what I'm /really/ looking for is processEvents() |
05:51 | <@Derakon> | Ah hah. |
05:52 | <@Derakon> | http://paste.ubuntu.com/198189/ |
05:53 | <@Derakon> | The theory here is that eventually I will add events that are things like "User clicked on this button", hence the UIElements and context variables; for now, though, it's just straight PyGame input. |
05:53 | < Vornicus> | aha! |
05:53 | < Vornicus> | pygame.event.get() does what I am looking for then. |
05:53 | <@Derakon> | You should probably just translate event.key (which is things like "K_UP", "K_LEFT", "K_a", etc.) into actions. |
05:53 | <@Derakon> | Yes. |
05:54 | <@Derakon> | (Er, not the string K_LEFT, but the identifier K_LEFT, which is in the root pygame namespace. |
05:54 | <@Derakon> | ) |
06:02 | < Vornicus> | 1 / float(constants.physicsUpdatesPerSecond) * 1000 <---> 1000 / float(constants.physicsupdatespersecond) |
06:02 | <@Derakon> | Er, yes. |
06:03 | <@Derakon> | In fact, 1000.0 / constants.physicsUpdatesPerSecond |
06:03 | < Vornicus> | Slightly faster, more obvious, and -- yes, do that, even. |
06:03 | | * Vornicus has found himself always using from __future__ import division lately. |
06:05 | | Syloqs-AFH [Syloq@ServicesAdmin.Nightstar.Net] has quit [Connection reset by peer] |
06:11 | <@Derakon> | This is in fact one of the reasons I'm looking to open-source JBRL; one set of eyes means stupid mistakes. |
06:12 | <@SmithKurosaki> | I really wish I understood what you guys were talking about |
06:12 | <@Derakon> | You can learn. |
06:12 | <@SmithKurosaki> | I'm slowly working on it, TF is a lot of help :) |
06:12 | < Vornicus> | SmithKurosaki: I was, at first, trying to figure out how to grab a bunch of events at once from the event queue - the thing that has stuff like keypresses and mouse movement in it. |
06:13 | <@SmithKurosaki> | Right. I followed that. Once the actual code came out I was getting confused |
06:13 | < Vornicus> | All my old code uses poll(), which grabs the oldest event I haven't looked at (if an event exists; it may not) |
06:14 | < Vornicus> | Der's code is a horror even to /me/, and I suspect also to him. |
06:14 | <@SmithKurosaki> | Poor Derakon |
06:14 | < Vornicus> | I looked at it and said "Okay, the thing I need happens in processEvents()" because I saw that that's where he was getting his events from. |
06:14 | <@Derakon> | It is, fortunately, a horror that I don't have to look at very often. |
06:15 | <@SmithKurosaki> | Well, that's good for your sanity isn't it? |
06:15 | < Vornicus> | So I had him paste the code in processEvents, I looked at that, smacked my forehead, and thanked Der. |
06:16 | < Vornicus> | He mentioned that he has in-game actions (like "move left") and out-of-game actions (like "quit") and that processevents dispatches the out-of-game actions itself before passing in-game actions to the game loop. |
06:17 | < Vornicus> | (the game loop does the stuff like "make mario jump" and "show mario jumping") |
06:17 | <@SmithKurosaki> | Ahh so the out-of-game loop has to be checked before and after events occur? |
06:18 | < Vornicus> | Well, sort of. |
06:18 | <@Derakon> | Pygame accumulates events, which are basically any input that the player or the operating system has that the program can know about. |
06:18 | <@Derakon> | It puts them all into a queue. |
06:19 | <@Derakon> | You have to empty the queue out regularly, or your program is assumed to be nonresponsive. |
06:19 | <@Derakon> | Some of these events are relevant to playing the game -- things like hitting arrow keys. |
06:19 | <@Derakon> | Some of them are relevant to program control, like the QUIT event. |
06:19 | < Vornicus> | Anyway after we talked about that, he mentioned what I should do - I'm actually not going to follow that advice because what I /really/ need is to go "Okay, the <- key is down now, so I need to make a note of that" because it doesn't give me events that say "the <- key is still down!" |
06:19 | <@Derakon> | All of them should be handled appropriately, and ideally with a well-designed program. |
06:20 | <@Derakon> | Ahh, Vorn. A moment. |
06:20 | < Vornicus> | Which actually isn't hard - I imagine Der is about to dump another horror onto me. |
06:20 | <@Derakon> | It's not so bad. http://paste.ubuntu.com/198206/ |
06:21 | < Vornicus> | Nope, that one's not bad. |
06:22 | <@Derakon> | 'key' is, again, a PyGame key identifier. I'm not certain why I'm casting it to an int there. |
06:24 | < Vornicus> | Then after /that/ we talked about statement clarity. |
06:27 | < Vornicus> | 1000.0 / constants.physicsUpdatesPerSecond is 1. clearer, 2. less likely to go wahooni-shaped in the case of accidentally stomping the float() function (which I haven't done to that one, but others yes), and 3. slightly faster. |
06:28 | <@Derakon> | (Ahh, I'm casting to an int because I didn't bother to cast to an int when I load config from file. Stupid of me. Better to do it once per game than once per function call.) |
06:30 | <@SmithKurosaki> | Ok, I have no python experience, but I do now understand the intent of the code. Thanks :) |
06:30 | < Vornicus> | oh /look/, the other thing I thought I needed to write. |
06:30 | <@Derakon> | Already done by PyGame? |
06:31 | < Vornicus> | Yes. |
06:31 | <@Derakon> | <3 PyGame, seriously. |
06:31 | < Vornicus> | Quite. |
06:32 | <@Derakon> | Oh, Vorn? Do you mind downloading a copy of the JBRL source? I'm a bit titchy about backups since I let the Aegis site expire (and with it, lost my convenient offsite backup location). |
06:33 | <@Derakon> | http://derakon.dyndns.org/~chriswei/temp2/jbrl-20090617.tgz |
06:33 | <@Derakon> | (4MB) |
06:33 | | ASCII [~none@Nightstar-27052.dyn.optonline.net] has quit [Ping Timeout] |
06:33 | < Vornicus> | Downloading now. |
06:34 | <@Derakon> | Thanks. |
06:45 | | UndeadAnno [AnnoDomini@Nightstar-29603.neoplus.adsl.tpnet.pl] has joined #Code |
06:45 | | mode/#code [+o UndeadAnno] by ChanServ |
07:26 | | Derakon is now known as Derakon[AFK] |
07:30 | <@ToxicFrog> | My god a SUSE repomirror is big. |
07:30 | <@ToxicFrog> | The file_list is up to 12k and shows no signs of slowing down. |
07:30 | <@ToxicFrog> | This may not be the best approach to take. |
07:31 | <@SmithKurosaki> | Clarify? |
07:35 | < Vornicus> | 12k isn't that big. |
07:36 | <@SmithKurosaki> | I am just curious as to why TF is making a deal about it |
07:38 | <@ToxicFrog> | Vornicus: 12k as in twelve thousand files. |
07:39 | <@ToxicFrog> | The total repo looks to be around 14k files, 13.5GB. |
07:39 | < Vornicus> | ah |
07:39 | <@SmithKurosaki> | I am less confused now :) |
07:52 | <@ToxicFrog> | Ok, this is not practical. |
07:52 | | * ToxicFrog writes a shell script to generate a complete directory listing for the repo so he can write another shell script to automatically download the RPMs he needs for the buildsystem |
07:53 | <@SmithKurosaki> | It fails terribly? |
07:54 | <@SmithKurosaki> | Or is just not a solution for this magnitude of files> |
07:58 | <@SmithKurosaki> | Night everybody :) |
07:58 | <@ToxicFrog> | I would rather not download 13GB of data for ~2MB of dependencies. |
07:58 | <@SmithKurosaki> | Thought so |
09:25 | | gnolam [lenin@Nightstar-1382.A163.priv.bahnhof.se] has joined #Code |
09:25 | | mode/#code [+o gnolam] by ChanServ |
09:27 | | You're now known as TheWatcher |
09:32 | | Rhamphoryncus [~rhamph@Nightstar-7168.ed.shawcable.net] has quit [Quit: Rhamphoryncus] |
10:14 | | Consul_ [~Consul__@Nightstar-3702.dsl.sfldmi.ameritech.net] has joined #code |
10:15 | | Consul [~Consul__@Nightstar-2808.dsl.sfldmi.ameritech.net] has quit [Ping Timeout] |
10:37 | | ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Operation timed out] |
10:38 | | SmithK [~Smith@Nightstar-6508.dsl.teksavvy.com] has quit [Ping Timeout] |
10:44 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
10:44 | | mode/#code [+o Attilla] by ChanServ |
10:55 | | SmithK [~Smith@Nightstar-5161.dsl.teksavvy.com] has joined #code |
10:56 | | ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code |
10:56 | | mode/#code [+o ToxicFrog] by ChanServ |
12:28 | | McMartin [~mcmartin@Nightstar-19418.dsl.pltn13.sbcglobal.net] has quit [Operation timed out] |
12:30 | | McMartin [~mcmartin@Nightstar-19418.dsl.pltn13.sbcglobal.net] has joined #code |
12:30 | | mode/#code [+o McMartin] by ChanServ |
12:42 | | * gnolam woots! |
12:43 | | * gnolam gains the ability: TTF wrangling. |
14:47 | | UndeadAnno [AnnoDomini@Nightstar-29603.neoplus.adsl.tpnet.pl] has quit [Ping Timeout] |
14:47 | | UndeadAnno [AnnoDomini@Nightstar-29030.neoplus.adsl.tpnet.pl] has joined #Code |
14:47 | | mode/#code [+o UndeadAnno] by ChanServ |
15:01 | | Confusion [~Spam@Nightstar-20737.cable.telstraclear.net] has left #code [] |
16:06 | | Syloqs_AFH [Syloq@Admin.Nightstar.Net] has joined #code |
16:07 | | Syloqs_AFH is now known as Syloqs-AFH |
16:47 | | Thaqui [~Thaqui@121.98.166.ns-22683] has quit [Client exited] |
17:00 | | Consul_ is now known as Consul |
17:09 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Ping Timeout] |
17:14 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
17:17 | | Derakon[AFK] is now known as Derakon |
17:23 | | Rhamphoryncus [~rhamph@Nightstar-7168.ed.shawcable.net] has joined #code |
17:28 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Ping Timeout] |
17:29 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code |
17:29 | | mode/#code [+o Attilla] by ChanServ |
18:13 | | Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Quit: <Insert Humorous and/or serious exit message here>] |
18:27 | <@ToxicFrog> | You know |
18:27 | <@Derakon> | The secret's out! |
18:27 | | * Derakon runs. |
18:27 | <@ToxicFrog> | I bet I could exploit this OCR technology to do the dialogue portraits automatically as well. |
18:28 | <@SmithKurosaki> | Probably. You were doing it by hand before, this isn't like you TF, you always use your robot army |
18:28 | <@Derakon> | What would you do, tell it the different portraits are different "words"? |
18:29 | <@SmithKurosaki> | Actually, I'm thinking he will get it to put the text automatically into his post code |
18:30 | <@Derakon> | He's already done that. He was talking about the dialogue portraits. |
18:30 | <@SmithKurosaki> | Nice |
18:32 | <@SmithKurosaki> | I was thinking that it was just the text wouldn't have to get typed and would automatically get taken and then go into his code without him doing anything |
18:32 | <@SmithKurosaki> | (Other than running the script) |
18:34 | <@ToxicFrog> | No, no |
18:34 | <@ToxicFrog> | I mean, currently the findfaces script just names each face after the screenshot it came from |
18:35 | <@ToxicFrog> | If it can coordinate with transcribe, it knows what the name of the portrait should be: just match the extracted text against ^[^:]+ |
18:37 | <@SmithKurosaki> | I understand part of what you are planning. Can you go into more detail/ |
18:39 | <@ToxicFrog> | findfaces greps the screenshots for dialog portraits and extracts them. I end up with a dir full of files with names like l_1234.png |
18:39 | <@ToxicFrog> | It would be nice if it could instead name them, frex, Maya.1.png, Maya.2.png |
18:40 | <@ToxicFrog> | I figure I can get it to do this by using the output of transcribe, the dialogue grabber. |
18:40 | <@SmithKurosaki> | You are a genius |
18:58 | | Alek [~omegaboot@Nightstar-4141.dsl.emhril.sbcglobal.net] has quit [Connection reset by peer] |
19:06 | | Alek [~omegaboot@Nightstar-4141.dsl.emhril.sbcglobal.net] has joined #code |
19:08 | < Tarinaky> | I have a vague recollection that there's a C keyword that will return you to the start of a loop but I can't remember what it is. |
19:08 | < Tarinaky> | Anyone know what it is? |
19:09 | <@Derakon> | continue; |
19:10 | < Tarinaky> | Thanks. |
19:24 | <@gnolam> | Using it is /usually/ evil though. |
19:26 | <@Derakon> | ...? |
19:26 | <@Derakon> | How do you figure, Gnolam? |
19:31 | <@gnolam> | Continue is like goto; in 9 out of 10 cases it leads to spaghetti code and points to a flaw in your design. |
19:31 | <@gnolam> | There's still that 10% where it's justified though. |
19:31 | <@Derakon> | I declare that statistic made up on the spot. |
19:31 | <@gnolam> | Like 86% of all statistics. |
19:31 | <@Derakon> | And there's a huge difference between "short-circuit the rest of this loop" and "jump to an arbitrary location in the program". |
19:32 | <@Derakon> | After all, you could replace continue; with "if (conditional) {rest of loop}" |
19:33 | < Tarinaky> | I have an irrational fear of long else-if statements >.> |
19:34 | <@ToxicFrog> | Derakon: you could, but it's a lot uglier than just saying 'continue' |
19:34 | <@Derakon> | TF: that was my point. |
19:34 | <@ToxicFrog> | But really, there's an easy way to sort this once and for all: stop using loops, go tail-recursive~ |
19:34 | < Tarinaky> | tail-recursive? |
19:35 | < Tarinaky> | Oh. |
19:35 | <@ToxicFrog> | If a languag implements proper tail recursion (such as Scheme or Lua), you can return the result of a function call without using an additional stack frame, allowing infinite recursion and thus letting you implement loops in terms of function calls. |
19:36 | | * SmithKurosaki brains melt |
19:36 | <@ToxicFrog> | This is especially a characteristic of functional languages, which tend to either lack looping constructs entirely, or discourage their use. |
19:37 | <@ToxicFrog> | Tarinaky: however, if you're using C, it doesn't do tail recursion, and you're doomed. Sorry~ |
19:37 | | * Tarinaky shrugs. I realised a slightly neater way of doing what I wanted anyway. |
20:04 | <@McMartin> | I actually did tail calls in C by hacking the function epilogues with inline assembler once. |
20:04 | <@McMartin> | I don't recommend this practice. |
20:04 | <@McMartin> | Also, a conditional continue at the top of a loop is fine, IMO, and is more than 10% of cases people can use continue. |
20:05 | <@McMartin> | It's the procedural equivalent to processing a filtered list instead of the full one. |
20:06 | <@SmithKurosaki> | I've used continue before. It makes getting the output at the right time a lot easuer |
20:06 | <@SmithKurosaki> | easier, even |
20:17 | <@McMartin> | Also, because I'm still kind of :argh: about it, Haskell has proper tail recursion but thanks to lazy evaluation this doesn't buy you anything and you can still blow out your stack just as easily. |
20:17 | <@McMartin> | Sometimes more easily because stuff that wouldn't be an infinite loop otherwise becomes such. |
20:33 | <@ToxicFrog> | o.O |
20:34 | <@McMartin> | You don't compute a value until it's actually used, right? |
20:34 | <@ToxicFrog> | Right. |
20:34 | <@McMartin> | So the question is whether you're stacking stuff up on the call stack, or on the "compute this series of values once it's needed" stack. |
20:34 | <@McMartin> | Both are outblowable. |
20:34 | <@ToxicFrog> | Aah. |
20:35 | <@McMartin> | This has stung me several times, and new and exciting incarnations of it are what I'm usually bothering MCV about in here. |
20:39 | < Tarinaky> | Gah >.> I have a stupid question I can't find the answer to. I have the pointer to object1. I want to copy the contents of object2 into object1. How do I do this in c++? |
20:40 | < Tarinaky> | (they're of the same type) |
20:42 | <@ToxicFrog> | Just to be absolutely clear here, you have Object * object1; Object object2; ? |
20:44 | < Tarinaky> | Yes. |
20:50 | <@ToxicFrog> | *object1 = object2; |
20:50 | <@ToxicFrog> | memcpy() should also work. |
20:51 | <@McMartin> | O |
20:51 | <@McMartin> | NO |
20:51 | <@McMartin> | No memcpy()ing. |
20:52 | <@Derakon> | Heh. |
20:52 | <@McMartin> | memcpy does not call copy constructors and will wreck the shit out of any, say, boost::shared_ptr<>s in your Object. |
20:53 | <@McMartin> | (Or anything else that needs to do bookkeeping on copy, which is what operator= is for) |
20:53 | < Tarinaky> | ...Okay. My compiler did not like that... |
20:53 | <@McMartin> | Does Object have a public operator= method? |
20:54 | < Tarinaky> | No. |
20:55 | <@McMartin> | Hm. It should have one autogenerated if none is defined. What's the error? |
20:55 | < Tarinaky> | But yeah... Tons of errors about stringstream. |
20:55 | <@McMartin> | Can you quote one, preferably without the piles of template spam? |
20:55 | <@McMartin> | But first things first |
20:56 | < Tarinaky> | http://tarinaky.pastebin.com/m4e113ae3 |
20:56 | <@McMartin> | Looks like stringstreams are noncopyable, which is news to me. |
20:57 | <@McMartin> | Is there a particular reason you're keeping the stream proper in the object instead of just a reference to it? |
20:58 | <@McMartin> | (After copying, should they share the stream?) |
20:59 | <@ToxicFrog> | McMartin: re copy constructors: isn't Tarinaky working in C? |
20:59 | < Tarinaky> | ToxicFrog: No. |
20:59 | <@McMartin> | Clearly not, he's getting errors regarding <sstream>. |
20:59 | < Tarinaky> | I only asked about C because I knew the keyword I wanted was in the C subset >.> |
21:00 | <@McMartin> | The problem here is that string streams extend io_base, whose operator= is a private method. |
21:00 | <@McMartin> | Which means the resulting objects are noncopyable. |
21:00 | <@McMartin> | This means in part that you want to rethink your semantics a bit. |
21:00 | | * Tarinaky nod-nods. |
21:00 | <@McMartin> | What does the line you quoted *mean*? You have a string stream inside of it, which is presumably a string you can append to. |
21:00 | <@McMartin> | After the copy, should appending to that string in one object also append it to the other object? |
21:01 | <@McMartin> | If yes, you should have a stringstream& or stringstream*, not a raw one, since it's a shared state. |
21:01 | <@McMartin> | If it's *not*, the objects should really be carrying around a string that is string-so-far. |
21:02 | < Tarinaky> | Yeah. |
21:03 | <@McMartin> | If it's a string you're reading from, string or const string& and an index. That way you don't have to worry about messing up each other's internal file pointers.) |
21:04 | < Tarinaky> | Yes. I know, that's what I've done. I was only using a stringstream because it was the easiest way of adding a char on the end of it every so often. |
21:09 | <@McMartin> | Pretty sure the easiest way to do that is to use std::string::push_back |
21:09 | <@McMartin> | stringstreams are for appending formatted data types to a string. |
21:09 | < Tarinaky> | -.- I could have done with knowing about push_back several hours ago. |
21:09 | <@McMartin> | If you don't have the reference pages at http://www.cplusplus.com/ bookmarked, do so |
21:10 | <@McMartin> | (push_back actually works with most C++ collection types, including lists and vectors) |
21:10 | < Tarinaky> | I have selective blindness. Whenever I want something it's completely invisible to me >.> |
21:11 | < Tarinaky> | What about examining a string character by character? I can't spot a pop. |
21:12 | <@McMartin> | You can index strings with s[i] |
21:12 | <@McMartin> | There's also charAt or something. |
21:12 | <@McMartin> | actually deleting characters is expensive so there might not be one. |
21:12 | <@McMartin> | (assuming you're popping off the front) |
21:12 | | * Tarinaky nods. |
21:13 | <@McMartin> | You'd have to do s[0] and s = s.substr(1) |
21:13 | < Tarinaky> | I'll bear that in mind in future. |
21:14 | <@McMartin> | If you're actually implementing a queue of some kind where you're only operating on the edges, a std::list<char> or a std::deque<char> might be what you want. |
21:14 | | * McMartin forgets offhand the difference between those two classes. |
21:36 | <@Namegduf> | A list is a linked list, a deque works mostly like a vector (a classic array, basically) except with better speeds/speed guarantees for adding to the start as well as the end. |
21:36 | <@Namegduf> | (Correct me If I make a mistake) |
21:38 | <@Namegduf> | Deque has better random access time, list has much better addition/deletion of entries in arbitrary position time. |
22:05 | < Vornicus> | Deque doesn't actually describe the way the thing works. |
22:06 | <@McMartin> | Yeah, I was going to say, I thought std::list was a double-ended queue. |
22:06 | < Vornicus> | It just describes what things you can talk to it with. |
22:06 | <@Namegduf> | Yeah, most of those structures leave the actual implementation open. |
22:06 | < Vornicus> | List and Array are the usual unsorted linear collections. |
22:07 | <@Namegduf> | It's the operation time guarantees that vary. |
22:07 | < Vornicus> | Queue, Stack, Deque, and others are just interfaces. |
22:07 | <@McMartin> | Aha. |
22:08 | < Vornicus> | (I'm not sure whether there are other unsorted linear collection systems than list and array) |
22:09 | | * Namegduf thought deque did some internal work to be able to make those guarantees. |
22:10 | <@McMartin> | Could be. I don't keep that data swapped in and have to hit the references every time. |
22:11 | < Vornicus> | Deque, really, you want yourself a doubly linked list. |
22:11 | < Vornicus> | Makes for constant time access in both directions. |
22:12 | <@Namegduf> | No, it isn't constant time. |
22:12 | <@Namegduf> | Lists aren't constant time access. |
22:12 | <@McMartin> | std::list *is* doubly-linked. |
22:12 | < Vornicus> | This is end access, which is what you're looking for as far as deques. |
22:12 | <@McMartin> | Yeah, and std::list requires that, and also requires constant-time reverse_iterators, IIRC. |
22:12 | < Vornicus> | If you want priority queue, you usually use a heap or something similar. |
22:13 | <@McMartin> | std::set~ |
22:13 | < Vornicus> | But that's not a deque |
22:13 | < Vornicus> | ...uh. |
22:13 | < Vornicus> | Why the crap would you use a /set/ for a PriQ? |
22:13 | <@McMartin> | Well. Multiset. |
22:13 | <@Namegduf> | A deque is just an implementation of a double ended array, it isn't a fifo or first in last out or similar. |
22:13 | <@McMartin> | insert, pop_minimum. |
22:14 | < Vornicus> | Wouldn't that be multimap? |
22:14 | <@Namegduf> | No, it wouldn't, that's a map. |
22:14 | <@McMartin> | Depends on what your PriQ means. |
22:14 | <@McMartin> | I'm assuming priority is defined by comparable on the data. |
22:15 | < Vornicus> | Ah, ok |
22:15 | <@McMartin> | If there's irrelevant side data, then multimap might make sense though it might also get you *everything* at the highest priority at once. |
22:15 | <@McMartin> | If you don't want that, a set of pairs is probably better. |
22:15 | < Vornicus> | Reminds me, I wanted to finish my sorted list implementation for Python, |
22:31 | | * Derakon blarghs at his code. |
22:31 | <@Derakon> | I'm checking to see if the player can stand up by letting them try, and if they hit their heads, forcing them to crawl again. |
22:32 | <@Derakon> | Problem being that when you're mostly embedded into a wall tile, there's no guarantee which direction that tile will try to eject you. Might be downwards. Might be sideways instead. |
22:32 | <@Derakon> | I could just say "If you hit anything when trying to stand, force a crawl" but that seems hackish. |
22:53 | | Vornicus [~vorn@ServicesOp.Nightstar.Net] has quit [Ping Timeout] |
23:25 | | You're now known as TheWatcher[T-2] |
23:27 | | You're now known as TheWatcher[zZzZ] |
23:28 | | Vornicus [~vorn@ServicesOp.Nightstar.Net] has joined #code |
23:28 | | mode/#code [+o Vornicus] by ChanServ |
23:50 | | Netsplit DeepThought.NY.US.Nightstar.Net <-> Blargh.CA.US.Nightstar.Net quits: crem_, Tarinaky, @EvilDarkLord, Rhamphoryncus, @Doctor_Nick |
23:51 | | Netsplit over, joins: crem_, EvilDarkLord, Tarinaky, Doctor_Nick |
23:51 | | mode/#code [+o EvilDarkLord] by ChanServ |
23:51 | | Netsplit over, joins: Rhamphoryncus |
23:51 | | mode/#code [+o Doctor_Nick] by ChanServ |
--- Log closed Fri Jun 19 00:00:14 2009 |