code logs -> 2010 -> Wed, 06 Oct 2010< code.20101005.log - code.20101007.log >
--- Log opened Wed Oct 06 00:00:06 2010
00:00 Syloqs_AFH is now known as Syloqs-AFH
00:00 Derakon [Derakon@Nightstar-1ffd02e6.ucsf.edu] has quit [[NS] Quit: Leaving]
00:00
< RichardBarrell>
No need to use dynamic_cast to go from child* to parent*. You can, but it invokes RTTI overhead for no real gain.
00:01
< RichardBarrell>
dynamic_cast is only necessary when you want to attempt to go from parent* to child*.
00:01
< celticminstrel>
Parent to child may be the better route actually... store it as an ios* and attempt casting as necessary.
00:01
< RichardBarrell>
Find someone smarter than me if you want to query whether you can dynamic_cast from void* to some_class*.
00:01
< RichardBarrell>
But why do you want to do that?
00:01
< celticminstrel>
The other option would be storing as void*.
00:01
< celticminstrel>
Hm?
00:02
< RichardBarrell>
Why is it that you do not know whether you are going to be using the streams for input or for output?
00:02
< celticminstrel>
Because it's too generic.
00:04
< RichardBarrell>
You're kind of fighting C++'s type system here. A built-for-C++ library would encode the information about what operations are going to be used on what objects by picking whether to require istreams or ostreams.
00:04
< celticminstrel>
Right, but I'm dealing with SDL here.
00:05
< RichardBarrell>
(If it bothered at all, instead of just sidestepping the type system by always using objects that look like full iostreams but sometimes don't actually implement half of the methods.)
00:06
< RichardBarrell>
I'd advise you not to bother, really. This is a case where SDL and C++ don't fit each other particularly well, and iostreams isn't all *that* nice *anyway*.
00:06
< celticminstrel>
Hehe.
00:06
<@McMartin>
SDL is pretty firmly a C library; if you're wrapping by hand you should be hiding SDL almost entirely
00:06
<@McMartin>
imo
00:06
< celticminstrel>
They definitely don't fit that well.
00:06
<@McMartin>
Otherwise, RB has the right of it.
00:07
< RichardBarrell>
Thank you. :)
00:09
< RichardBarrell>
If you look at gtkmm, for example, which is a C++ wrapper around GTK, you'll find that using gtkmm you almost *never* touch raw GTK structs - it's hidden almost completely, even despite the fact that GTK's API is quite well suited to C++. The normal procedure when wrapping one language's API in another is to *completely* hide the library that you're building on.
00:09
< RichardBarrell>
(Unless I am incorrect ^_^)
00:09
< celticminstrel>
There's another way to do this that I was avoiding because it's about thrice as much code... that's not all that much though, so perhaps I'll do that.
00:12
< gnolam>
What exactly are you trying to do?
00:14
< celticminstrel>
I thought I said that already.
00:17 Attilla [Some.Dude@Nightstar-6d27e276.threembb.co.uk] has quit [[NS] Quit: ]
00:19
< gnolam>
The only thing I found in the backscroll was
00:19
< gnolam>
<celticminstrel> I'm trying to make SDL work with C++ streams. <_<
00:19
< gnolam>
Which isn't very specific. :)
00:19
< celticminstrel>
Oh. Okay.
00:19
< celticminstrel>
Basically binding SDL_RWops to C++ streams.
00:20
< gnolam>
Ah.
00:20
< gnolam>
My general advice is to simply toss C++'s file I/O and use C's.
00:22
< RichardBarrell>
iostreams really isn't all *that* nice anyway. :)
00:36 You're now known as TheWatcher[T-2]
00:38 You're now known as TheWatcher[zZzZ]
00:58 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: KABOOM! It seems that I have exploded. Please wait while I reinstall the universe.]
00:58 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
01:01 * ToxicFrog works on his vicious test suite for luapilot
01:01 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [Connection closed]
01:02 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
01:11 Orthia [orthianz@Nightstar-26a6e3e6.xnet.co.nz] has joined #code
01:36 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
01:36 Derakon[AFK] is now known as Derakon
01:42
<@Vornicus>
Kaura!
01:51
< celticminstrel>
Okay, I need a way to get an SDL_Cursor from an SDL_Surface...
01:54
< RichardBarrell>
Vornicus: were you registering surprise?
01:55
<@Vornicus>
No, I was registering "Hey you!"
02:15 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
03:28
< celticminstrel>
LSB first = little endian, right?
03:40
<@Vornicus>
Yes
03:44 RichardBarrell [mycatverbs@Nightstar-3b2c2db2.bethere.co.uk] has quit [Ping timeout: 121 seconds]
03:55
< celticminstrel>
Okay, I'm pretty sure SDL expects its cursor bitmaps to be encoded top-to-bottom, left-to-right, so I need to convert this bottom-to-top, left-to-right bitmap to match...
03:57
< celticminstrel>
Hm... that makes it sound like I merely need to reverse rows...
03:58
<@Vornicus>
Yep.
03:59
< celticminstrel>
Which shouldn't be terribly difficult.
04:00
< celticminstrel>
Certainly not as bad as reversing all bits.
04:03 kwsn [kwsn@31356A.5FD175.2259B6.DFACD4] has joined #code
04:15
< Alek>
...
04:16
< Alek>
just how many programming languages are there?
04:16
< Alek>
including little-used and dead ones?
04:16
< Alek>
as of 2002, there were already over 2500, according to a computer magazine.
04:18
< celticminstrel>
Well, there are tons of esoteric languages floating around...
04:19
< celticminstrel>
Such as INTERCAL.
04:19
< celticminstrel>
Which is one of the oldest.
04:37 Orthia [orthianz@Nightstar-26a6e3e6.xnet.co.nz] has quit [Client closed the connection]
04:45 Orthia [orthianz@Nightstar-26a6e3e6.xnet.co.nz] has joined #code
05:46 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
05:54 Orthia [orthianz@Nightstar-26a6e3e6.xnet.co.nz] has quit [Ping timeout: 121 seconds]
05:55 cpux is now known as shade_of_cpux
05:56 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
06:05
<@Vornicus>
Kaura!
06:11
< kaura>
Vorn!
06:11
<@Vornicus>
Let us make examine do Awesome things!
06:12
< kaura>
Awesome!
06:12
<@Vornicus>
Right now, if you do examine on your deck, you get a long-ass list of cards. You get four whatsitcalled, and four whatelseitscalled, and four...
06:13
<@Vornicus>
You get the idea.
06:13
< kaura>
Aye.
06:13
< kaura>
So the plan's to shrink it down to quantity and name?
06:13
<@Vornicus>
What if, instead of that, you could convince it to give you the quantities of each card.
06:14
< kaura>
That would greatly simplify its reading!
06:14
<@Vornicus>
it would.
06:14
<@Vornicus>
For this, we will use something called a defaultdict.
06:14
<@Vornicus>
http://docs.python.org/library/collections.html#defaultdict-objects
06:16
<@Vornicus>
What we're going to do is create a defaultdict where, if it tries to work with a nonexistent key, it will set that key's value to 0.
06:17
<@Vornicus>
Then, for every thing in the list, we're going to add 1 to that thing's entry in the defaultdict.
06:18
<@Vornicus>
and /then/, we're going to read out the stuff from the defaultdict and glom it all into a string.
06:20
< kaura>
..ooph. Tricky order.
06:20
<@Vornicus>
Not really.
06:20
<@Vornicus>
Anyway all of this stuff will happen in user_examine.
06:20
< kaura>
Right.
06:21
<@Vornicus>
But first! We need to import collections
06:22
< kaura>
So "import collections" at the top.
06:22
<@Vornicus>
Yep.
06:23
<@Vornicus>
Now, down in user_examine, create our defaultdict: collections.defaultdict(int)
06:24
< kaura>
Right.
06:24
<@Vornicus>
Now, the thing about defaultdict
06:25
<@Vornicus>
That thing I put in there, it's a callable -- technically it's a class-function-something -- that defaultdict will call every time it needs a value for a key it hasn't seen before.
06:25 Orthia [orthianz@Nightstar-5349bf86.xnet.co.nz] has joined #code
06:26
<@Vornicus>
So, it happens that int... returns 0.
06:26
<@Vornicus>
Which is right for this situation: we're technically asking how many there are before we add our new one.
06:27
< kaura>
Right. So left as-is, it defaults to 0.
06:31
<@Vornicus>
Right.
06:31
<@Vornicus>
So next, we have to add our cards to this dictionary.
06:32
< kaura>
Something like collections.defaultdict.append(cards)?
06:32
<@Vornicus>
nope.
06:33
<@Vornicus>
We just created our defaultdict; what did you call it?
06:33
< kaura>
Er, collections?
06:33
< kaura>
Or was I supposed to assign a name to collections.defaultdict(int)?
06:34
<@Vornicus>
Yeah, it created for you a defaultdict in the same way that Deck("decklist.txt") creates for you a Deck.
06:35
< kaura>
Ahh.
06:36
< kaura>
So it would be more like collections.append(cards) then, as .defaultdict(int) tells it to make a deck called -- wait, is that right? Then what did we import earlier?
06:36
<@Vornicus>
We imported a module, with the defaultdict class in it.
06:36
<@Vornicus>
We then created a defaultdict object, giving it "int" as its "default_factory"
06:37
< kaura>
Right.
06:38
<@Vornicus>
This, then, we have to put somewhere, so we can talk about it more.
06:41
<@Vornicus>
So, yeah.
06:41
<@Vornicus>
What do you want to call this defaultdict, that will hold card names and their quantities?
06:42
< kaura>
Eh, "pool"
06:43
<@Vornicus>
Works.
06:43
<@Vornicus>
Okay, now. We have to handle every card in the list that we got from examine.
06:45 Derakon is now known as Derakon[AFK]
06:45
<@Vornicus>
And what we're going to do, is add 1 to the card's value in pool, each time.
06:47
< kaura>
So get it to recognize a card, then get it to check the quantity. ...there's something involved here that I haven't used before, I think.
06:48
<@Vornicus>
Probably: augmented assignment.
06:49
<@Vornicus>
something += something_else is the same as something = something + something_else
06:49
< kaura>
Ahh... mentioned before, but not used.
06:50
<@Vornicus>
What we're going to do, then, is hunt up the value for the card (by indexing; defaultdict works almost exactly like a dictionary), and then add 1 to it.
06:52
< kaura>
So [n] += 1?
06:52
<@Vornicus>
will [n] give you the value from pool?
06:52
< kaura>
...nnno.
06:53
<@Vornicus>
how do you get a value from pool that's associated with the key n?
06:55
<@Vornicus>
(hint: you were close)
06:56
< kaura>
Ah, wait. pool[n], right?
06:56
<@Vornicus>
Indeed.
06:57
<@Vornicus>
So let's see the new user_examine code, up through getting the cards into the default_dict.
06:57
<@Vornicus>
or, rather, into pool.
06:57
<@Vornicus>
(and while you're in there, might be a good idea to return pool to see what it does according ot the terp.)
07:00
< kaura>
http://pastebin.starforge.co.uk/416
07:00
< kaura>
return pool does nothing so far.
07:00
<@Vornicus>
What's n? Where'd that come from?
07:01
< kaura>
Ah, whups. Value placeholder. Forgot to get rid of it.
07:01
<@Vornicus>
No, you need something there
07:01
<@Vornicus>
But what should you be asking pool about?
07:04 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code
07:06 Orthia [orthianz@Nightstar-5349bf86.xnet.co.nz] has quit [Connection reset by peer]
07:07
< kaura>
...damn, brainfarting on this. Alright, from the top: pool defined as collections.defaultdict(int). We need to feed my_deck into pool first, right?
07:07
<@Vornicus>
you need to feed the results of my_deck.examine into the pool, using that pool[n] += 1 line.
07:09
< kaura>
Ahh.
07:09 Anno[Laptop] [annodomini@Nightstar-56dfa451.adsl.tpnet.pl] has joined #code
07:09
<@Vornicus>
Since each key in pool will be a name of a card, you have to do something with the results of my_deck.examine()
07:10
<@Vornicus>
to get them one at a time.
07:13
< kaura>
...oh, hey, that worked.
07:13
< kaura>
A for loop, right?
07:14
< kaura>
http://pastebin.starforge.co.uk/417
07:14 Orthia [orthianz@Nightstar-5349bf86.xnet.co.nz] has joined #code
07:14
<@Vornicus>
yep. I'd use "card" instead of "x" though
07:14
<@Vornicus>
(just as a naming thing)
07:15
< kaura>
Right, that'd make it clearer what's happening.
07:15
<@Vornicus>
Anyway, we've now got pool filled.
07:16
<@Vornicus>
We're now going to take pool and pass it through a couple of things: we're going to get a sorted list of key/value pairs (in a particular order that isn't the one that it would come up on its own), then turn all those into strings, and then join them up with newlines.
07:16
<@Vornicus>
This can all happen on one line, using a list comprehension (actually a generator expression, which is very similar)
07:18
<@Vornicus>
So let's start with this: dictionaries and defaultdicts both have a method called "iteritems()" -- it will iterate over all the key-value pairs in the dictionary.
07:19
<@Vornicus>
And we want to sort the key-value pairs somehow; so let's try, instead of returning pool, return sorted(pool.iteritems())
07:22
<@Vornicus>
And now you see what that looks like. Unfortunately, we don't really want it in that order: we want it to list things in order of quantity, and then break ties with names!
07:22
< kaura>
I see... so something to tell it to sort by the value, not key.
07:23
<@Vornicus>
Right.
07:23
<@Vornicus>
Which is what sorted's "key" parameter is for. This is a named parameter, though, and we're going to have to create a function right in the middle there that does this.
07:24
<@Vornicus>
Which brings us to "how the hell do we tell it this"
07:25
<@Vornicus>
Wel, what we need is a function that, when given (k, v), returns (v, k)
07:27
<@Vornicus>
(sorting a tuple goes by its contents: first it checks the starting element, then it breaks ties with the next one, then it breaks further ties with the one after that, and so on)
07:30 * Vornicus thinks he's gone a little deep here.
07:32
< kaura>
Not really...I think. sort() basically orders by the first part of a tuple, ignoring whatever comes after, right? So every time you want to sort otherwise, you first have to reassign the preferred element to be the first that is checked.
07:33
<@Vornicus>
Right - it only looks at the next part if it has to break a tie.
07:34
<@Vornicus>
Anyway, your function should take in a single tuple and return it, reversed.
07:34
<@Vornicus>
That last, actually, is the name of a known function!
07:35
<@Vornicus>
...so all we have to do is pass that in as key. Looks like this: sorted(pool.iteritems(), key = reversed)
07:35
< kaura>
I figured there'd be a built-in mirror function or something.
07:36
<@Vornicus>
See how that shakes out, then we'll work on the next bit.
07:36
<@Vornicus>
(oh, also, lists also compare the same way.)
07:36
< kaura>
...it shakes out oddly. No apparent order.
07:37
<@Vornicus>
what the cheese
07:37
< kaura>
I'll post up a comparison.
07:37
<@Vornicus>
I'm actually getting a very, very strange result there too.
07:38
< kaura>
http://pastebin.starforge.co.uk/418
07:38
< kaura>
What was the expected result - by numerical order, right?
07:39
<@Vornicus>
By count first, then name. What on earth is going on...
07:40
<@Vornicus>
Oh, try this, instead of "reversed": "lambda k: tuple(reversed(k))"
07:42
< kaura>
That works! ...why does it work?
07:42
<@Vornicus>
(lambda creates a nameless function that all it does is return something, based on its inputs. I /suspect/ that what we're seeing is that reversed is returning an /iterator/, and then it doesn't really know how to compare those -- an iterator is an object that works in for, but doesn't act at all like a tuple otherwise)
07:42
<@Vornicus>
So, lambda k: tuple(reversed(k)) is equivalent to def some_crazy_function(k): return tuple(reversed(k))
07:43
<@Vornicus>
Then, well, usually reversed returns what's called an iterator -- I just described that, and iteritems is one too. It is an object that knows how to traverse (or in some interesting cases, /generate/) a sequence, but is not itself the sequence.
07:45
< kaura>
Ahh... so by assigning key = reversed, we essentially confused Python by telling it to sort an iterator, not reverse the key.
07:46
<@Vornicus>
We're telling it to use the iterators as keys.
07:46
<@Vornicus>
Which is ridiculous, because iterators don't... really compare...
07:46
<@Vornicus>
>>> iter([1,2,3])
07:46
<@Vornicus>
<listiterator object at 0x011BE450>
07:47
<@Vornicus>
well, that's what we had done. Now we have set it so it knows to use the tuple that the iterator would generate, so it works now.
07:48
<@Vornicus>
Anyway. Now that we've got out things coming out of there, let's build a list comprehension around that. Note that the stuff between "for" and "in" can have multiple things, if we separate them by commas. Since each key-value pair is two things, we'll want a name for the key (which is to say, the card name), and another name for the value (which is to say, the count of cards)
07:51
<@Vornicus>
Then for the bit where we tell it what to do with these things, we want the count, then a space, then the name of the card.
07:52 Kazriko [kaz@Nightstar-e09690fa.client.bresnan.net] has quit [Ping timeout: 121 seconds]
07:54
<@Vornicus>
(remember: listcomps are [do what for with what in from where]
07:56 kwsn is now known as kwsn\t-2
07:58
< kaura>
...rgh, brainfarting again. Gimme a sec...
07:59
< kwsn\t-2>
kaura; that would imply you had a brain
07:59
< kwsn\t-2>
and with that
07:59
< kwsn\t-2>
i'm out :P
07:59 kwsn\t-2 [kwsn@31356A.5FD175.2259B6.DFACD4] has quit [[NS] Quit: i lost the game]
08:01
< Anno[Laptop]>
The nickname kwsn sounds like some sort of *nix application.
08:07
<@Vornicus>
Just throw guesses out there, kaura, I'm here to help critique, this isn't the final exam. (there isn't a final exam)
08:08
< kaura>
Vorn: I'm aware. My brainfart right now is how to structure this thing.
08:08
<@Vornicus>
Where are you getting your card/count pairs
08:09
< kaura>
From the pool, right?
08:09
<@Vornicus>
From that big complicated piece of crap we just wrote, actually.
08:10 Ortiha [orthianz@Nightstar-ad36c145.xnet.co.nz] has joined #code
08:12 Orthia [orthianz@Nightstar-5349bf86.xnet.co.nz] has quit [Ping timeout: 121 seconds]
08:13
< kaura>
Ah... think I have an idea now.
08:14
<@Vornicus>
Show me!
08:15
< kaura>
..hm. This big, ugly line wasn't quite it...
08:15
< kaura>
return [pool [0] + "" + pool[1] for pool[0], pool[1] in sorted(pool.iteritems(), key = lambda k: tuple(reversed()))]
08:16
< kaura>
Ah, left a space in pool[0], but that doesn't actually fix matters much.
08:17
<@Vornicus>
Don't call 'em pool[0] and pool[1], because we don't want to mangle pool any more.
08:17
<@Vornicus>
try "card" and "count" instead
08:20
< kaura>
Ah, right. Their order determines placement. ...looks like I'm missing an argument in "reversed"
08:21
<@Vornicus>
Put the k in there.
08:21
<@Vornicus>
Also, you want to use " ", not ""
08:22
< kaura>
Oh, right. "" is just nothing.
08:23
<@Vornicus>
Right.
08:23 * kaura scratches his head. "Cannot concatenate 'str' and 'int' objects."
08:23
<@Vornicus>
str(count) instead of just count
08:24
< kaura>
Oh, sensible.
08:26
< kaura>
Ah, there we go. # cardname
08:26
<@Vornicus>
All right!
08:26
<@Vornicus>
Now we have a bunch of strings, all in a list!
08:27
< kaura>
\o/
08:27
<@Vornicus>
Now we need to make it do something we've made it do before: make that list of strings into a single string full of linebreaks!
08:27
< kaura>
Right! ...is it just "\n".join.listcomp?
08:27
<@Vornicus>
"\n".join(listcomp)
08:28
< kaura>
And done!
08:28
< kaura>
...damn, that's neat.
08:29
<@Vornicus>
\o/
08:29
<@Vornicus>
By the way.
08:30
<@Vornicus>
At this point, you can if you choose, remove the [] around that listcomp - every list comprehension can also be a "generator expression", which is a listcomp-shaped thing that makes an iterator instead.
08:30
<@Vornicus>
join works on anything that's iterable, including generator expressions and lists.
08:30
< kaura>
Ah... so if the entirety of the listcomp is an iterator, it can be treated as one.
08:32
<@Vornicus>
The advantage of using generator expressions (which actually isn't that big here, because sorted makes a list) is that it doesn't make a list, it just makes the elements of the list, as they come available. This can be useful when the things you make are large and don't want to keep them around that long because you'll blow out your memory.
08:34
<@Vornicus>
(the reason sorted makes a list is because it has to keep all the things, or it wouldn't be able to say "this is sorted!"
08:34
< kaura>
Which can be really awkward for Huge Things.
08:35
<@Vornicus>
Yeah. If you're sorting a lot of stuff, you need a lot of ram or a proper fucking database.
08:35
< kaura>
And I'm not quite up for databases yet, huh?
08:36<~Reiver> Databases are not a natural part of python, no.
08:36<~Reiver> Though I am not surprised if you can bloody well plug one of the bastards in...
08:36
<@Vornicus>
"sqlite3" is a native module
08:36<~Reiver> bahahaha
08:36<~Reiver> see
08:37
<@Vornicus>
But yeah - databases are really, really good at keeping track of, and sorting, and filtering stuff. But you talk to it like it's a black box most of the time.
08:40
<@Vornicus>
Apparently Python can sort a million random floating-point numbers in 0.67 seconds.
08:41
< kaura>
...Python is really surprising sometimes.
08:41
<@Vornicus>
That's not all that surprising - it only takes about, oh, 20 million comparisons at most to pull that off.
08:43<~Reiver> nlogn <3
08:45 * Anno[Laptop] is currently in a renewed fondness for Java.
08:45 * Vornicus didn't know that emotion was possible.
08:46
< Anno[Laptop]>
Vornicus: Compare to trying to prototype in C++.
08:48
<@Vornicus>
think i'd still prefer python. :)
08:48
< Anno[Laptop]>
That's probably because you know Python. ;p
08:49
<@Vornicus>
I also know Java and C++.
09:36 Zed__ [Zed@Nightstar-556ea8b5.or.comcast.net] has joined #code
09:37 Netsplit *.net <-> *.split quits: @Vornicus, Anno[Laptop], Rhamphoryncus, Zed_, Thaqui, @jerith
09:39 Zed_ [Zed@Nightstar-556ea8b5.or.comcast.net] has joined #code
09:39 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
09:39 jerith [jerith@ServerAdministrator.Nightstar.Net] has joined #code
09:39 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
09:39 Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has joined #code
09:39 Anno[Laptop] [annodomini@Nightstar-56dfa451.adsl.tpnet.pl] has joined #code
09:39 ServerMode/#code [+oo Vornicus jerith] by *.Nightstar.Net
09:39 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
09:39 Anno[Laptop] [annodomini@Nightstar-56dfa451.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds]
09:40 Zed_ [Zed@Nightstar-556ea8b5.or.comcast.net] has quit [Ping timeout: 121 seconds]
09:43 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
09:43 mode/#code [+o Vornicus] by Reiver
09:45 Vornicus is now known as Vornicus-Latens
10:04 You're now known as TheWatcher
10:16 Anno[Laptop] [annodomini@F67919.F326B3.98D923.BDA7B6] has joined #code
11:38 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed]
11:54 kaura [kaura@Nightstar-fd82400d.snfc21.sbcglobal.net] has quit [[NS] Quit: HydraIRC -> http://www.hydrairc.com <- Chicks dig it]
12:14 Anno[Laptop] [annodomini@F67919.F326B3.98D923.BDA7B6] has quit [Ping timeout: 121 seconds]
12:49 Anno[Laptop] [annodomini@Nightstar-56dfa451.adsl.tpnet.pl] has joined #code
13:13
< Tarinaky>
How do you 'do' hexagonal grids?
13:14
< Tarinaky>
I mean. Square tiles are easy but I can't quite work out how you draw them, convert between on-screen and map position or even work with them.
13:19 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [Client closed the connection]
13:50<~Reiver> Painfully.
13:58
<@TheWatcher>
Well, first you find a witch....
14:00
< Anno[Laptop]>
ITYM, "Zun?chst finden Sie eine Hexe..."
14:00
<@TheWatcher>
>.> Maaybe.
14:01
< Anno[Laptop]>
Die Hexe == witch.
14:01 * TheWatcher nod
14:01
< Anno[Laptop]>
Aaaand the first thing that comes up in my mind is that I can't compare strings like that.
14:03 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
15:24 * TheWatcher eyes this horrible mass of 1845 lines of perl code, sighs, starts to refactor the everliving shit out of it
15:42 Ortiha [orthianz@Nightstar-ad36c145.xnet.co.nz] has quit [Ping timeout: 121 seconds]
15:53 Kazriko [kaz@Nightstar-e09690fa.client.bresnan.net] has joined #code
15:54 mode/#code [+o Kazriko] by Reiver
15:59 Orthia [orthianz@Nightstar-ad36c145.xnet.co.nz] has joined #code
16:17 Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has quit [Client exited]
16:40
<@Vornicus-Latens>
Tarinaky left. I could have explained!
16:47
<@Vornicus-Latens>
(for location: use the matrix [[sqrt(3)/2, 1], [-sqrt(3)/2, 1]] to get the center points of your hexagons.)
16:50 Orthia [orthianz@Nightstar-ad36c145.xnet.co.nz] has quit [Ping timeout: 121 seconds]
16:50
<@Vornicus-Latens>
(for connectedness: two hexagons are connected if their coordinate differences are any of these: {<1, 0>, <-1, 0>, <0, 1>, <0, -1>, <1, 1>, <-1, -1>}
16:52
<@Vornicus-Latens>
(their non-display coordinates, that is)
16:53
<@Vornicus-Latens>
(for distance: if the signs of their nondisplay coordinates are the same, it's the maximum of their absolute values; if different, it's the sum.)
16:53 * TheWatcher stabs autoconf for not utilising multiple processors
16:54
<@TheWatcher>
wait
16:54
<@Vornicus-Latens>
wait what
16:55
<@TheWatcher>
s/(stabs autoconf).*/$1/
16:55
<@Vornicus-Latens>
That's more like it, yes
17:06 Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code
17:41 Attilla [Some.Dude@Nightstar-791ffadc.threembb.co.uk] has joined #code
17:41 mode/#code [+o Attilla] by Reiver
17:41
<@Vornicus-Latens>
erp, sorry, [[sqrt(3)/2, 3/2], [sqrt(3)/2, -3/2]]
17:42
<@Vornicus-Latens>
...yes. that's right.
18:13 celticminstrel [celticminst@Nightstar-f8b608eb.cable.rogers.com] has joined #code
18:18
<@Vornicus-Latens>
Hm. I seem to recall a week or so ago that McM was talking about non-square pixels, and it occurred to me that there is a place that uses them nowadays, and it's a relatively common setup.
18:18 Alek [omegaboot@Nightstar-8f41d887.il.comcast.net] has quit [Ping timeout: 121 seconds]
18:19 Alek [omegaboot@Nightstar-8f41d887.il.comcast.net] has joined #code
18:19
< gnolam>
Oh?
18:19
<@Vornicus-Latens>
The Wii only puts out 480i (which is to say "standard definition" TV); however, if you plug it into an HDTV, you can set the HDTV to "stretch" and the Wii to "widescreen" and it corrects the aspect ratio.
18:19
<@Vornicus-Latens>
--but now the pixels are nonsquare.
18:23 Alek [omegaboot@Nightstar-8f41d887.il.comcast.net] has quit [Ping timeout: 121 seconds]
18:26
<@Vornicus-Latens>
(the discussion was in relation to old games that use 320x200 on a 4:3 monitor)
18:27 Alek [omegaboot@Nightstar-8f41d887.il.comcast.net] has joined #code
18:34
< gnolam>
Pfft.
19:06
< celticminstrel>
So, would it be unusual to change this reference-counting class to maintain a global map of memory address to reference count rather than having a pointer to the reference count?
19:12
<@ToxicFrog>
Why?
19:12
< celticminstrel>
Well, at present it's possible for two instances of the smart pointer to not know about each other.
19:12
< celticminstrel>
.
19:12
< celticminstrel>
And thus maintain separate reference counts.
19:14
< celticminstrel>
This is because some functions are getting the raw pointer from a function that returns it and then wrapping it in the smart pointer (obviously not a good idea); the only other way I can think of to fix it is maintain global instances of the smart pointer for those cases where this is a problem.
19:22
<@ToxicFrog>
Aah.
19:23
<@ToxicFrog>
Make the object itself reference-counted rather than the pointers to it?
19:23
<@ToxicFrog>
Switch to a language with a mark-and-sweep garbage collector?~
19:23
< celticminstrel>
I'm not switching languages. 9_9
19:24
< celticminstrel>
And I'm unsure what you mean by the other thing, but I suspect it's not in my ability since the "object" is owned by the SDL.
19:27
<@ToxicFrog>
Aah.
20:46 Attilla [Some.Dude@Nightstar-791ffadc.threembb.co.uk] has quit [Ping timeout: 121 seconds]
20:49 Attilla [Some.Dude@Nightstar-a4bfbc02.threembb.co.uk] has joined #code
20:50 mode/#code [+o Attilla] by Reiver
21:37 * TheWatcher vaguely pokes the python people here
21:38
< celticminstrel>
Hm?
21:39
<@TheWatcher>
I have run into a question that is making me O.o vaguely - http://pastebin.starforge.co.uk/419
21:39
<@TheWatcher>
Not being a pythonhead, I can't directly answer it, beyond the high suspicion that said asker doesn't know WTF they're talking about
21:40
<@TheWatcher>
but I put it to people here who may know
21:42
< Namegduf>
He can expect it to fail with an error because os.system() executes the command in a subshell.
21:42
< Namegduf>
Aside anything else.
21:42
< Namegduf>
It's similar to system() in C.
21:43
< Namegduf>
The part of it inside the os.system() brackets looks pretty made up.
21:43
<@TheWatcher>
Yeah
21:43
< Namegduf>
The last paragraph, too.
21:43
< Namegduf>
"inside the Python terminal"
21:44
< Namegduf>
Assuming that they actually have an external program which will jump to an address passed to it, their problem is that they don't understand virtual memory.
21:46
< Namegduf>
Possibly, specifically, that it's per-process aside for threads being involved, and any externally invoked command is a separate process.
21:46
<@TheWatcher>
Yeah, I know that bit - is it possible to get any kind of machine code into a running python terp?
21:46
< Namegduf>
I have no idea.
21:47
< Namegduf>
I'd ask them to define what they mean by "into Python"
21:47
< Namegduf>
Also, "a machine code".
21:47
<@TheWatcher>
As in compiled assembler code
21:48
< Namegduf>
Alright, so how is it "in" Python?
21:48
<@TheWatcher>
in the address space, I guess
21:48
<@TheWatcher>
If this was me, in C, I'd just do it using inline assembler, but I suspect python doesn't let you pull such shenanigans?
21:49
< Namegduf>
As vaguely as that, you could get it mapped in by loading it as data.
21:49
< Namegduf>
I very much doubt it.
21:49
< Namegduf>
At any rate, they themselves should know what they did.
21:50
<@TheWatcher>
Right, I'll go and get the idiot to clarify with actual code, and if he's not just wasting my time I'll see...
21:50
< Namegduf>
It does very much look like he doesn't know what he's talking about.
21:50
<@TheWatcher>
Yeah
21:50
<@TheWatcher>
Wouldn't surprise me from this guy
21:51
< Namegduf>
11-13: You can't call an "assembly routine"
21:51
< Namegduf>
Assembly is not executable.
21:51
< Namegduf>
Assembled assembly is; but it just becomes more of the already compiled stuff.
21:51
<@TheWatcher>
Indeed
21:52
<@TheWatcher>
Well, mail dispatched, if he's still completely full of fail in his reply I'll just ingore him...
21:55
< Namegduf>
I have never heard, ever, of a way to call into precompiled code from Python without using a function call to a precompiled module.
22:06
< gnolam>
http://www.youtube.com/watch?v=MDrqBYkco-Y
22:06
< gnolam>
And the associated white paper: http://www.livet.se/mahoney/c64-files/Cubase64_White_Paper_by_Pex_Mahoney_Tufves son.pdf
22:10
< gnolam>
(DSPing with a C64)
22:10 kwsn [kwsn@31356A.5FD175.2259B6.DFACD4] has joined #code
22:25
<@McMartin>
(ISTR the SID had serious problems with dynamic range.)
22:25
< celticminstrel>
?
22:26
<@McMartin>
The SID was the C64's sound chip. It had a number of interesting DSP functions it could apply to its oscillators, but it only had a single global volume level that applied to all channels equally.
22:27
< celticminstrel>
ISTR?
22:27
< gnolam>
I Seem To Recall.
22:27
< celticminstrel>
Ah.
22:28
<@McMartin>
Caveat: Am at work, didn't read the white paper, is entirely possible this is using the CPU as a general input transformer
22:29
<@McMartin>
In which case, ehn. 65xx chips are still sold for embedded purposes already, you don't need to cannibalize C64s for that.
22:34
< gnolam>
The actual processing is done on the CPU, and then some undocumented features of the SID are used to actually play the sound.
22:34
< gnolam>
The audio input isn't realtime; it's downsampled with some compression to fit within the 50 or so k of memory available.
22:37
<@McMartin>
Aha.
23:01 You're now known as TheWatcher[T-2]
23:04 You're now known as TheWatcher[zZzZ]
23:14 celticminstrel [celticminst@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
23:56 shade_of_cpux is now known as cpux
--- Log closed Thu Oct 07 00:00:07 2010
code logs -> 2010 -> Wed, 06 Oct 2010< code.20101005.log - code.20101007.log >