code logs -> 2006 -> Wed, 23 Aug 2006< code.20060822.log - code.20060824.log >
--- Log opened Wed Aug 23 00:00:01 2006
--- Day changed Wed Aug 23 2006
00:00
< fhtagncaps>
10 to 35 in the docs, Reiv.
00:00
<@Reiver>
Oh, right
00:00
< fhtagncaps>
Which it manifestly isn't, being 42.
00:07
< McMartin>
By "your" here I mean "Sun", yes.
00:08
< McMartin>
I'd suggest fixing this by toUpper()ing it first, so that it will also accept A7A6
00:10 * Reiver does so!
00:10 * Reiver doublechecks its functionality.
00:10
<@Reiver>
...The upper case is also 42.
00:11
<@Reiver>
Curious
00:11
<@Reiver>
There /is/ something odd there.
00:13
< GeoTube>
I agree.
00:13
< GeoTube>
I'm starting to believe that 42 wasn't "randomly though of" for being that number .. *looks at other proof*
00:13
< GeoTube>
[as in that number for the answer]
00:16
< McMartin>
You're confusing it with 17 and 23.
00:20
<@Reiver>
Odd...
00:21 * Reiver pokes at it with a few other things to see how it reacts.
00:21
< McMartin>
What happens if you subtract 'A' from it the uppercased one and then just assign the result outright to an integer?
00:26
<@Reiver>
Hm?
00:26
<@Reiver>
Oh
00:26 * Reiver will give that a shot, one sec
00:27
<@Reiver>
-1
00:27
<@Reiver>
So it's not integer-ating.
00:27
<@Reiver>
Or some such.
00:27
<@Reiver>
Er.
00:27
<@Reiver>
It works if I don't poke it too hard? ^^;
00:28
<@Reiver>
(Say what you will about Procedural, it's easier to work out where to put Debug outputs... >.<)
00:31 * Reiver pokes at it. Why are you cycling one way and not the other? I am certain that bit of the script must be working, surely.
00:35
<@Reiver>
Oh! You start infinitely looping.
00:36
<@Reiver>
...Which is a very interesting trick.
00:46
<@Reiver>
Hey, McM?
00:47
<@Reiver>
Is there any way in Eclipse to trace the activities through code step-by-step?
00:47 * Reiver suspects not, considers it worth asking anyway.
00:47 Schlock [~schlock@Nightstar-6915.hsd1.or.comcast.net] has quit [Quit: Can I shoot the attorney?]
00:48
<@Vornicus>
Yes.
00:48
<@Reiver>
Ooh
00:49
<@Reiver>
What button do I need to push?
00:49
<@Vornicus>
Put in a breakpoint where you want to start tracing, and choose debug.
00:49
<@Vornicus>
Both are in the debug menu.
00:49
<@Vornicus>
er
00:49
<@Vornicus>
the run menu.
00:50
<@Vornicus>
THen you'll get the ability to step through your code one thing at a time.
00:54 * Reiver nod!
00:54 * Reiver also throws a few debug statements in and
00:54 * Reiver ...
00:55
<@Reiver>
a7a6 is parsing to 8 6 8 5.
00:55
<@Reiver>
Oh, no
00:55
<@Reiver>
7 6 7 5
00:55
<@Reiver>
So the offset is... /more/ than 42?
00:55
<@Reiver>
wut?
00:56
<@Reiver>
...Waaaataminute.
00:56
<@Reiver>
49 is a thingy character.
00:58
<@Vornicus>
49.chr = 1
00:58
<@Vornicus>
'1'
01:00
<@Reiver>
Yes.
01:00
<@Reiver>
I am... pondering that.
01:00
<@Reiver>
As I wanted to subtract one. >.>
01:02
<@Vornicus>
heh.
01:03
<@Reiver>
Why are you inf looping?
01:03 * Reiver eyes the code, pokes at it.
01:05
< Chalcedon>
do you have your code up somewhere Reivy?
01:05
<@Reiver>
...
01:05
<@Reiver>
Oh.
01:05
<@Reiver>
You dummy.
01:05
<@Reiver>
Heh.
01:05
< Chalcedon>
?
01:06
<@Reiver>
Making "Complete" a boolean instance variable is a bad thing. >.<
01:06
< Chalcedon>
uh, yeah, sounds that way.
01:06
<@Reiver>
As it goes through once, sets itself to true, and is never recreated.
01:06
< Chalcedon>
...oops
01:06
<@Reiver>
And then I wonder why it suddenly starts looping, when that was my input loop controller.
01:07
<@Reiver>
Heh.
01:07 * Reiver continues.
01:07
< Chalcedon>
I think you found your problem
01:07
< McMartin>
When is this thing due?
01:07
< Chalcedon>
in 5 hours
01:07
<@Reiver>
McM: Er. In 5 hours.
01:07
<@Reiver>
I've been working on it for weeks.
01:07
<@Reiver>
But things only really started coming together in the last couple days, and I only swallowed my pride enough to actually ask for help yesterday. >.<
01:12
<@Reiver>
Right! Loop is sorted.
01:12
< Chalcedon>
yay
01:12
<@Reiver>
...Now to figure out why my peices are not actually shifting.
01:15
< himi-sleeping>
Is it the pieces that aren't having their positions reset, or the display of them that isn't updating?
01:16
<@Reiver>
himi: The peices are not moving. The act of moving them would alter what the display shows.
01:16
<@Reiver>
As the display is just a set of System.out.Print's on the array itself.
01:16
<@Reiver>
So if nothing moves, nothing in the array has changed.
01:16
<@Reiver>
public void movePeice(int locX, int locY, int newX, int newY) throws Exception {
01:17
<@Reiver>
if(getSquare(locX,locY) != null && getSquare(locX,locY).getSide() == Chess.currentPlayer() && //If the square is not empty, and the players colour
01:17
<@Reiver>
getSquare(locX,locY).isLegal(newX, newY) && //and the destination move matches the peices movement rules
01:17
<@Reiver>
isLegal(newX, newY) ) { //and the destination move is within the Chessboards rules - boundaries, etc
01:17
<@Reiver>
setSquare(newX,newY,getSquare(locX,locY));
01:17
<@Reiver>
getSquare(newX,newY).setPosition(newX, newY);
01:17
<@Reiver>
setSquare(locX,locY,null);
01:17
<@Reiver>
}else throw Exception;
01:17
<@Reiver>
}
01:17
<@Reiver>
...And incidentally, that syntax for Exception throwing I just tacked on is wrong. *grabs text book*
01:18
< McMartin>
throw new RuntimeException("Your Message Here")
01:19
< McMartin>
You might actually want to make a new IllegalChessMoveException class that extends Exception, just to be clean about it
01:19
< McMartin>
Since Exceptions are caught based on their type.
01:19
< McMartin>
(This is another one of the few places inheritance -- well, really, just subtyping -- is reasonable.)
01:20 * Reiver nods.
01:20
<@Reiver>
}else throw new RuntimeException("Illegal Move!");
01:20
<@Reiver>
Is what you had in mind?
01:20
< McMartin>
Something like that
01:20
<@Reiver>
right
01:20
< McMartin>
It's kind of bad form to use Exception or RuntimeException directly, though, since it makes it impossible to treat Illegal Moves and, say, a programming error resulting in a NullPointerException differently
01:20
< McMartin>
Since that latter will also be caught by "catch (Exception e)"
01:25 * Reiver nods.
01:26
<@Reiver>
So I need a new class for MoveException.
01:26
< McMartin>
"public class MoveException extends Exception {}" will probably do it.
01:26
<@Reiver>
public class IllegalChessMoveException extends Exception {} is the right syn--right!
01:32
<@Reiver>
...Odd
01:33 himi-sleeping is now known as himi-coffee
01:33
<@Reiver>
try {
01:33
<@Reiver>
Chessboard.instance.movePeice(moveList.get(ran).oX(), moveList.get(ran).oY(), moveList.get(ran).nX(), moveList.get(ran).nY());
01:33
<@Reiver>
} catch(IllegalChessMoveException e) {
01:33
<@Reiver>
System.out.println("Debug:AI code submitted illegal move");
01:33
<@Reiver>
}
01:33
<@Reiver>
Complains about an unhandled exception type Exception.
01:33
< McMartin>
movePeice, I assume, is declared as "throws Exception"?
01:34
<@Reiver>
Yes.
01:34
< McMartin>
Redeclare it to only throw IllegalChessMoveException.
01:34
<@Reiver>
Oh, er.
01:34
<@Reiver>
public void movePeice(int locX, int locY, int newX, int newY) throws IllegalChessMoveException {
01:34
< McMartin>
"throws Exception" means "Just about anything could go wrong here, and anyone who calls me better be prepared to deal with it."
01:34
< McMartin>
What about in the Player Interface?
01:35
<@Reiver>
Come again?
01:35
< McMartin>
Is movePeice is part of the superclass that AI and Human inherit from?
01:35
< McMartin>
Wait, I guess not.
01:36
< McMartin>
...
01:36
<@Reiver>
No, it's a Chessboard method...
01:36
< McMartin>
Ok, wait, I misread something
01:36
< McMartin>
Hmm
01:36
<@Reiver>
And that's the script for the AI try/catch.
01:36
<@Reiver>
The Human try/catch has an identical catch statement.
01:36
<@Reiver>
Yet has no error.
01:36
<@Reiver>
(They both call movePeice, 'course.)
01:36
< McMartin>
Hmm
01:38
<@Reiver>
Seems a little odd.
01:38
<@Reiver>
I must've done something Stupid(tm)...
01:38
< McMartin>
Or there's some synchronization problem. Try to edit the AI code trivially and force a recompile
01:39
<@Reiver>
Ah, 'tis gone.
01:39
< McMartin>
OK, that one was Eclipse's fault, then.
01:40 * McMartin is going to look into turning off autocompile, since it's clearly not working right.
01:41
<@Reiver>
It /mostly/ works...
01:41
<@Reiver>
>.>
01:41
< McMartin>
Yeah. Is "Clean" greyed out as well in your Project menu?
01:41
< McMartin>
If not, you can use it to force it to recompile everything.
01:41
<@Reiver>
No
01:42
<@Reiver>
Oooh
01:42
<@Reiver>
ok
01:42 * Reiver eyes, pokes something.
01:42
<@Reiver>
How do I get breakpoints to actually pause the code?
01:42 * McMartin tends instead to turn off Build Automatically in the same menu and just hit Control-B to rebuild all before running.
01:42
< McMartin>
Hmm. I don't actually use breakpoints in Java much, and I've never done it in Eclipse.
01:42
< McMartin>
I suspect that it involves running in some kind of debug mode, though.
01:43
< McMartin>
Try setting your breakpoints then saying "Debug Last Launched" from the Run menu.
01:43
< McMartin>
Which is F11 on my version of Eclipse, but that's Fedora's version of it, which you aren't using.
01:44 * Reiver nods.
01:48 * Reiver now tries to work out what the the hell his code is doing.
01:48
<@Reiver>
...Agh.
01:49
<@Reiver>
It won't tell me the state of methods that return stuff...
01:49
< McMartin>
"state"?
01:49 * Reiver tries to think how the hell you check .getSquare() to see what's inside it in an if statement.
01:51
<@ToxicFrog>
I have no idea what you're asking.
01:51
<@ToxicFrog>
But I'm to take a random guess and say "with a debugger"
01:51
< McMartin>
There's some kind of confusion elsewhere.
01:51
< McMartin>
I mean, what's inside getSquare() is program code, which you run when you call getSquare().
01:52
<@Reiver>
Ah, yes.
01:52 * Reiver puts a breakpoint in getSquare!
01:56 * Vornicus goes hoem
01:57 Vornicus [~vorn@Nightstar-18307.slkc.qwest.net] has quit [Quit: ]
01:59
<@Reiver>
Is there a quick and easy way to output all the arguements in a logical expression, or does one just type System.out.println(Var1 + " " + Var2 + " " + etc);?
01:59
< McMartin>
That is, pretty much, the easiest way to do it, unless they're in a Collection, in which case you can just print htat.
02:01 * Reiver frowns.
02:02
<@Reiver>
And you can't println(if(xyz = abc)); either.
02:02
<@Reiver>
Which makes sense, but is mildly less convinient when one just wants to have true or false outputted >.>
02:04
< McMartin>
You shoud be able to print "println(xyz == abc)".
02:04
< McMartin>
xyz = abc is an assignment statement, not a boolean expression.
02:06
< McMartin>
Unlike C, Java does not happily compile incorrect code when you forget an equals sign.
02:06
< McMartin>
(saying "if (xyz = abc) in C will assign the value of abc to xyz, then branch true if that value isn't zero.)
02:06 You're now known as TheWatcher
02:10 * Chalcedon waves to TW
02:11
< Chalcedon>
not compiling incorrect code sounds like a /good/ thing
02:11
< McMartin>
Sometimes it's not incorrect.
02:11
< McMartin>
C believes that the programmer knows what he wants, and deserves to get it good and hard.
02:11
< McMartin>
C++ inherits this, while adding many more ways of doing so.
02:11
< Chalcedon>
that could be a problem
02:11 * Chalcedon urk! rain! my washing!
02:12
< McMartin>
In particular, C doesn't distinguish between statements and expressions, so you can check the truth value of anything.
02:12
< McMartin>
It also doesn't have a real boolean type.
02:12
< McMartin>
C++ pretends to, but doesn't.
02:14 * Chalcedon boggles at the idea of a programming language pretending to do something
02:14
< McMartin>
C++ has a "type" called "bool"
02:14
< McMartin>
However, bool is a kind of enumerated type
02:15
< McMartin>
bools, enums, and integers are all actually the same thing.
02:15
< McMartin>
So you can add one to false.
02:15
< Chalcedon>
o.O
02:15
< McMartin>
C and C++ are what we in the business call "weakly typed languages".
02:15
<@Reiver>
...Ohhh...
02:15
<@Reiver>
if(getSquare(locX,locY).getSide() == (Chess.currentPlayer()))
02:15 * Chalcedon sees the light
02:15
< McMartin>
Java is Strongly Typed. Mostly.
02:15
<@Reiver>
That doesn't work, does it.
02:16 * Reiver thwap forehead regarding using == on reference variables. >.<
02:16
< McMartin>
Well
02:16
< McMartin>
If it's Exactly The Same Object, it works, Reiver.
02:16
<@Reiver>
This isn't.
02:16
<@Reiver>
Uh.
02:16
< McMartin>
Yeah, you'll be wanting .equals().
02:16
< McMartin>
And to be defining equals().
02:16
<@Reiver>
Oh dear.
02:17
< McMartin>
Wait.
02:17 * Reiver er. How would one define equals? >.>
02:17
< McMartin>
Override public boolean Object.equals (Object o).
02:17
<@Reiver>
...?
02:17
< McMartin>
There's a method every object has, called "equals(Object)".
02:18
<@Reiver>
Right
02:18
< McMartin>
Returns a boolean if the two objects "have the same value".
02:18
< McMartin>
Defaults to ==.
02:18
<@Reiver>
Ah.
02:18
< McMartin>
Which is sometimes right, but usually isn't, so you need to write a special version for each type that gets compared.
02:18
<@Reiver>
I need to get it to change to ... thingy.
02:18 * Reiver nods.
02:18
< McMartin>
Presumably, to see whether or not the field that represents which side it is is the same or not
02:19
< McMartin>
Though really, you could also just make getSide() and friends return integers~
02:19
<@Reiver>
They're returning booleans.
02:19
< McMartin>
You can == booleans.
02:19
< McMartin>
Chess.currentPlayer() returns a boolean too?
02:19
<@Reiver>
Yes.
02:19
<@Reiver>
...So that this is not working is due to something else gone odd.
02:19
< McMartin>
You should be golden, then, yes.
02:19
< McMartin>
Check to see what they're returning
02:20
<@Reiver>
Both boolean...
02:20
<@Reiver>
Clearly it is something wrong with my calls instead.
02:20
< McMartin>
Well
02:20 * Reiver frowns.
02:20
< McMartin>
I meant, "true or false"
02:21
<@Reiver>
Both should be returning true, I'd hope.
02:21
< McMartin>
Confirm that first.
02:21 * Reiver puts in stop thingies!
02:21
<@Reiver>
breakpoints.
02:21
<@Reiver>
>.>
02:21
< McMartin>
Especially since a7a6 is a move for Black.
02:21
< McMartin>
And so should be an illegal first move.
02:22
<@Reiver>
...Oh dear, have I been that dense?
02:22 * Reiver checks. >.<
02:22
< McMartin>
e2e4 is a traditional first move for White.
02:22
< McMartin>
P-K4, if you will.
02:23
<@Reiver>
I've been using knights on the basis that they had simpler rules for movement than pawns, and I was trying to cut down on confusion.
02:23
<@Reiver>
...
02:23 * Reiver eyes.
02:23
<@Reiver>
That's a pretty stack.
02:23
< McMartin>
I like stack traces
02:24
< McMartin>
That's one reason I don't use breakpoints much; I just have the program dump stack traces occasionally and that usually quite suffices.
02:25
<@Reiver>
if(Chessboard.instance.getSquare(destX, destY).getSide() != side)
02:25
<@Reiver>
Can't handle null pointers.
02:25
< McMartin>
Indeed it cannot.
02:25
<@Reiver>
This is obvious enough; but how do I get it so it /does/?
02:25
< McMartin>
Three approaches.
02:25
<@Reiver>
If statement checking .getSquare for null?
02:25
< McMartin>
That's (1).
02:26
< McMartin>
(2) is to make getSide() be part of Chessboard, taking a Piece reference as its argument, and checking for null in it.
02:26
< McMartin>
(3) is to fill the blank spaces with a new Piece subclass BlankSquare, and implement getSide() to return a third value. This means "Side" can't be boolean, though.
02:27
<@Reiver>
I think I'll go with 1.
02:27
< McMartin>
(1) is probably the easiest unless you're doing this all over the place, in which case shoving the code into one routine (that is, (2)) is the answer.
02:27
<@Reiver>
Nah, I think it's just here.
02:27
<@Reiver>
I was trying to be clever. >.>
02:28
< McMartin>
A rule of thumb I've seen used in various places is "Once you've written the same code three times, make it a function instead."
02:29 * Vornicus-Latens usually does it with twice.
02:30
< McMartin>
Depends on the size of the code.
02:30
<@Reiver>
YES
02:30
<@Reiver>
HAHA
02:30
<@Reiver>
The knight finally moves; it was the nulls tripping it.
02:30
<@Reiver>
Now to play with ze ozzers!
02:31 * Chalcedon gives Reiver a cookie
02:50 * Reiver stabs pawns.
02:50
< McMartin>
They have the most complicated moves. Do them last.
02:50 Vornicus-Latens is now known as Vornicus
02:50
< McMartin>
Remove the pawns from the initial board to test the other pieces first.
02:59
<@Reiver>
...I hadn't thought of that.
02:59
<@Reiver>
Well, they move forward ok.
02:59
<@Reiver>
They don't do the two-squares-move yet.
03:00
< McMartin>
And captures, I assume, are right out?
03:03
<@Reiver>
I'm about to check.
03:04
<@Reiver>
Although there seems something odd with the pawn collision detection as it is - they can't move in front of another peice, they hang one square back...
03:04
< Chalcedon>
hrm
03:04
<@Reiver>
...Queens can't move diagonal either.
03:04 * Reiver sets things up for a forward move.
03:05
<@Mahal>
....
03:05
<@Mahal>
queens can move anywhere, hon.
03:05
<@Mahal>
The only move they can't do is the knight hop
03:06
<@Reiver>
I mean my queens can't.
03:06
<@Reiver>
:p
03:06
<@Reiver>
Hrm
03:06 * Mahal grins
03:06
<@Reiver>
And it appears the out-of-bounds is not tight enough.
03:07
<@Reiver>
As it threw a nice error, then promptly had the JVM complain anyway.
03:07
<@Reiver>
Clearly it did not throw well enough... >.>
03:07
< McMartin>
Mahal: There are moves such as right 1, up 4 that no piece can make.
03:09
<@Reiver>
...Ohhhh.
03:09
<@Reiver>
I geddit.
03:10 * Reiver puts an isLegal into getPeice.
03:10
<@Reiver>
Because otherwise it throws a shiny little 'false', but has already tried to access an out of bounds thingy.
03:12
<@Mahal>
I meant to say, the queen can do any move that any other piece can, with the exception of the knight.
03:12
<@Mahal>
:P
03:13 himi-coffee is now known as himi-heading-to-work
03:16 Derakon [~Derakon@Nightstar-13202.sea2.cablespeed.com] has joined #code
03:16 * Derakon eyes this place.
03:16 * Chalcedon eyes back
03:17
< Derakon>
Why wasn't I informed of this channel earlier?
03:17
< Chalcedon>
because you didn't go looking for it?
03:17
< Chalcedon>
Reiver how are you submitting this?
03:17
<@Reiver>
Electronically.
03:17
< Chalcedon>
handy.
03:17
<@Reiver>
I rather thought so...
03:17
<@Reiver>
>.>
03:19
< Derakon>
I didn't know you coded, Reiver.
03:19
< McMartin>
Does homework count?~
03:19
< Derakon>
Yes.
03:19
< Chalcedon>
Reiver has an assignment due in.... 2.5 hours.
03:19
< Derakon>
It counts at least as much as my latest project.
03:20
< Derakon>
(Making the Dungeon Crawl cards, I mean)
03:20 himi-heading-to-work is now known as himi-really-heading-to-work
03:20
< Chalcedon>
bye himi
03:22 * Chalcedon decides to stop being impolite and introduce herself.
03:22
< Derakon>
Pheh. I didn't bother doing that myself.
03:22 * Reiver frown.
03:22 * Chalcedon gives Reiver a cookie.
03:22
< Chalcedon>
it doesn't really work very well in here does it?
03:22
<@Reiver>
heh
03:22
< Derakon>
We pretend it does. :)
03:23 * Chalcedon is a biologist, and beginner at programming
03:23
< Chalcedon>
currently I have a tendency to be grumpy as I have an exam Friday morning.
03:24
< Derakon>
Go biology. Good science.
03:24
< McMartin>
Yay bio.
03:24
< Chalcedon>
:)
03:25 * McMartin is a Computer Science grad student and programming language geek -- his actual work mostly involves program analysis and security stuff, his hobby stuff is mostly 2D games.
03:25
< McMartin>
With the occasional foray into 3D stuff.
03:25
< Derakon>
I'm a computer science B.A., currently working the corporate life.
03:25
<@Reiver>
And today he is being a very kind man and helping me with homework. >.<
03:25 * Reiver is usually much better than this... granted, he's not usually trying to code java.
03:25
< Derakon>
Ew, Java. ¬.¬
03:26
<@Reiver>
This is the universal sentiment, yes. :p
03:26
<@Reiver>
(McM possibly excluded.)
03:26
< Derakon>
I can appreciate it in theory, but in practice, it's an ugly language without even the brevity of, say, Perl (another ugly language).
03:26
< McMartin>
I'm rather a partisan of the language, at least for instructional and middleware use.
03:26
<@Reiver>
McM: Yeah, but you helped write it~
03:26
< McMartin>
No, no
03:26
<@Reiver>
(I'm kidding.)
03:26
< McMartin>
I said I wrote the book, or near enough.
03:26 * Derakon snerks.
03:27
< McMartin>
I didn't write it. That was the guy I shared an office with. (Or at least, a complete standalone JVM.)
03:27
< Derakon>
Sun wrote the language.
03:27
<@Reiver>
>.>
03:27
< McMartin>
Given the amount of trouble Revier's already had with reference confusion and if (a=b) errors, it's just as well he's got a language that catches these for him.
03:27
< Derakon>
Trtue.
03:27
< Derakon>
But I'd rather people learned on, say, Python.
03:28
< Derakon>
Er, true.
03:28
< Chalcedon>
well, at least I did one thing right.
03:28 * McMartin TAed the same course twice, once in C++ and once in Java. The Java version his office hours were full of questions about the course material. The C++ one, it was all on pointer and template misuse.
03:28
<@Reiver>
The school I'm from has introduced Java as our Very Second Language after two and a half years of C/C++.
03:28
< McMartin>
... They teach C/C++ first?
03:28
<@Reiver>
Yes.
03:28
< Derakon>
Traditionalists.
03:28
< Chalcedon>
I thought the paper was 200 level?
03:28
< McMartin>
Somebody needs trouting.
03:28
< McMartin>
Traditionalists start with LISP.
03:29
< McMartin>
Though I could see Python working there.
03:29
< Derakon>
No, that's Emacs nuts.
03:29
<@Reiver>
Everyone else in this course has already had about a years worth of data structures and pointers.
03:29
< McMartin>
Also all the Top Four.
03:29 * Derakon ponders starting beginners on SML.
03:29
< McMartin>
UMAA does that.
03:29
< McMartin>
MIT, Berkeley, and CMU start them on Scheme, a LISP dialect.
03:29
<@Reiver>
So they tended to gloss that in class, which is possibly why I keep doing stupid syntax mistakes. >.>
03:29 * Reiver understands the theory of it all...
03:29 * Mahal notes her uni taught C++ as a first language
03:30
< Derakon>
To be fair, data structures aren't really syntax. But the other people *have* had more experience with the language; that always helps.
03:30
< McMartin>
Berkeley starts at Lisp, then moves through Java to C and assembler. However, nobody teaches you the language; you're expected to pick it up on your own over a week or so.
03:30
< McMartin>
Or take a self-paced course first.
03:30
<@Reiver>
I branched off and messed about with Python and VB (Informally), and have dived back in. I don't remember most of teh C I learned given it was three years ago that I learned it. And never touched it since. >.>
03:30
< McMartin>
And yeah, Data Structures used to be taught in C++, but it was a form of it that produced Bad C++ Coders.
03:31 * Reiver nods.
03:31
<@Reiver>
They, uh, sort of teach you the language here.
03:31
<@Reiver>
Obviously not enough~
03:31 * McMartin has, to date, only found C++ useful for implementing GUIs and video games. And even there, Lua and friends make games just as feasible in C/Lua, and more hybrid.
03:31
< McMartin>
Er, and more extensible.
03:32
< Derakon>
Clearly a hybrid program is more robust. ¬.¬
03:32
< McMartin>
Harder to debug, but you don't have to worry about C++ linking hell.
03:33
< Derakon>
I've just been writing everything in Perl these days, because that's what I work in. And I'm lazy.
03:33
< McMartin>
My Day Job work is all Java, with occasional forays into Python, and my hobby work is almost all C.
03:33
< McMartin>
Sable was C++, though.
03:33
< McMartin>
UQM, though...
03:34
< Derakon>
Written in NES assembler?
03:34
< McMartin>
Nah, I gave up on that as Not Worth the Effort.
03:35
< McMartin>
Especially since that community spends too much time with its head up its ass, unlike, say, the IF community, which is still "retro" but has pretensions towards Improving The Art.
03:35
< Derakon>
Incidentally, this is really freaky: http://www.youtube.com/watch?v=S3FtRV2VqkE
03:37
<@Reiver>
Um
03:37
<@Reiver>
if(Math.abs(xOffset(destX))==(Math.abs(yOffset(destY))))
03:37
<@Reiver>
Does this hit the reference problems?
03:38
< McMartin>
Math.abs returns an int, right?
03:38
<@Reiver>
It should theoretically be returning an int.
03:38
<@Reiver>
Yeah.
03:38
< McMartin>
ints are not references, so.
03:38 * Reiver pokes at it.
03:38
<@Reiver>
For some reason, diagonal movement is not being approved of. >.>
03:40
< Derakon>
Are you trying to move by something less than 1?
03:40
< Derakon>
Remember, the int of .75 is 0.
03:40
<@Reiver>
Nope.
03:40
< McMartin>
abs, not fabs.
03:40
<@Reiver>
protected int xOffset(int newX) { //Returns the X offset of the destined position compared to the current position.
03:40
<@Reiver>
return newX-posX;
03:40
<@Reiver>
}
03:40
<@Reiver>
protected int yOffset(int newY) { //Returns the Y offset of the destined position compared to the current position.
03:40
<@Reiver>
return newY-posY;
03:40
<@Reiver>
}
03:41
<@Reiver>
For some reason it's not being terribly co-operative.
03:41
< Derakon>
Add print statements to check your input and output values.
03:41
< Derakon>
Never underestimate the value of System.out.println (the name of which, incidentally, is one of the reasons I dislike Java. Too wordy).
03:41 * Reiver has been doing that...
03:42
< McMartin>
Derakon: namespaces or name conflicts, choose one~
03:42
< Chalcedon>
so the input/outputs are correct then? not one out like before?
03:43
< Derakon>
Name conflicts, definitely. You can always be precise if you need it, and conflicts can throw an error if there's ever doubt.
03:44
< McMartin>
No, sometimes they just stomp on each other and fail mysteriously 3,000 instructions later.
03:44
< Derakon>
I'd say that's a compiler problem, though.
03:45
< McMartin>
Depends on circumstances. externs are supposed to be defined in multple places.
03:46
<@Reiver>
...Dear Reiver.
03:47 * Derakon smiles.
03:47
<@Reiver>
When you are constructing Queens.
03:47
< McMartin>
Though I think that C89 at least forbids you from declaring non-extern versions more than once.
03:47
<@Reiver>
Do not use isDiagonal && isStraight ...
03:47 * Reiver headdesk.
03:47
< Derakon>
Use isLesbian and isStraight?
03:47
< McMartin>
||
03:47
<@Reiver>
McM: I'd gathered that one. :p
03:48 * Mahal hugs Reiv.
03:50
<@Reiver>
(Incidentally my victory testing is perfectly fine.)
03:50
<@Reiver>
(Go me!)
03:50 * Reiver now ponderates these $#@! pawns.
03:50 * Reiver also ponders he should start testing the AI soon, but should get the pawns working first hey? >.>
03:50
<@Reiver>
Hrm.
03:50 * Chalcedon makes a plate of cookies magically appear on Reiver's desk
03:51 * Reiver nrom. Mmm. Sugar.
03:51 * Mahal also points at the soop
03:51
< Derakon>
Good for your brain!
03:51
< Chalcedon>
have you eaten today?
03:51
<@Reiver>
uh
03:51
<@Reiver>
Define "Today" and "Eaten"
03:51 You're now known as TheWatcher[afk]
03:52
< Derakon>
"Today" == "Since you last slept", and "eaten" == "ingested solid nutrients".
03:52
< Chalcedon>
since you got up ~10am and something substantial eg fruit, soup, toast etc...
03:52
<@Reiver>
Ah.
03:52
<@Reiver>
Then no.
03:52
<@Reiver>
>.>
03:52
<@Reiver>
I did eat at 6AM though.
03:52 * Chalcedon points Reiver in the direction of microwave and soup
03:52
<@Reiver>
woe
03:53
<@Reiver>
Once I got these pawns working.
03:53
< Chalcedon>
you will think better.
03:53
<@Reiver>
Whereapon the last step will be the AI, and I will be done.
03:53
<@Reiver>
(Terrifying thought, really...)
03:53
< Chalcedon>
if you put it on to heat up now, you can eat it once the pawns work
03:53
< Chalcedon>
you might even have it done arly
03:53
< Chalcedon>
-er-
03:53
< Chalcedon>
*early
03:53
< Chalcedon>
(not by much admittedly...)
03:54 * Chalcedon applies 4x2 to pawns while Reiver is away
03:54 * Mahal makes plots to stuff Reiver with food whilst he's here.
03:54
< Chalcedon>
that sounds like an excellent idea.
03:55 * Chalcedon would offer to go stuff Reiver with food now, but suspects she'd be in the way
03:56
<@Reiver>
Aha.
03:56
<@Reiver>
I have the jump-move /half/ working.
03:56
<@Reiver>
Need to work out why the black can't do the same move.
03:56
<@Reiver>
...Which shouldn't really be a problem, but for some arcane reason it is. Hrmm.
03:57
<@Reiver>
private int colourDirection() {
03:57
<@Reiver>
if(getSide() == BLACK)
03:57
<@Reiver>
return -1;
03:57
<@Reiver>
else
03:57
<@Reiver>
return +1;
03:57
<@Reiver>
That works fine.
03:58
<@Reiver>
private int pawnRow(int dist) { //Measures the distance from the colours starting edge in number of squares. Thus, the second (starting row for pawns) is 2, as it is the SECOND row.
03:58
<@Reiver>
if(getSide() == BLACK)
03:58
<@Reiver>
return 8-dist;
03:58
<@Reiver>
else
03:58
<@Reiver>
return dist-1;
03:58
<@Reiver>
}
03:58
<@Reiver>
That does not.
03:58
<@Reiver>
It works fine for pawns moving /up/ the board, but not the pawns moving down?
03:58
< Derakon>
Up is positive?
03:59
< Derakon>
Or negative?
03:59
<@Reiver>
Yes.
03:59
<@Reiver>
Up is positive increments, down is negative.
03:59
< Derakon>
So the bottom of the board is zero, then.
03:59
<@Reiver>
Correct.
04:00
<@Reiver>
It's an array. 0-7
04:00
< Derakon>
And your distance calculation is then accounting for the fact that dist ranges from 1 to 8 instead of 0 to 7. Except you're only doing it for white.
04:00
< Derakon>
Er...I think.
04:01
< Derakon>
Wait...does every pawn, from its own perspective, move from 0 to 7, or do the white pawns move from 0 to 7 and the blacks from 7 to 0? If it's the latter case, then you shouldn't be using that second if block.
04:02
<@Reiver>
public boolean isLegal(int newX, int newY) {
04:02
<@Reiver>
if(checkPath(newX, newY))
04:02
<@Reiver>
if((xOffset(newX) == 0 && newY == posY+pawnDirection && checkPath(newX, newY) || //normal movement: One square advance, no obstruction in destination square (checkPath thus checks one square further ahead than usual.)
04:02
<@Reiver>
(xOffset(newX) == 0 && posY == pawnRow(2) && newY == pawnRow(4) && checkPath(newX, newY)) || //starting square movement: Two squares advance, no obstruction in destination square or traveled square. (checkPath thus checks one square further ahead than usual.)
04:02
<@Reiver>
(xOffset(newX) == 1 && posY == posY+pawnDirection && checkDestination(newX, newY) && !Chessboard.instance.isClear(newX, newY)))) //capturing diagonally: Must move diagonal, must move one square advanced, must be a non-friendly, and /must/ be non-clear (occupied).
04:02
<@Reiver>
return true;
04:03
<@Reiver>
Er.
04:03
<@Reiver>
It's the second line I was after.
04:05
< Derakon>
You mean "if((xOffset(newX) == 0 && newY == posY+pawnDirection && checkPath(newX, newY)"
04:05
< Derakon>
?
04:05
< Derakon>
(Also, for reference: when capturing, pawns can move both left and right)
04:06
< Chalcedon>
I thought that was pawnDirection
04:06
< Derakon>
pawnDirection indicates if they're going up or down, I thought.
04:07
<@Reiver>
I caught that ater pasting, yes.
04:07
< Chalcedon>
actually you're right Derakon.
04:07
<@Reiver>
It's now Math.abs(xOffset(newX)) == 1... on that row. >.>
04:08
< Chalcedon>
so why doesn't the middle one (2 squares) have a pawnDirection?
04:08
< Derakon>
Does pawnRow(foo) take into account the pawn's direction?
04:09 * Vornicus ponders how many smart people are in here now.
04:09
<@Reiver>
See above.
04:09
< Derakon>
Oh, right.
04:09
<@Reiver>
So it /should/ be...
04:09
< Chalcedon>
as a proportion of what?
04:09
< Derakon>
We need a paste site so I don't lose this stuff off the top...
04:09
<@Reiver>
Vorn: Define 'smart'.
04:09
< Derakon>
pawnRow = (color == BLACK) ? 8 - dist: dist - 1.
04:10
< Chalcedon>
The general population of smart people? the Nightstar population of smart people? What proportion of people in here are smart?????
04:10
< Vornicus>
The nightstar population of smart people.
04:10
< Derakon>
I think you have an off by one error, Reiver. Run some sample positions through your head from Black's perspective.
04:10
<@Mahal>
Derakon, it's called "logging" :)
04:10
< Derakon>
Bah. Logs have no syntax highlighting.
04:11 * Mahal grins
04:11 * Chalcedon ponders
04:11 * Reiver wrestles.
04:11
<@Reiver>
What've I done wrong to the capture scripts...
04:12 * Chalcedon supplies mud and a fence
04:12
< Chalcedon>
can you repost for me Reiver ? in PM if necessary
04:12
<@Reiver>
(xOffset(newX) == 1 && posY == posY+pawnDirection && checkDestination(newX, newY) && !Chessboard.instance.isClear(newX, newY)))) //capturing diagonally: Must move diagonal, must move one square advanced, must be a non-friendly, and /must/ be non-clear (occupied).
04:13
< Chalcedon>
oh, oops
04:13 * Chalcedon doh
04:13
<@Reiver>
Something is not working in that, because the pawns cannot capture.
04:13
< Derakon>
Er, "posY == posY + pawnDirection" is always false.
04:13
<@Reiver>
...Where's that?
04:13
<@Reiver>
...Oh!
04:13
< Derakon>
Second test.
04:13
<@Reiver>
DOH
04:13 * Derakon pats.
04:13
<@Reiver>
Needs to be newY tested. >.<
04:15
<@Reiver>
Hm.
04:15
<@Reiver>
Still not...
04:15
<@Reiver>
...Actually, can I do that with other peices?
04:15
< Derakon>
Do what?
04:16
< Derakon>
Also, I assume you put the Math.abs back in there.
04:17
<@Reiver>
Ah.
04:17 * Reiver stab.
04:17
<@Reiver>
My checkClear method is checking the final square... not meant to do that.
04:18
<@Reiver>
protected boolean checkPath(int destX, int destY) {
04:18
<@Reiver>
int x = posX;
04:18
<@Reiver>
int y = posY;
04:18
<@Reiver>
int distance = getDistance(destX, destY);
04:18
<@Reiver>
int deltaX = direction(posX, destX);
04:18
<@Reiver>
int deltaY = direction(posY, destY);
04:18
<@Reiver>
04:18
<@Reiver>
for(int i = 0; i<distance; i++) {
04:18
<@Reiver>
x += deltaX;
04:18
<@Reiver>
y += deltaY;
04:18
<@Reiver>
if(!Chessboard.instance.isClear(x,y))
04:18
<@Reiver>
return false;
04:18
<@Reiver>
}
04:18
<@Reiver>
return true;
04:18 * Reiver examines. .../does/ that check the final square?
04:18
< Derakon>
No.
04:19
< Derakon>
If you want it to check the final square, you need to either start x and y at posX+deltaX etc., or change the bounds on your loop.
04:19
<@Reiver>
I don't want it to check the final square.
04:19 * Reiver frowns.
04:20
< Derakon>
Why not? The final square must be occupied by the piece at the end of its move, right?
04:20
< Derakon>
Or...oh, for other piece captures.
04:20
<@Reiver>
Yes.
04:20
<@Reiver>
checkDestination is a different rule that only checks for friendlies.
04:20
<@Reiver>
And is used by the knights without checkClear at all.
04:21
<@Reiver>
...checkPath. Um. Anyway.
04:23
< Chalcedon>
what else needs to be done Reiver, you're rapidly running out of time.
04:23
<@Reiver>
I need to get the movement working.
04:23
<@Reiver>
And then, assuming all is well, the AI will work.
04:23
<@Reiver>
And then all will be happy and puppies and kittens.
04:25
<@Reiver>
Of course, because the AI relies entirely on .isLegal to collect it's moves...
04:25
<@Reiver>
I sort of need to get the rules working first. >.>
04:27
< Chalcedon>
so you know what still needs checking in the movement rules?
04:27
<@Reiver>
I need to get peices capturing.
04:27
<@Reiver>
They are apparently failing at the checkClear method.
04:28
<@Reiver>
If I can get around this...
04:28
<@Reiver>
Rumor has it it should be about it.
04:29
< Chalcedon>
yay
04:56
<@Reiver>
what in the blazing hells.
04:57
<@Reiver>
h2h3 queens that pawn.
04:57
<@Reiver>
But none of the other pawns do it
04:57
<@Reiver>
public void setPosition(int newX, int newY) {
04:57
<@Reiver>
posX = newX;
04:57
<@Reiver>
posY = newY;
04:57
<@Reiver>
if(newX == pawnRow(8))
04:57
<@Reiver>
Chessboard.instance.setSquare(posX,posY,new Queen(posX,posY,side));
04:57
<@Reiver>
Nowhere in there should there be anythnig like /that/, should there?
05:01
< Vornicus>
uh
05:01
< Vornicus>
Y
05:01
< Vornicus>
Not X.
05:01
< Vornicus>
h2 has an X value of 8.
05:02
<@Reiver>
...
05:02
<@Reiver>
Of course.
05:02
<@Reiver>
I am a dolt.
05:02
<@Reiver>
Thank you.
05:03
<@Reiver>
(On the bright side, I now know the queening function runs though~)
05:03
< Vornicus>
hee
05:04
<@Reiver>
So why is the checkClear function not working.
05:04
<@Reiver>
Or rather, if it is, then what isn't?
05:05
< Vornicus>
I don't know.
05:05
<@Reiver>
It is ignoring the destination square, yes?
05:06
<@Reiver>
If I want to move between h1 and h8, it checks the squares h2 h3 h4 h5 h6 h7, but not h8, right?
05:06
< Vornicus>
I don't know.
05:06
< Vornicus>
I don't have the function in front of me.
05:06
<@Reiver>
protected boolean checkPath(int destX, int destY) {
05:06
<@Reiver>
int x = posX;
05:06
<@Reiver>
int y = posY;
05:06
<@Reiver>
int distance = getDistance(destX, destY);
05:06
<@Reiver>
int deltaX = direction(posX, destX);
05:06
<@Reiver>
int deltaY = direction(posY, destY);
05:06
<@Reiver>
05:06
< Vornicus>
And, you could add debug code to show you what it's checking.
05:06
<@Reiver>
for(int i = 0; i<distance; i++) {
05:06
<@Reiver>
x += deltaX;
05:06
<@Reiver>
y += deltaY;
05:06
<@Reiver>
if(!Chessboard.instance.isClear(x,y))
05:07
<@Reiver>
{System.out.println("CheckPath failed at step " + i); return false;}
05:07
<@Reiver>
}
05:07
<@Reiver>
return true;
05:07
<@Reiver>
}
05:07
< Vornicus>
dump x and y to the console.
05:07
<@Reiver>
ok
05:08
< Vornicus>
And if you could clean up the indentation and all that jazz, it would be good.
05:10
<@Reiver>
Sorry
05:10
<@Reiver>
...
05:10
<@Reiver>
It IS checking the last square.
05:10
<@Reiver>
RIGHT.
05:10
<@Reiver>
Step 0: 3 6
05:10
<@Reiver>
Step 1: 2 5
05:10
<@Reiver>
Step 2: 1 4
05:10
<@Reiver>
Step 3: 0 3
05:10
<@Reiver>
Er.
05:10
<@Reiver>
Mispaste
05:11
<@Reiver>
although the input to get that was Input: e8a4
05:11
<@Reiver>
It doesn't check the square you start in, but it does check the one you end in.
05:12
< Vornicus>
i < distance - 1
05:13
<@Reiver>
YES
05:13 * Reiver huggles Vorn!
05:13
<@Reiver>
Ok.
05:13
<@Reiver>
That's... everything working. Yes.
05:14
<@Reiver>
Now for the AI, and refactoring(I hope)
05:15
< Vornicus>
UNIT TESTS UNIT TESTS UNIT TESTS!
05:15
< Vornicus>
How much longer do you have?
05:21
<@Mahal>
About half an hour, Vorn.
05:22
< Vornicus>
arg. No time for unit tests.
05:26
<@Reiver>
Indeed not. :/
05:26
< Chalcedon>
how's the AI?
05:26
<@Reiver>
Crashing.
05:26 * Mahal huggles Reiver
05:26
<@Reiver>
It appears I need to get stronger protection of keeping things inside the array.
05:27
< Vornicus>
the AI as far as I can tell is practically trivial, once you get it to the API.
05:27
<@Reiver>
This puzzles me greatly, but...
05:28
<@Reiver>
Is there an equivalent in java to ascii(13);
05:28
<@Reiver>
?
05:28 * Reiver needs to turn a number back /into/ a letter.
05:28
< Vornicus>
Have you been declaring read methods const
05:28
< Vornicus>
?
05:29
<@Reiver>
...no I haven't? Hm?
05:29
< McMartin>
There is no such declaration in Java.
05:29
<@Reiver>
Oh dear.
05:29 * Reiver hrmm.
05:29
<@Reiver>
Er.
05:29
< McMartin>
And Reiver, I think you can assign the integer directly to a char.
05:29
< Derakon>
I think McM meant "const", not "itoa".
05:29
< Vornicus>
...there isn't?
05:29
< Vornicus>
...suck.
05:30
<@Reiver>
McM: I'm, um.
05:30
<@Reiver>
Cycling through the array trying to find valid moves, and then saving them.
05:30
< Vornicus>
Build a new array.
05:30
<@Reiver>
I'll then randomly pick one of these moves, and apply it to the board - and then print out the appropriate letter code.
05:30
< McMartin>
Vornicus: "final" is the closest, but that means "You cannot override this, and if it's a field, you must assign it exactly once, and that in the constructor."
05:30
<@Reiver>
f.ex a2a4.
05:30
< Vornicus>
but why do you need ascii(13)? doesn't \n do the job?
05:31
<@Reiver>
Er, no. I need to be able to turn a number into a letter.
05:31
< McMartin>
No, because \u000D is \r.
05:31
< McMartin>
Reiver: Try Character.valueOf() or some such.
05:31
< Vornicus>
or, rather, \r?
05:31
<@Reiver>
McM: That goes the wrong direction.
05:31
< McMartin>
Browse through the rest.
05:31
<@Reiver>
Ok.
05:31
< Derakon>
Have you tried passing the int in as an argument to the construction of Character?
05:32
< McMartin>
StringBuffer.append((char)65) might work.
05:32
< Vornicus>
...duh
05:33
< Vornicus>
casts.
05:33
< Vornicus>
that's what you need.
05:33
< Vornicus>
(char)65 -> 'A'
05:36
<@Reiver>
...it is?
05:36 * Reiver pokes at his code.
05:36
< Vornicus>
Should be.
05:41
<@Reiver>
HAH
05:41
<@Reiver>
Right.
05:41
<@Reiver>
Now to rename, submit...
05:41
<@Reiver>
'cuz it works yay!
05:41
< Chalcedon>
yay!
05:41
< Derakon>
Yay!
05:41 * Mahal hugs Reiver!!!!
05:42 * Chalcedon gives Reiver cookies, hot crossless buns, soup and any other foodstuff she can fine
05:42
< Chalcedon>
*find
05:42
<@Mahal>
And it's nearly hand-in time, lad...
05:42 * Chalcedon also hands out cookies and hot crossless buns to everyone else.
05:42
< Derakon>
Whatchoo got against hot *cross* buns?
05:43
< Chalcedon>
it's not easter
05:43
< Chalcedon>
besides, the crosses are a pain to make
05:43
< Derakon>
Fair enough.
05:44
<@Reiver>
Ok.
05:44
<@Reiver>
In Eclipse.
05:44
<@Reiver>
How do I pack the whole thing into a .jar ?
05:44
< Vornicus>
one moment..
05:46
< Vornicus>
...shit, I forget.
05:53
< Vornicus>
I don't know.
05:53
< Vornicus>
.jar is not a hard format though
05:54 * Chalcedon hopes Reiver is uploading by now. :S
05:56
<@Reiver>
it is done.
05:57
<@Reiver>
hee.
05:57
< Chalcedon>
yay!!!!!!!!
05:57 * Mahal hugs!!!
05:57
<@Reiver>
Next time? Um.
05:57
<@Mahal>
Now: FIRST THINGS FIRST GO EAT
05:57 * Chalcedon hugs Reiver and feeds him
05:57
< Derakon>
Start before the day it's due, huh? :)
05:57
<@Mahal>
That was not a request.
05:57
< Chalcedon>
yes, food first talk later
05:57
<@Reiver>
I think I'll leave writing all the documentation until /after/ it's working...
05:57
<@Reiver>
>.>
05:57 * Vornicus applies stoatburgers liberally.
05:57 * Derakon snerks.
05:57
<@Reiver>
I thought it would work, darnit!
05:57
<@Reiver>
I had lots of pretty code.
05:57
<@Mahal>
Reiv, it depends which earns more marks...
05:57
<@Reiver>
Er.
05:57
< Chalcedon>
that sounds like a good idea
05:57
< Derakon>
It never works on the first try.
05:57
<@Mahal>
Now, food.
05:57 * Reiver ended up throwing out 3/4 of it. >.<
05:57
<@Mahal>
GO.
05:57 * Mahal grins
05:57 * Vornicus <3 Unit Tests.
05:58
< Chalcedon>
what's a unit test?
05:58
<@Mahal>
Welcome to any programmer's world, Reiver.
05:58
< Vornicus>
Someone get the man a steak and a guinness.
05:58
<@Mahal>
Testing bits at a time, isn't it Vornicus ?
05:58
< Derakon>
A unit test is a program that does a simple test of your actual program's correctness.
05:58 * Mahal only vaguely knows.
05:58
< McMartin>
Chalcedon: A series of very small tests each of which excercises exactly one behavior.
05:58
< McMartin>
The goal is that by looking at which tests succeed and fail, you can precisely determine which chunks of code need work.
05:58
< Derakon>
For example, if you're working on a calculator, one unit test might put in "3+4" and check that it got "7" out.
05:58 * Chalcedon wonders why Reiver /didn't/ use them
05:58
< Vornicus>
One moment, let me give you an example...
05:58
< Derakon>
You have to make them before you can use them.
05:59
< McMartin>
Derakon: That's only a unit test if you've already tested input, parsing, etc.
05:59
< Derakon>
Well, yes.
05:59
< Derakon>
I wanted a simple example. ¬.¬
05:59
< Vornicus>
Okay. Writing a class that handles points in Ruby, here's a bit of my testing framework.
05:59
< McMartin>
What you've described is a "sanity check".
05:59
< Chalcedon>
heh
05:59
< Vornicus>
@first = Point.new(0,0)
05:59
< Vornicus>
@second = Point.new(4,3)
05:59
< Vornicus>
def setup
05:59
< Vornicus>
@first = Point.new(0,0)
05:59
< Vornicus>
@second = Point.new(4,3)
05:59
< Vornicus>
end
05:59
< Vornicus>
...gah
05:59
< Vornicus>
the first two lines are a mispaste
06:00
< Vornicus>
def test_distance
06:00
< Vornicus>
assert_equal(4, @first.x_distance_to(@second))
06:00
< Vornicus>
assert_equal(3, @first.y_distance_to(@second))
06:00
< Vornicus>
assert_equal(5, @first.distance_to(@second))
06:00
< Vornicus>
end
06:00
< Chalcedon>
so essentially, you write something that calls the precise function (and nothing else) you want to test with known inputs to see if it's working correctly?
06:01
< Vornicus>
Before this test I first test if the initialization has worked.
06:01
< Derakon>
Or for complicated functions, you pass in inputs that will exercise only a specific part of the function.
06:02
< Chalcedon>
does it have to be a separate program?
06:02
< Vornicus>
In general you want to break down complicated functions into small parts so that you can exercise that specific part without having to go through the rigmarole of figuring out how to get there.
06:02
< Derakon>
No, Chalcedon.
06:02
<@Reiver>
I did use a /couple/ of unit tests... I should probably have used more. >.>
06:02
<@Mahal>
Reiver, it's an assignemtn.
06:03
< Derakon>
Ideally, your unit tests will exercise and verify every line of code in your program. In reality...well, writing the unit tests would take much longer than writing the actual code.
06:03
< Chalcedon>
ok (sorry, I see program as being a separate individual entity)
06:03 himi-really-heading-to-work [~himi@Nightstar-29007.ACT.netspace.net.au] has quit [Ping Timeout]
06:03
< Chalcedon>
heh, true.
06:03
< Vornicus>
A unit test is usually set up in a separate file, and will run as a separate program, but the unit testing frameworks will do all the "different program" work for you.
06:03
< Derakon>
S'okay; my original definition was poor.
06:04
< Vornicus>
There are many reasons to use unit tests.
06:04
< Chalcedon>
besides, there's probably usually a few lines you don't need to test, like setting a variable.
06:04
<@Reiver>
Uh. Er. Sorry about poking folks with so many questions. It's much appreciated.
06:04
< Derakon>
No prob.
06:04
<@Reiver>
And next time I'll actually start asking sooner. >.<
06:04
< Derakon>
Incidentally, unit tests can also be used as regression tests.
06:04 * Reiver hates asking for help. >.>
06:04
< Derakon>
Regression tests are tests that make certain that existing functionality keeps working after you've changed something.
06:04
< Vornicus>
the first and foremost is to make your program resistant to breaking - if you break a unit test while changing something, you know you did it wrong.
06:05 * Chalcedon nods and files all this info away
06:06 himi-really-heading-to-work [~himi@Nightstar-29007.ACT.netspace.net.au] has joined #code
06:06
< Vornicus>
(a common place to /create/ unit tests is when you get a bug report and find what was wrong. Then you write unit tests that, if they pass, mean that the bug doesn't exist)
06:06
< Chalcedon>
aaahhh
06:07 * Chalcedon needs to report a few bugs in her analysis program
06:07
< Chalcedon>
problem is, I think half the bug is the size of my data files :S
06:08
<@Reiver>
...What's funny.
06:08
< Chalcedon>
?
06:08
< Vornicus>
Also, unit tests can be used as a sort of documentation. Properly put together, a unit test suite describes all the special cases that a system handles, in addition to the gist of the general case.
06:08
<@Reiver>
Is that with the amount of code I had /figured/ I had left to write when I started crunching over the weekend?
06:08
<@Reiver>
Even up to yesterday evening? I was meant to have finished by last night.
06:08 * Reiver is very glad he'd allowed himself a day. >.>
06:09
<@Reiver>
But now I'm gonna go shower again because I've been sitting around all day.
06:09
< Vornicus>
I know that feeling.
06:17 EvilAwayLord is now known as EvilDarkLord
06:22
<@Reiver>
Clean!
06:22
< Vornicus>
yey
06:22
< Vornicus>
now eat.
06:22
<@Reiver>
Bah to eating.
06:23
<@Reiver>
Eating is for the weak!
06:23
<@Reiver>
And possibly hungry.
06:23
<@Reiver>
>.>
06:23
< Derakon>
And you are neither? Think carefully, now.
06:23
<@Reiver>
Bah.
06:23
<@Reiver>
I can go for days without food!
06:24
<@Reiver>
...Not that I am claiming this is a good idea, granted...
06:24
<@Mahal>
EAT, REIVER.
06:24
<@Mahal>
>.<
06:24
<@Reiver>
Yeah, yeah.
06:24
<@Reiver>
What is it with people and feeding me?
06:24
<@Reiver>
Geez, I dunno, you'd think they were trying to fatten me up or something...
06:25
< Derakon>
...curses!
06:25 * Chalcedon sends subliminal food messages to Raif
06:25
< Derakon>
Er, I mean, of course not!
06:25
< Chalcedon>
-er- Reiver
06:25 * Chalcedon sorry
06:26
<@Mahal>
yes, Reiv.
06:26
<@Mahal>
We wnat o fatten you up so we can cook you.
06:26
<@Reiver>
I knew it.
06:26
<@Reiver>
Tsk, tsk, tsk.
06:26
< Chalcedon>
well, I know what's up with Mahal and I: we're female, we have this instinctive need to feed men.
06:26
< Derakon>
And then we feed you to yourself.
06:26
<@Reiver>
Well, your foul plan shall not work!
06:26 * Mahal eyebrows.
06:26
<@Reiver>
Muahahahaha.
06:26
<@Reiver>
Oh hey my soop is done brb
06:26
<@Reiver>
:p
06:26
<@Mahal>
:D
06:26
<@Mahal>
Good lad!
06:31
< Derakon>
Well anyway, bedtime for me. Night, all.
06:31
< Chalcedon>
night!
06:31
<@Mahal>
Night!
06:31 Derakon is now known as Derakon[AFK]
06:32
< EvilDarkLord>
Ni!
06:52 You're now known as TheWatcher
07:00 Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
07:00 mode/#code [+o Chalcy] by ChanServ
07:01 himi-really-heading-to-work [~himi@Nightstar-29007.ACT.netspace.net.au] has quit [Ping Timeout]
07:01 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout]
07:02 himi-really-heading-to-work [~himi@Nightstar-29007.ACT.netspace.net.au] has joined #code
08:32 You're now known as TheWatcher[afk]
08:59 Vornicus is now known as Vornicus-Latens
09:28 EvilDarkLord is now known as EvilNromLord
09:50 Reiver is now known as ReivF0d
09:58 himi-really-heading-to-work [~himi@Nightstar-29007.ACT.netspace.net.au] has quit [Ping Timeout]
10:01 himi-really-heading-to-work [~himi@Nightstar-29007.ACT.netspace.net.au] has joined #code
10:05 ReivF0d is now known as Reiver
10:40 EvilNromLord is now known as EvilDarkLord
10:43 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
10:43 mode/#code [+o Chalcedon] by ChanServ
10:44 Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout]
11:04 * EvilDarkLord hmm. Anyone know how to fix a faulty sleep / standby mode on Windows? Both just go into a black screen and lock up the computer.
11:04
< McMartin>
... isn't that what standby is?
11:05
< EvilDarkLord>
Point being that it does not come back out.
11:05
< McMartin>
Oh.
11:05
< EvilDarkLord>
Plus, as far as I can tell it doesn't go into standby mode (I have a nifty little light for this).
11:06 * McMartin is not wise in the ways of such things, though maybe the BIOS settings are screwy?
11:06
< EvilDarkLord>
Hm. This happened after a fix-install of Windows. Forgot to mention, sorry.
11:07 * McMartin uses windows maybe once a month, so.
11:07 * EvilDarkLord hm. Does Linux have decent support for standby / sleep?
11:07
< McMartin>
Depends on your hardware.
11:08
< McMartin>
Fedora Core 5 is the first version of Linux I've seen to do it right for my Thinkpad.
11:08
< McMartin>
The libraries that handle it on Linux are called ACPI.
11:08
< McMartin>
You now know basically everything I do.
11:08
< McMartin>
FC5 had them Just Work right out of the box, though.
11:08
< McMartin>
Standby, anyway
11:09
< McMartin>
Hibernate is apparently vastly trickier in Linux and requires special drive partitions and stuff
11:09
< McMartin>
To which my reaction was generally "right, I'll live with just turning the thing off"
11:09
< EvilDarkLord>
Well, not like I need much hibernate. Standby takes at least a few days to go through the battery.
11:09 * McMartin nods
11:10
< McMartin>
Thinkpads are also apparently notoriously temperamental about such things.
11:10
< McMartin>
I don't have enough experience with Ubuntu to know how it handles it.
11:10
< McMartin>
Other than that it would be using ACPI too.
11:10
<@Reiver>
I note than in Linux, half the time you can set it up to basically pick up where you left off on a reboot anyway~
11:11
< EvilDarkLord>
Hm, also. DVD player is not detected. Anything else to do beside trying to find the right driver?
11:11
< EvilDarkLord>
Or rather, Windows does not detect my disks. I can still use LiveCDs and whatnot at startup.
11:11
< McMartin>
Sounds like drivers to me, yeah.
11:11 himi-really-heading-to-work is now known as himi
11:12 * McMartin actually hasn't installed Windows on a machine since... 1999.
11:12 * EvilDarkLord needs it for some coding projects, plus he's lazy.
11:12
< McMartin>
I said I hadn't installed it.
11:13
< McMartin>
I last used it two days ago.
11:13 * EvilDarkLord nods.
11:13
< McMartin>
I've just had OEM versions that didn't require installation.
11:13
< EvilDarkLord>
I last installed Windows... never.
11:13
< McMartin>
You just mentioned doing a fix-install?
11:13
< EvilDarkLord>
Well, that hardly counts.
11:13
< McMartin>
I'm counting those.
11:14 * McMartin tends to keep his Windows systems sufficiently spare that the "nuke everything and start over" point isn't reached before the "hardware is laughably obsolescent; get all new stuff" point is reached.
11:15 * EvilDarkLord ponders nuking and then doing just that.
11:23 * MahalWork looks at her Windows installation, which has been her primary OS for the last three years, skulks out of the conversation.
11:26
<@Mahal>
But!!
11:26
<@Mahal>
Mactop :D
11:26
< McMartin>
BooyaH!
11:26 * McMartin would pester Mahal to test some Mac distributions of his software, bot Mahal has work to do~
11:26 * Mahal has SORTED IT OUT
11:26 * Mahal grin
11:26
< McMartin>
In which case!
11:26 * Mahal was given said mac!!
11:26
<@Mahal>
Yey presents!
11:26
<@Mahal>
And yes, i will test.
11:26
< McMartin>
I give you http://www.stanford.edu/~mcmartin/sable/ and a question as to whether the .dmg works!
11:27
< McMartin>
Since sometimes it seems not to, and Vorn and I never did figure out why.
11:27
<@Mahal>
Provided you are reasonable sure it won't break my machine :P
11:27
<@Mahal>
Seeing as I am a mac n00b still.
11:27
< McMartin>
Um. Intel Mac or PowerPC?
11:27
<@Mahal>
PPC
11:27
< McMartin>
Pretty sure. As I don't have a Mac, I have only that some Mac software site looked at it and determined that I wasn't writing spyware.
11:27
< McMartin>
OK. That's good, as that's the only version I have.
11:27
<@Mahal>
Emulater? :)
11:28
< McMartin>
Nah. I wrote the game.
11:28
<@Mahal>
Oh.
11:28
<@Mahal>
Right then.
11:28
< McMartin>
Vorn built it and packaged it for Mac
11:28 * McMartin handled the Linux and Windows versions.
11:29
<@Mahal>
It loads not.
11:29
<@Mahal>
I may be doing something Wrong.
11:29
< McMartin>
Alas, I am entirely innocent of OS X.
11:29
< McMartin>
Is there an error message of some sort that one could deliver unto a guru?
11:30
<@Mahal>
Heheh.
11:30
<@Mahal>
Not unless "it opens then it goes away again!!" helps.
11:30
<@Mahal>
I am going to try running it from terminal.
11:30
< McMartin>
OK
11:30
< McMartin>
(If it continues to fail and you're curious about the game, the Windows version ought to work on anything.)
11:30 * Mahal nods
11:30
< McMartin>
(Well, anything running Windows.)
11:31
<@Mahal>
I guessed :)
11:31
<@Mahal>
I can give you errors from terminal if you like?
11:31
< McMartin>
Sure
11:31
<@Mahal>
I am inside the sable app.
11:31 * McMartin is pretty familiar with the Linux versions of the graphics/input libraries, so if it's failing there...
11:31
<@Mahal>
/Applications/Games/Sable.app/Contents/MacOS
11:31
<@Mahal>
./sable
11:31
<@Mahal>
dyld: Library not loaded: /usr/lib/libSDL_image-1.2.0.dylib
11:31
<@Mahal>
Referenced from: /Applications/Games/Sable.app/Contents/MacOS/./sable
11:31
<@Mahal>
Reason: image not found
11:31
<@Mahal>
Trace/BPT trap
11:32
< McMartin>
Aha.
11:32
< McMartin>
Yes, I think Vorn will be able to do something about that.
11:32
< McMartin>
is there a libSDL_image of some kind anywhere in the app?
11:33 * Mahal hunts.
11:33
<@Mahal>
where would I look for it, if you know?
11:33
< McMartin>
I'm not sure which things are installed by default for the Mac terminal
11:33 * EvilDarkLord bah. He is getting a whopping 5 fps or so on this machine.
11:34
< McMartin>
EDL: You'll need 3D acceleration.
11:34
<@Mahal>
I cannot find a lib_sdl ANYWEHRE
11:34
<@Mahal>
(not inside your app, that is.)
11:34
< McMartin>
You won't need much, but you need some.
11:34
< EvilDarkLord>
I'll have to try it on my real computer later.
11:34
<@Mahal>
Aaand the only place I have it on the mac is inside VLC
11:35 * Mahal <3 that Mac is Darwin under the hood :)
11:35
< McMartin>
EDL: I think it's throwing about 10,000 polygons a frame.
11:35
< McMartin>
Heh
11:35
< McMartin>
try "find . -name libSDL\*" in Sable.app
11:35 * McMartin actually hasn't tried Sable with the new graphics on a machine that can't do compiled vertex arrays, wonders if that matters anymore
11:36
<@Mahal>
No results returned, McMartin
11:36
< McMartin>
... interesting.
11:36
< McMartin>
I now believe I'm Missing Something, and will bother Vorn or Derakon about it later.
11:36
<@Mahal>
:)
11:37
<@Mahal>
Should I be awake and at home, you are 100% welcome to use me as testing :)
11:37
< McMartin>
Because without shipping with the SDL libraries, it shouldn't have run on anyone's machine
11:37
< McMartin>
Though your error implies that it would work OK if they had those libraries installed globally
11:38
< McMartin>
Again assuming that this is a place where Linux and OS X act the same way, which isn't always safe
11:38
<@Mahal>
Indeed.
11:42
< McMartin>
And I've seen screenshots of it running, so I know it runs occasionally
11:45
< McMartin>
But thanks for the offer; I really appreciate it =)
11:55 Mahal [~Mahal@Nightstar-5107.worldnet.co.nz] has quit [Quit: slwwp]
11:59 Reiver [~reaverta@IRCop.Nightstar.Net] has quit [Ping Timeout]
12:01 Reiver [~reaverta@IRCop.Nightstar.Net] has joined #Code
12:01 mode/#code [+o Reiver] by ChanServ
14:04 EvilDarkLord is now known as EvilYumLord
14:48 Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
14:48 mode/#code [+o Chalcy] by ChanServ
14:50 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout]
14:55 EvilYumLord is now known as EvilDarkLord
14:57 Serah [~Shemhazai@Nightstar-27025.bynxx4.adsl-dhcp.tele.dk] has joined #Code
14:58 himi [~himi@Nightstar-29007.ACT.netspace.net.au] has quit [Ping Timeout]
15:02 himi [~himi@Nightstar-29007.ACT.netspace.net.au] has joined #code
15:23 Reiver is now known as ReivZzz
15:55 ReivZzz is now known as ReivSLEP
16:18 ReivSLEP is now known as ReivSLEPnoreally
16:37 ReivSLEPnoreally is now known as ReivSlepNoReallyDamnit
16:45 himi is now known as himi-sleeping
17:06 Vornicus [~vorn@Nightstar-18307.slkc.qwest.net] has joined #code
17:07 mode/#code [+o Vornicus] by ChanServ
17:07 * Vornicus arrives at vork.
17:08 * Serah is at work too.
17:09 * ToxicFrog|AFK likewise.
17:09
< ToxicFrog|AFK>
...oi.
17:10 ToxicFrog|AFK is now known as ToxicFrog|W`rkn
17:10
< ToxicFrog|W`rkn>
Bad irssi, no biscuit./
17:11 ToxicFrog|W`rkn is now known as NSGuest-882
17:11
<@Vornicus>
Speaking of things that deserve no biscuits.
17:12
< GeoTube>
?
17:12 NSGuest-882 is now known as ToxicFrog|W`rkn
17:12
< GeoTube>
When was someone handingout biscuits...
17:12 * ToxicFrog|W`rkn strangles irssi with its own shitty reconnect code.
17:12
< ToxicFrog|W`rkn>
(yes, that was an irssi problem, not a services problem)
17:13 * GeoTube watches it error output failed: no output function back
17:13 * ToxicFrog|W`rkn sets GeoTube on fire. Again.
17:14 * GeoTube runs around the channel to light the lame one on fire. Again.
17:16-ToxicFrog|W`rkn:@#code- When did he get in here, anyways?
17:18 mode/#code [+o ToxicFrog|W`rkn] by ChanServ
17:19
<@Vornicus:@#code>
I... don't know.
17:36 Serah [~Shemhazai@Nightstar-27025.bynxx4.adsl-dhcp.tele.dk] has quit [Ping Timeout]
19:52 fhtagncaps is now known as aoanla
20:10 Syloqs-AFH [Syloq@NetAdmin.Nightstar.Net] has quit [Connection reset by peer]
20:10 * Vornicus tries to figure out where the zone files are hiding.
20:20
<@ToxicFrog|W`rkn>
Zone files?
20:22
< McMartin>
HUGE CRISIS ZONE
20:22
<@ToxicFrog|W`rkn>
OMG DEATHBOTS
20:28
<@Vornicus>
DNS zone files.
20:28
<@ToxicFrog|W`rkn>
Aah.
20:37 Chalcy is now known as Chalcedon
20:56 Mahal [~Mahal@Nightstar-5107.worldnet.co.nz] has joined #code
20:56 mode/#code [+o Mahal] by ChanServ
20:59
< McMartin>
Vorn!
20:59
< McMartin>
I am reminded.
21:00 EvilDarkLord is now known as EvilSLEPLord
21:00
< McMartin>
If you get a chance, can you poke at the Sable.app library settings? Mahal tried to run it and it seemed to be looking for SDL_image in /usr/lib
21:08
<@Vornicus>
I'll have a look see. The whole library thing tends to eat my lunch on all possibly platforms.
22:02 NSGuest-893 [~Shemhazai@Nightstar-8502.ds1-ba.adsl.cybercity.dk] has joined #Code
22:08 ToxicFrog|W`rkn is now known as ToxicFrog|AFK
22:13 GeoTube [~Someone@Nightstar-2676.cable.ubr01.dund.blueyonder.co.uk] has quit [Killed (NickServ (GHOST command used by COL_GeoTube))]
22:13 COL_GeoTube [~Someone@Nightstar-2676.cable.ubr01.dund.blueyonder.co.uk] has joined #Code
22:24
<@Vornicus>
gnar. I need more knowledge of the gnu text tools.
22:44 COL_GeoTube is now known as GeoTube
22:54
<@ToxicFrog>
Any tools in specific?
22:54
<@Vornicus>
Not really, because I don't really know what the capabilities of any of the tools actually are. Though I imagine awk and sed would probably be my best bets.
22:55 * Vornicus is trying to replace things in a file with the contents of environment variables that occasionally happen to have stuff in them that kills sed.
22:57
<@Vornicus>
...of course, as I say this, Der places a cute little chunk of plumbing & perl on his LJ.
22:59
< aoanla>
awk and sed are awesome, yes.
22:59
<@ToxicFrog>
The answer to this is either a simple awk script, or a simple sed script with hideous quoting.
22:59
<@ToxicFrog>
However, if the perl fragment does what you need, go for it~
22:59
<@Vornicus>
No, I can't tell what the perl fragment does at all.
22:59 * aoanla thinks it is worth learning a little awk, then.
22:59
<@ToxicFrog>
(and it can't be any more hideous than something I wrote in bash with, IIRC, four levels of quotes and eleven of backslash escapes)
22:59
< McMartin>
TF: If the environment variable's values have newlines in it, sed simply fails outright.
23:00
<@ToxicFrog>
There /is/ a way to get sed to handle newlines; I've done it.
23:00
<@Vornicus>
BUt I've got an HTML file with things like __MESSAGE__ in it, which I want to replace with the value of $message - which /very often/ has newlines in it.
23:00
< McMartin>
It sees the newline in the environment variable as terminating the s command.
23:00
<@ToxicFrog>
I can't remember how, though.
23:00
< McMartin>
Which is really quite rude.
23:00
<@ToxicFrog>
Hmm. Let me test something.
23:00
< McMartin>
Vorn: Wouldn't this be, like, 12 lines of Python?
23:00
<@Vornicus>
(as it's an svn commit message or a jUnit failure message)
23:01
<@Vornicus>
It would be. If I could get python, or ruby, or perl, or php to work.
23:01
< aoanla>
I think you /can/ do that in sed.
23:01
<@ToxicFrog>
Vornicus: using \n instead of a hard newline works.
23:01
<@Vornicus>
yeah, but I don't get access to that, either.
23:02
<@Vornicus>
message=`svn propget --revprop -r HEAD svn:log`
23:02
<@ToxicFrog>
Aah.
23:02
<@ToxicFrog>
Well, let me test something else~
23:02
<@Vornicus>
I'm receiving hard newlines.
23:03
<@ToxicFrog>
Hmm.
23:03
<@ToxicFrog>
I can get sed to insert newlines, but I can't get it to replace them~
23:04
< McMartin>
s/// in sed means "do this to every line", so, um, yeah~
23:04
<@Vornicus>
I don't want to /replace/ a newline, I want to /put in/ a newline. s/__MESSAGE__/$message/, where $message contains newlines.
23:05
<@ToxicFrog>
Right. I was thingking of replacing $message with `newline_to_escape $message`
23:05
<@ToxicFrog>
However, the following appears to work:
23:05
<@Vornicus>
(it may also contain ampersands, which are an entirely different sack of potatoes.)
23:05
<@ToxicFrog>
sed -r -e "s;__MESSAGE__;`echo -n $message | awk '{ printf "%s\\n",$0 }'`;g"
23:06
< NSGuest-893>
printf("Goodnight.")
23:06 NSGuest-893 is now known as Serah
23:07
<@ToxicFrog>
Nini, Serah.
23:09
<@ToxicFrog>
...hmm.
23:09
<@ToxicFrog>
It kind of works.
23:09
<@ToxicFrog>
It seems to end up translating the newlines into spaces, which is not right.
23:09
< McMartin>
... if it's HTML, shouldn't it turn them into <br>?
23:10
<@ToxicFrog>
Well, ok, replace the "\\n" in the awk script with whatever you want to replace newlines with~
23:10
<@ToxicFrog>
Aha.
23:10
<@ToxicFrog>
It should be "\\\\n"
23:10
<@ToxicFrog>
If you want HTML newlines, use "<br>"
23:11
<@Vornicus>
it's going into a <pre>
23:13
<@ToxicFrog>
If you need to deal with ampersands as well, it gets slightly uglier:
23:13
<@ToxicFrog>
sed -r -e "s;__MESSAGE__;`echo $message | awk '{ printf "%s\\\\n",$0 }' | sed -r -e 's;\&;\\\\&;g'`;g"
23:14
<@ToxicFrog>
Yes, that is a sed command embedded inside the arguments to a sed command.
23:18
<@Vornicus>
slightly uglier he says.
23:18
<@ToxicFrog>
It does the job~
23:19
< aoanla>
Yay recursion.
23:19
< McMartin>
That's not really recursion.
23:19
<@ToxicFrog>
It's not - what McM said.
23:19
< McMartin>
It's not calling itself, just spawning a new instance of a program with identical code.
23:20
< McMartin>
It's like a String constructing a new String object in one of its methods.
23:20
<@ToxicFrog>
It's like sed(foo, sed(awk(bar)))
23:21
<@ToxicFrog>
McMartin: and sed doesn't do the spawning anyways, bash does.
23:21
<@ToxicFrog>
It's bash calling sed once and then using its output to call sed again.
23:21 Mahal is now known as Wenchling
23:22
< McMartin>
True enough.
23:22
<@ToxicFrog>
Anyways. Based on (admittedly brief) testing, that handles both newlines and ampersands.
23:25
<@ToxicFrog>
I hope it helps.
23:28 * aoanla notes that it's sort of "hand unrolled recursion".
23:28
< aoanla>
Ish.
23:29 Wenchling is now known as Mahal
23:42
<@Vornicus>
IT WORKS!
23:43
< aoanla>
Hurrah!
23:47
<@ToxicFrog>
Huzzah!
23:51
< McMartin>
FLANLESS VICTORY
23:51
< McMartin>
Now go get some flan.
23:51
<@Vornicus>
23:52 ReivSlepNoReallyDamnit is now known as Reiver
23:52
< McMartin>
It's kind of ugly, so it can't be a FLAWLESS VICTORY.
23:52
< McMartin>
But no flan was involved, so!
23:53
<@Chalcedon>
...
23:56
<@ToxicFrog>
--- Log closed Thu Aug 24 00:00:02 2006
code logs -> 2006 -> Wed, 23 Aug 2006< code.20060822.log - code.20060824.log >