code logs -> 2006 -> Tue, 22 Aug 2006< code.20060821.log - code.20060823.log >
--- Log opened Tue Aug 22 00:00:02 2006
00:15 * Vornicus teaches the support guy the magic of grep.
00:24
<@Vornicus>
grep "mail:" exported_address_book.ldif | awk '{ print $2 }' > email_addresses.txt
00:32
<@Chalcedon>
is starting list indices at zero a feature common to many languages or peculiar to python (or a small set)
00:32
<@Chalcedon>
*?
00:33
<@Vornicus>
Most languages start indexing at 0.
00:33
<@Vornicus>
VB and Lua use 1, some older langauges also use 1.
00:33
<@Chalcedon>
ok, thanks, was curious.
00:42 Reivlin [~reiver@Nightstar-29841.ubs-dsl.xnet.co.nz] has joined #Code
00:42 ReivZzz [~reaverta@IRCop.Nightstar.Net] has joined #Code
00:42 mode/#code [+o ReivZzz] by ChanServ
00:44 * ReivZzz flails at the internets.
00:44
<@ReivZzz>
How dare you disconnect!
00:44 ReivZzz is now known as Reiver
00:44 * Vornicus patpats the REiver.
00:44
<@Vornicus>
Anyway there is a reason for using 0.
00:44
<@Vornicus>
Well, several, really.
00:45
<@Reiver>
0?
00:46
<@Vornicus>
As the start of array indexing.
00:46
<@Reiver>
Oh.
00:46
<@Reiver>
(Who you telling this?)
00:46
<@Vornicus>
Chalcedon
00:46
<@Reiver>
right!
00:46
<@Reiver>
Carry on
00:46 * Reiver goes to shower
00:47
<@Vornicus>
First and foremost is that the way to get the address of any element in an array is easy: address_of_array + size_of_record * element_index
00:50
<@Vornicus>
Then there's the "when have I finished looking at the array?" thing: address_of_array + size_of_record * number_of_elements points to the first location not in the array.
00:50
<@Vornicus>
or, rather: array[number_of_elements] doesn't exist.
00:52
<@Vornicus>
(oh, awk uses 1-indexing too)
01:07
<@Chalcedon>
so why does 0 present an advanage?
01:07
<@Chalcedon>
(sorry, I had to go away and make dinner)
01:09
<@Vornicus>
The main reason is that it's a bit faster, and a bit easier to read stuff written for 0-indexed arrays.
01:13
<@Chalcedon>
ok
01:14 Mahal [~Mahal@Nightstar-5107.worldnet.co.nz] has quit [Quit: This computer just fell asleep.]
01:14 Mahal [~Mahal@Nightstar-5107.worldnet.co.nz] has joined #code
01:15 mode/#code [+o Mahal] by ChanServ
01:16 * Chalcedon hrm
01:19
<@Chalcedon>
hardware: how important is it to match FSB, processor and RAM speeds?
01:19
<@Chalcedon>
well, not match
01:20
<@Chalcedon>
I seem to recall that something (RAM, processor?) works in multiples of a lower speed (FSB?), is it necessary or advantageous to match these?
01:21
<@Vornicus>
RAM won't work faster than FSB.
01:21
<@Chalcedon>
does it cause problems if it tries to though?
01:21
<@Vornicus>
Processor works best at a multiple of max(FSB, RAM), but it's not that big a deal.
01:21
<@Vornicus>
...I don't actually know that.
01:22
<@Chalcedon>
so, ideally I want to match multiples of processor, RAM and FSB but having them out shouldn't be a problem?
01:22
<@Vornicus>
Right
01:23
<@Chalcedon>
thanks :)
01:23
<@Chalcedon>
I don't really like having my knowledge of hardware relied on, because it's incredibly patchy
01:26
<@Vornicus>
Mine isn't that great either.
01:40 * Chalcedon beats it
01:41
<@ToxicFrog>
RAM won't work faster than FSB. CPU will work faster than FSB, and is always operating at a multiple of FSB speed - but not necessarily an integer multiple.
01:42
<@Chalcedon>
fsb base speeds are 100, 133, 166 (or 167?) and 200, right?
01:44
<@ToxicFrog>
These days? 66, 100, 133, 166, 200, 266, 333, 400, 600, 800, 1000.
01:44
<@ToxicFrog>
Depending on what processor you're going with.
01:45
<@Vornicus>
woo gigahertz ram
01:46
<@ToxicFrog>
Pentiums range from 66 (P2) to 333 (Woodcrest Xeon), with four transfers per clock; Athlons from 100 to 1000 depending on whether it's a normal or Hypertransport processor.
01:47
<@ToxicFrog>
(with two transfers per clock)
01:47
<@ToxicFrog>
(and hypertransport has some other odd properties I don't fully understande)
01:47 * Chalcedon attempts to assimilate this
01:48 * Chalcedon contemplates
01:48
<@Chalcedon>
I need to go to work in two hours. I currently feel incredibly ill.
01:51
<@ToxicFrog>
Call in sick?
01:51
<@Chalcedon>
that's what I'm thinking, the problem is I work as a tutor, calling in sick is... complicated
01:53
<@Chalcedon>
well, that was quick.
01:54 * Chalcedon thinks she should go back to bed...
01:54
<@ToxicFrog>
?
01:54
<@Chalcedon>
I find curling up when this happens helps, I don't know why. you'd think my stomach would want to be unsquished
01:55 Vornicus [~vorn@Nightstar-18307.slkc.qwest.net] has quit [Quit: ]
01:59 * Mahal huggles the Chalcedon.
02:13 Mahal is now known as MahalAFK
02:50 MahalAFK is now known as Mahal
03:58
<@Reiver>
Okay.
03:59
<@Reiver>
I have a drawBoard() function.
03:59
<@Reiver>
Is there any way in Java to test what it does?
03:59
<@Reiver>
I'm pretty sure it will compile, I'm less sure it will spit out anything other than gibberish.
04:22 * Reiver pokes ToxicFrog?
04:30
<@ToxicFrog>
...call it and see?
04:31
<@Reiver>
Er.
04:31
<@Reiver>
How?
04:31 * Reiver is feeling extremely dense.
04:31
<@ToxicFrog>
... Game.Board.drawBoard()
04:31
<@ToxicFrog>
Exactly as any other function call.
04:32
<@Reiver>
Right. Er.
04:32
<@Reiver>
...>.<
04:32
<@Reiver>
Does Eclipse come with a compiler? >.>
04:33
<@ToxicFrog>
..
04:33
<@ToxicFrog>
I don't know, I haven't used it.
04:33
<@ToxicFrog>
One would assume so.
04:33
<@ToxicFrog>
You mean you haven't actually tried compiling any of your code?
04:36
<@Reiver>
Er. Not as yet.
04:36
<@Reiver>
I haven't really quite gotten the hang of how you test code fragments in java... >.>
04:37
<@Reiver>
In C it's easy, but I don't think things work like that.
04:38
<@Reiver>
And I haven't really written the Main enough yet for it to work entirely right. *cough*
04:39
<@ToxicFrog>
...it's not really any harder in Java than it is in C.
04:39
<@ToxicFrog>
Much harder than in an interpreted language, true.
04:40
<@Reiver>
In C I'd just stuff a couple braces around the function and pretend it was a program.
04:40
<@Reiver>
Er.
04:42
<@ToxicFrog>
So, write an alternate main() that sets up the board and draws it and swap that in.
04:47
<@Reiver>
This wouldn't mess up the inheritance and dependancies?
04:50 * Reiver pauses, pokes.
04:50
<@Reiver>
If I declare a method private, subclasses can reference it, surely?
04:53
<@ToxicFrog>
I can't remember if that's private or protected in java.
04:53
<@Reiver>
...Aha.
04:53
<@Reiver>
Hrm.
04:54
<@Reiver>
I am trying to get a Peice method to call a method on the board.
04:54
<@Reiver>
Chess.board.isClear(x,y); is not correct way to reference the instance?
04:58
<@ToxicFrog>
It should be. But check your case.
04:58
<@ToxicFrog>
Anyways, I slwwp now.
04:58
<@Reiver>
Night, TF
05:01
<@Mahal>
Nini TF
05:01
<@Chalcedon>
night TF
05:01 * Chalcedon sends TF cookies and hot crossless buns in his dreams
05:04
< Serah>
Night night TF.
05:04 * Serah nuzzles ToxicFrog
05:07 Raif [~corvusign@Nightstar-7918.hsd1.mn.comcast.net] has joined #Code
05:07 mode/#code [+o Raif] by ChanServ
05:07
<@Raif>
Wow, this is a full channel.
05:07
< Vornicus-Latens>
It is a full channel.
05:07 * ToxicFrog lapcurls Serah and slwwps
05:07
<@Raif>
Ew. I hope you're paying her extra.
05:08
<@Reiver>
So I have a circular dependancy, Raif?
05:08 * Serah pets ToxicFrog.
05:08
<@Raif>
Yep.
05:08
<@Reiver>
Hrmm.
05:08
<@Raif>
Now your two options are to have the board know about everything, or the pieces to know about themselves and their place on the board.
05:08
<@Reiver>
Origionally isClear() was a Peice method, but TF suggested it was better suited to being performed on the Board.
05:09
<@Reiver>
...But that then leads to the Peices having to call the Board, and about that point I can't get things to reference right...
05:09
< Serah>
Sounds harder to have the pieces know everything about themselves.
05:11
<@Chalcedon>
it is becomming rather a full channel
05:12
<@Raif>
isClear belongs on the board.
05:12
<@Raif>
However, MyPos() belongs on the piece, which it couldn't be if the board was the only holder of that information.
05:13
< Vornicus-Latens>
Having pieces know everything about themselves does have one advantage: it makes the movement logic better factored.
05:13
<@Reiver>
The peices do have an entry that keeps track of their position.
05:13
<@Raif>
So the board knows only this: It is essentially methods on top of a 2d array of bools.
05:13
<@Reiver>
It's used for comparing their current position to the destination.
05:13
<@Reiver>
I see.
05:13 * Reiver hrms.
05:14
<@Chalcedon>
is it possible to store the information on the location of each piece somewhere else (like a dictionary, say - I don't know if that's practical) and have it accessible to both pieces and board?
05:14
<@Raif>
IE: IsClear(0, 1) would return true or false. It could even return an int representing what piece was on that spot, and 0 for none, whatever you like.
05:14
< Vornicus-Latens>
or it could return a Piece or null.
05:14
<@Raif>
But anyway, the board is that array.
05:14
< Vornicus-Latens>
But that's a different sack of potatoes.
05:14
<@Raif>
Now, pieces are in their own list (or two lists if you like, one for each side)
05:14
< Vornicus-Latens>
and probably the wrong name.
05:15
<@Raif>
The pieces know their position. They know that when they move they tell the board to clear their last position and to set their destination.
05:16
<@Reiver>
It currently returns Peice or null.
05:16
<@Raif>
Now, something clever would be to give the board references to pieces, cast to some arbitrary parent type (IE: Piece)
05:16
<@Raif>
In C++ this would be a void pointer or an IUnknown interface.
05:16
<@Reiver>
What the board currently has is that it's a two-dimensional Peice array - it's cast to the Peice superclass.
05:17
<@Reiver>
Collision checking was going to be whether things returned as Peice or Null...
05:17
<@Raif>
Collision checking is unnecessary.
05:17
<@Raif>
Except for the king.
05:17
<@Reiver>
Er. By that I mean "Is the path between here and there free?"
05:18
<@Raif>
That should be something the piece logic deals with.
05:18
<@Reiver>
I've got mathematical checks for isDiagonal, isStraight, and suchlike.
05:19
<@Reiver>
What I need is to be able to check that the path between 4,1 and 4,6 is clear of pawns when the queen tries to move.
05:19
<@Raif>
IE: killed = board.Occupant(0, 3); Move(0, 3, board); delete killed;
05:19
<@Reiver>
I was going to iterate through the interviening squares, checking for anything other than null.
05:19
<@Raif>
(Something along those lines for moving, plus whatever validity checking applies for that piece)
05:20
<@Raif>
Does that help at all?
05:21
<@Raif>
and remember you'll need to be able to downcast that supertype.
05:21
<@Reiver>
If it comes up clear, and the other checks are okay, it then does the reference-juggle of move-object-in board[4,1] to board[4,6].
05:21
<@Raif>
(Ie: Cast Piece down to KingPiece, because the rules apply differently)
05:21 * Reiver was extending to subclasses, yeah.
05:22
<@Reiver>
However, what I've currently got is the rules for each Peice are stored by the class of Peice.
05:22
<@Raif>
yeah. Anyway, the board should only be responsible of storing state. It's a storage container.
05:22
<@Reiver>
So for a Rook, I have, uh.
05:22
<@Reiver>
public boolean isLegal(int newX, int newY) {
05:22
<@Reiver>
if(isStraight(newX, newY) && checkPath(newX, newY))
05:22
<@Reiver>
if(checkDestination(newX, newY))
05:22
<@Reiver>
return true;
05:22
<@Reiver>
return false;
05:22
<@Reiver>
}
05:22
<@Raif>
Pieces and external code are responsible for the game logic.
05:22
<@Raif>
Exactly, reiv.
05:23
<@Reiver>
checkPath and checkDestination currently make references to the Board.
05:23
<@Reiver>
These references are breaking...
05:23
<@Reiver>
And I am puzzled as to what I've done wrong in syntax or whatever.
05:23
<@Raif>
breaking how?
05:24
<@Reiver>
protected boolean checkDestination(int destX, int destY) {
05:24
<@Reiver>
if(Chess.Board.getSquare(destX, destY).getSide() != side)
05:24
<@Reiver>
return true;
05:24
<@Reiver>
else
05:24
<@Reiver>
return false;
05:24
<@Reiver>
}
05:24
<@Reiver>
"Chess.Board cannot be resolved"
05:25
< Serah>
5 minutes. Byes.
05:25
<@Raif>
Chess::Board?
05:25
<@Raif>
Chess is a namespace, yes?
05:25
<@Reiver>
Java uses dots. >.>
05:25
<@Raif>
fucking java. :)
05:25
<@Raif>
Is Chess a global instance, then?
05:26
<@Raif>
I guess I'd have to see your code to help much.
05:27 Serah [~Shemhazai@Nightstar-8502.ds1-ba.adsl.cybercity.dk] has quit [Quit: Connection reset by evil CHILD EATING MONSTERS!]
05:27
<@Raif>
Toss it up on a server somewhere and I'll poke through it.
05:28
<@Reiver>
Er. I've currently got it fragmented a bit, as I've been trying to get the board, and my one 'example' object (The Rook) to work before I screwdriver it back to everything else, but ok...
05:28 McMartin [~mcmartin@Nightstar-9698.dsl.pltn13.pacbell.net] has joined #code
05:28
<@Reiver>
(Just in case you started wondering "Where's the rest?".)
05:28
<@Reiver>
hi, McM.
05:28
<@Mahal>
You have webspace you can use, Reiv
05:28
<@Mahal>
?
05:28
<@Reiver>
Mahal: Only poorly.
05:29
<@Reiver>
Unless you can set up a quick upload-and-share script?
05:29
<@Mahal>
Want to borrow Spinneretta?
05:29
<@Mahal>
(Ftp!)
05:29
<@Reiver>
...I'll just use the wiki for it requires less thought. No offense.
05:29
<@Mahal>
NP :)
05:32
<@Reiver>
http://vorn.dyndns.org/theonewiki/Chess?action=AttachFile&do=get&target=Chess.zi p
05:33
<@Reiver>
It's just a skeleton framework at the moment. I'm just trying to get the thing to /compile/... >.>
05:33
<@Reiver>
And then I'll start worrying about the rest.
05:33
<@Reiver>
(Or sticking it back into the proper methods, at least.)
05:34
<@Reiver>
What I'm trying to /get/ is http://www.cs.waikato.ac.nz/Teaching/COMP209B/assignments/Assignment1.pdf
05:35
<@Reiver>
(The plagarism stuff is standard restrictions - asking for help on design/syntax/etc, and even the odd code snippet is fine. But I'm not allowed to have someone elses entire program. :p)
05:40
<@Raif>
Java is a fucked up language.
05:40
<@Raif>
The reason you can't resolve board is because it's static to main()
05:40
<@Raif>
You want to make it a member variable of Chess
05:40
<@Raif>
(Assuming you want Chess.Board)
05:42 * Reiver blinks.
05:42
<@Reiver>
...Okay. Uh. How does I do that then?
05:43
< McMartin>
You want pointers both directions?
05:44
< McMartin>
Raif: "static to main" makes no sense. Do you mean local to main?
05:44
<@Reiver>
Unless there's a better way to get the rules in the right way?
05:44
<@Raif>
in the same scope as you declare main, declare: public ChessBoard Board;
05:45
<@Raif>
McMartin: Yes. Static local.
05:45
<@Raif>
He's declared it static.
05:45
<@Raif>
Which is not the same as declaring it a member variable.
05:45
< McMartin>
... is that even meaningful in Java?
05:45
<@Reiver>
...But you always declare main as static, don't you? >.>
05:45
< McMartin>
A static local in C persists across invocations.
05:45
<@Raif>
Reiver, not main.
05:45
<@Raif>
The Board variable.
05:45
<@Reiver>
...Oh.
05:45 * Reiver eyes it.
05:46
<@Raif>
move it into class scope, not function scope.
05:46
< McMartin>
But keep it static if you want Chess.board.
05:46
<@Raif>
indeed.
05:46
<@Reiver>
So I want Public Static Class ChessBoard?
05:46
< McMartin>
No, the class doesn't need to be static
05:46
< McMartin>
Unless you're declaring it inside another class.
05:47
<@Reiver>
Or I want static Chessboard Board = new Chessboard(); ?
05:47
< McMartin>
public static Chessboard board = new Chessboard();
05:47
< McMartin>
However
05:47
< McMartin>
It's probably better to not initialize it until main().
05:47
<@Raif>
Reiver, like this:
05:47
< McMartin>
Otherwise you can't guarantee initialization order.
05:47
<@Raif>
public static ChessBoard Board;
05:48
< McMartin>
(While we're at it, you've misspelled "Piece")
05:48
<@Raif>
... main(...) { Board = new ChessBoard; ...}
05:48 * Reiver pokes at that.
05:48
<@Reiver>
McM: I'm aware of the misspelling, um.
05:48
<@Reiver>
I always misspell my i before e.
05:48
< McMartin>
Eclipse should allow you to rename classes wholesale throughout a project.
05:49
<@Reiver>
While I realise it's bad practice, it was either having a misspelled word, or my mistyping it every time I used the term. >.>
05:49
<@Reiver>
(Maybe I should've used a different name entirely or something...)
05:49
< McMartin>
OK, next question.
05:49
<@Reiver>
Right?
05:49
< McMartin>
Who's referring to the board?
05:49
<@Raif>
My damage is done. Have fun. :)
05:49
<@Reiver>
Er. The Peices do so to check move legality.
05:49
<@Reiver>
Thank you, Raif!
05:50
<@Raif>
NP
05:50
< McMartin>
OK
05:50
<@Reiver>
The main method will also do so later when giving orders to it.
05:50
< McMartin>
OK.
05:50
< McMartin>
Certain schools of thought are full of hatred about global variables. Is your professor one such?
05:50
< McMartin>
Because if so, he'll be Irritated if you refer to static fields all through your program.
05:51
<@Reiver>
We were taught that you use static when you only ever want one instance of an object ever, and that in this case it was ok to have them.
05:51
< McMartin>
Fair enough.
05:51
< McMartin>
I would suggest putting that field in the ChessBoard class, however.
05:52
< McMartin>
ChessBoard.instance or whatnot.
05:52 * Reiver erms. Ok?
05:52
< McMartin>
That way, everything is being tied to ChessBoard, instead of being tied to ChessBoard and Chess.
05:52
<@Reiver>
...I'm not sure I follow, sorry?
05:53
< McMartin>
OK. Say you're trying to rip a chunk out of your program to do other things.
05:53
< McMartin>
You want to make the code as easily rippable as possible, which means you want to keep bits as self-contained as you can.
05:53
<@Reiver>
Right.
05:53
< McMartin>
The Chessboard class does all the work here.
05:53
< McMartin>
Which means that there's no reason to drag the Chess class into it.
05:54
<@Reiver>
So make that class the, uh, primary class, instead of Chess?
05:54 * Reiver ponders.
05:54
< McMartin>
No
05:54
< McMartin>
It's more like this.
05:54
<@Reiver>
Okay.
05:54
< McMartin>
... this would be way easier with a whiteboard.
05:54
< McMartin>
Pretend these are boxes.
05:54
< McMartin>
You've got your ChessBoard class: [ ChessBoard ]
05:55
<@Reiver>
Right
05:55
< McMartin>
Then you've got the Piece classes that are only meaningful in the context of the ChessBoard, and are sort of "part of it" : [ ChessBoard [ Piece ] ]
05:55 * Reiver nods.
05:56
< McMartin>
Then you've got the Chess class, which really only looks at the ChessBoard class and gives orders to it: [ Chess ] ---> [ Chessboard [ Piece ] ]
05:56
< Vornicus-Latens>
... inner classes.
05:56
< McMartin>
Not necessarily.
05:56
< McMartin>
This is dependencies, not source structure.
05:56
< Vornicus-Latens>
true
05:56
< McMartin>
Really, it's more "packages".
05:56
<@Reiver>
Is the way I was /trying/ to set up things along the right track?
05:56
< Vornicus-Latens>
oh, ok
05:56
< McMartin>
Mostly.
05:57
< McMartin>
I'm not sure quite what the application is. A GUI thing?
05:57
< McMartin>
A way of printing out games in progress?
05:57
< McMartin>
In any event, that box with Chessboard in it doesn't really say much about what the program *looks* like -- it's just The Rules Of Chess.
05:57
<@Reiver>
Did you see the above link to the actual assignment? >.>
05:57
< McMartin>
No
05:57
<@Reiver>
http://www.cs.waikato.ac.nz/Teaching/COMP209B/assignments/Assignment1.pdf
05:58
<@Reiver>
I'm trying to write a functional chess game.
05:59
<@Chalcedon>
for certain values of functional
05:59
< McMartin>
OK, so.
05:59
<@Reiver>
Heh, yes.
05:59 * Chalcedon doesn't consider the AI making random moves 'functional' in any real sense
05:59
<@Chalcedon>
however the alternative is so horribly complicated that it would be really mean.
05:59
<@Reiver>
(Incidentally the drawBoard function is entirely off. I've got a better version rewritten; but I haven't really worried about it much yet.)
05:59 * Chalcedon gives Reiver a hot crossless bun
05:59
< McMartin>
Suppose you eventually wanted to turn this into, say, some kind of IRC bot. It would be Nice (tm) to be able to simply write a new class that makes its own calls to ChessBoard and doesn't have to touch the Chess class at all.
06:00
< McMartin>
You want to have your main program basically just driving libraries.
06:00
< McMartin>
In this case, the "libraries" are the chess rules, the chessboard renderer, the computer AI, and the human input bits.
06:00
<@Reiver>
Right.
06:01
<@Reiver>
I follow this.
06:01
< McMartin>
And ideally, you have the minimum possible number of conduits between them.
06:01 * Reiver nods.
06:01
< McMartin>
In particular, those last three "libraries" don't really need to know about each other at all.
06:01
< McMartin>
And so it ought to be possible to deal with them individually, with just the chess rules behind them.
06:02 * Reiver nods.
06:02
< McMartin>
Which means that your final architecture would want to look a bit more like so:
06:02
< McMartin>
[ ChessBoard (with pieces, rules, etc) ]
06:02
< McMartin>
/ | \
06:03
< McMartin>
[ AI ] [ Move reader] [ Board renderer ]
06:03
< McMartin>
\ | /
06:03
< McMartin>
[ Main program ]
06:03
< McMartin>
Though the main program probably also needs to know the rules so that it can tell the board to set up, etc.
06:03 * Reiver nods.
06:04
<@Reiver>
So I need to set up the ChessBoard and Peices to be effectively standalone, with the actual Chess class just acting as an interface to tie them together and run the turn-by-turn?
06:04
< McMartin>
Yeah, though you'd be much better off having some general move-making interface so that it can treat AI and Human players identically at the top level.
06:05 * Reiver nods.
06:05
<@Reiver>
I was thinking of a Player object.
06:05
< McMartin>
HumanPlayer.getMove() and AIPlayer.getMove(), each being descendants of some Interface or Superclass Player.
06:05
< McMartin>
Yup
06:05
<@Reiver>
With human and AI subclasses.
06:05
<@Reiver>
Human one is the text-reader, AI one is a legal-checker.
06:05
< McMartin>
Mmmm, less good.
06:05
< Vornicus-Latens>
Technically the board thing should be able to tell you what moves are available.
06:05
<@Reiver>
Better way?
06:06
< McMartin>
The board should be the one to ask "Is This Move legal for This Player?"
06:06
< McMartin>
Main has to direct that, but it looks, given the output constraints, that if the AI is doing random moves, it has to do random *legal* moves.
06:06
<@Reiver>
I was planning for the AI to just iterate through the board, suggesting every possible move, and storing those that are legal.
06:06
<@Reiver>
And then picking randomly from that list.
06:06
< McMartin>
That works.
06:07
< McMartin>
But you have to be able to reject illegal human moves, and probably shouldn't ask the AI player if it's legal, instead asking the board/ruleset.
06:07
<@Reiver>
That was the input-getter, I was thinking.
06:07
< McMartin>
You might even have the board/ruleset say "give all legal moves for player X" at which point the AI player just picks off that list.
06:07
< McMartin>
As long as it's consistent, I guess.
06:07 Vornicus-Latens is now known as Vornicus
06:08
<@Reiver>
Using the same Chessboard.isLegal(x1, y1, x2, y2) thingy that the AI does.
06:08
< McMartin>
Right.
06:08
< McMartin>
See, that makes the legality checker "part of the Chessboard"
06:08
< McMartin>
As opposed to part of the AI.
06:08
<@Reiver>
Oh, right!
06:08
<@Reiver>
Yes.
06:08
< McMartin>
The AI's just asking the board about it.
06:08
<@Reiver>
The /legality/ stuff is built into the board and the peices.
06:09 * McMartin imagines this as the various class sitting around and talking to one another, and you want to organize the methods, etc. such that nobody's being overly OOC.
06:09
<@Reiver>
At the moment the board is responsible for checking for empty squares and board-boundaries, while the peices are responsible for their own internal rulesets.
06:09
< McMartin>
(From my upcoming lecture: Programming as Fanfic)
06:09
< McMartin>
Reiver: Tricky; pieces need to know whether or not there are any intervening pieces.
06:10
<@Reiver>
They were going to ask the board that...
06:10
< McMartin>
OK.
06:10
<@Reiver>
...Which is where I suddenly ran into circular reference problems. >.>
06:10
< McMartin>
Right.
06:10
< McMartin>
I'd suggest a global singleton for the board here, which we've outlined.
06:10
<@Reiver>
Okay. Er.
06:10
< McMartin>
(The public static field in the Chessboard class.)
06:10
<@Reiver>
The sort of syntax there?
06:11
< McMartin>
public class Chessboard {
06:11
< McMartin>
public static Chessboard instance = new Chessboard();
06:11
<@Reiver>
public static class ChessBoard?
06:11
<@Reiver>
AH
06:11
< McMartin>
private Chessboard() { /* ... base initialization stuff */ }
06:11
< McMartin>
}
06:11
< McMartin>
Note that the constructor is private so that nobody can go around making other ones.
06:11
<@Reiver>
Right.
06:11 * Reiver ponders.
06:11
< McMartin>
For the record, though...
06:12
<@Reiver>
Yes?
06:12
< McMartin>
If you need circular references...
06:12
< McMartin>
So that A.b is B, and B.a is A...
06:12
<@Reiver>
...Don't know if I do.
06:12
< McMartin>
You don't.
06:12
< McMartin>
Not for this, unless they ban globals
06:12
< McMartin>
But
06:12
< McMartin>
To do it...
06:13
< McMartin>
A() { b = new B (this); }
06:13
< McMartin>
B(A a) { this.a = a; }
06:13
< McMartin>
As the constructors for the two objects.
06:14
< McMartin>
You can also, of course, cheat and have some third class set all the fields directly, but this way works even if the "a" and "b" fields are private.
06:14
< McMartin>
And not even accessible by public getA() and setA() methods.
06:15 * Reiver nods.
06:15
<@Reiver>
Okay.
06:15
<@Reiver>
So if I'm managing to avoid them, I Think I'll store that away for the moment but not think too hard for the moment, no offense intended. :)
06:16
<@Reiver>
Okay, so I'm going to have my Chessboard create it's own instance, and it will be shiny and good.
06:16
<@Reiver>
Will this help with the Peices trying to call the Board for move legality problem?
06:17
< McMartin>
They can call any method on the board by saying Chessboard.instance.whatever().
06:18
< McMartin>
Well, any public method.
06:18 * Reiver nods.
06:18 * Reiver will give that a shot, one moment
06:19
<@Reiver>
Um...
06:19
< McMartin>
Capitalization counts.
06:20
<@Reiver>
public class ChessBoard {
06:20
<@Reiver>
private Peice[][] boardArray = new Peice[8][8]; // 8x8 array of null
06:20
<@Reiver>
public static Chessboard instance = new Chessboard();
06:20
<@Reiver>
(With corrected capilatisation.)
06:21
<@Reiver>
I'm a little puzzled by where I'm meant to stick the 'new Chessboard' decleration. I've not really had classes declare themselves before. >.>
06:21
< McMartin>
You're initializing it when the class is loaded.
06:21
< McMartin>
That's exactly equivalent to:
06:21
< McMartin>
public static Chessboard instance;
06:21
< McMartin>
static { instance = new Chessboard(); }
06:22
< McMartin>
It's not declaring itself. It's building a new version of itself.
06:22
< McMartin>
Using code that's "static" and thus not attached to any class.
06:23
<@Reiver>
Right. Okay.
06:23
<@Reiver>
...incidentally is 'instance' a literal, or whatever name I need to give it?
06:24
< McMartin>
Any name you want.
06:24 * Reiver nods.
06:24
< McMartin>
It's a traditional sort of name for The Only Copy Evar of something, assuming there's only going to be one copy Evar.
06:24
<@Reiver>
Calling it "ChessBoard" would just encourage confusion, wouldn't it...
06:26
<@Reiver>
...Okay, so.
06:26 * Reiver pokes at the next bit.
06:27
<@Reiver>
How do I actually get the confounded thing to be created in the first place?
06:27
<@Reiver>
The class calls itself...?
06:29
< McMartin>
Answering that honestly requires going under the hood rather deeply
06:29
<@Reiver>
Er.
06:29
<@Reiver>
Then let's skip that.
06:29
< McMartin>
The initialization code is called magically, by nobody, the first time anyone else refers to it.
06:29
<@Reiver>
It can be assumed to be automagical?
06:29
<@Reiver>
Ah!
06:29
<@Reiver>
Okay.
06:29
< McMartin>
Which will presumably be the main Chess class, ordering the board to be initialized.
06:30
< McMartin>
But if not, then the first time one of the players asks if a move is legal.
06:30 * Reiver nods.
06:30
<@Reiver>
HAH
06:31
<@Reiver>
The peices can refer to it happily, now!
06:31
<@Reiver>
Okay.
06:31
<@Reiver>
Now to poke at inheritances.
06:32
<@Reiver>
I can refer to instance variables in a superclass without declaring them, right?
06:32
< McMartin>
Yes; in fact, you can't redeclare them.
06:33
< McMartin>
(They have to be public or protected, though. Nobody can get at privates.)
06:33 * Reiver nods.
06:33
<@Reiver>
I got caught out by the private. :)
06:34
<@Reiver>
Uh, quick Dumb Question:
06:34
<@Reiver>
I want a single character letter to denote the letter of the Peice.
06:35
<@Reiver>
So a King is k or K, a rook is r or R, etc.
06:35
<@Reiver>
This will be used to display the appropriate symbol on the board.
06:35
<@Mahal>
(depending on whether black/white?"
06:35
< McMartin>
Yes.
06:35
<@Reiver>
(Correct.)
06:35
<@Mahal>
&case depending?
06:35
<@Reiver>
Case depends on side. I can handle that, it's a simple if.
06:35 * Mahal nod
06:36
<@Mahal>
Nono, I meant it's not an arbitary lower/uppoer, is lower black and upper white or vice versa or something? :)
06:36
< McMartin>
Yes.
06:36
<@Reiver>
I want to have a .printType(x,y) that returns the correct letter, or a space if there is no object in that square.
06:37
<@Reiver>
Can I use a character for that, or do I need to use a String?
06:37
< McMartin>
You can use a character.
06:37
< McMartin>
The only reason to use Strings would be if you wanted to force case with toLower or toUpper
06:37
< McMartin>
The if is faster. =P
06:37
<@Reiver>
As it will be generally called in System.out.print(printType(x,y) + " | "); system.
06:38
<@Reiver>
Okay, then!
06:38
< McMartin>
I'm fairly certain it will work.
06:38
< McMartin>
If it doesn't, then you can call print twice.
06:38
<@Reiver>
Now, er.
06:38
<@Reiver>
How do you get a, um
06:38
<@Reiver>
Return " ";
06:38
< McMartin>
return ' ';.
06:38
<@Reiver>
In a character method?
06:38
<@Reiver>
...*headdesk*
06:38
< McMartin>
characters are surrounded by single quotes, strings by double quotes.
06:39
<@Reiver>
Right. >.<
06:39 * Mahal patpat Reiv
06:39
<@Reiver>
(Too used to Basic, where they're interchangable...)
06:40
<@Reiver>
...Hey, it appears nulls show up as spaces anyway.
06:41
<@Reiver>
>.>
06:42
< McMartin>
That probably cannot be relied upon.
06:42
< McMartin>
'\0' != ' '.
06:42
< McMartin>
Especially if you've got some kind of autograder.
06:43
<@Reiver>
Oh, point...
06:43 * Reiver leaves the if statement in just to be sure.
06:44
<@Reiver>
Now to initialise the board.
06:45
<@Reiver>
Is there any cleaner way to do it than:
06:45
<@Reiver>
boardArray[0][0] = new Rook(0,0,Black);
06:46
<@Reiver>
boardArray[1][0] = new Knight(1,0,Black);
06:46
<@Reiver>
Etc?
06:46
<@Reiver>
Or while probably not, is there a cleaner way to do the row of 8 pawns at once?
06:46
< McMartin>
A for loop for the latter.
06:46
<@Reiver>
A for loop, is the best I can think of--right.
06:47
<@Reiver>
...Oh, I was also setting Black and White to a boolean.
06:47
<@Reiver>
Do I do that in the Chessboard, or in Chess, or in everywhere it gets used?
06:47
< McMartin>
... under what circumstances?
06:47
< McMartin>
Which piece is which, probably under the board.
06:47
< McMartin>
Whose turn it is, probably in the driver.
06:48
<@Reiver>
static final bool BLACK = true;
06:48
<@Reiver>
static final bool WHITE = false;
06:49
< McMartin>
Board.
06:49
<@Reiver>
Is what I'm planning on. I'm wondering just which classes need the decleration placed in them.
06:49
<@Reiver>
Right?
06:49
< McMartin>
Also, public.
06:49
< McMartin>
It would have be everywhere they're used, or they need to be ChessBoard.BLACK everywhere.
06:49
<@Reiver>
Will this, er, make them readable-by-default in the other classes?
06:49
<@Reiver>
Right. Hrm.
06:51
<@Reiver>
...Is it bad coder practice if I stuck it in all the classes?
06:51
<@Reiver>
Well, in Chess, Peice, Chessboard, and Player.
06:55
< McMartin>
I'd consider it such, but if he won't dock you, and you won't have to change it, ehn.
06:55
< McMartin>
Just make sure they're all the same everywhere.
06:56
<@Reiver>
Is it better than having If(Colour == Chessboard.BLACK) ?
06:57
<@Reiver>
Which just seems mildly boilerplateish. There again, when I think about it, does make sense...
07:00
< McMartin>
It's better to have a Single Point of Truth whenever possible.
07:00
<@Reiver>
Right.
07:00
<@Reiver>
Cool.
07:01
< Vornicus>
(frankly, coding in Java is bad practice. :P)
07:01
<@Reiver>
Quiet in the cheap seats.
07:01
<@Reiver>
:p
07:01
<@Reiver>
Ok!
07:01
<@Reiver>
Hrm.
07:02 * Reiver fiddles.
07:02
<@Reiver>
How to... Oh!
07:02
<@Reiver>
I have a Direction function.
07:02
<@Reiver>
I can highjack that to get my pawns to work.
07:02
<@Reiver>
Now for names...
07:03 * Reiver hrm.
07:04
<@Reiver>
Is it possible to use the toUpper widget on a character?
07:05
<@Reiver>
If not, um. When I initialise a peice, it is told what side it is on - BLACK or WHITE. It then needs to set the char type to the appropriate letter, which is case sensitive for side.
07:06
<@Reiver>
Is there a /tidy/ way to do that (Having a method that used an if statement with toUpper strikes me as tidiest), or do I just have to boilerplate the if statement into each constructor?
07:07
< McMartin>
Vornicus: No language handles this correctly, since you either have bulky namespaces or risk continuous conflicts when you mix libraries.
07:08
< McMartin>
Check the static methods in Character.
07:08
< McMartin>
If not, you may be better off with strings, and then returning charAt(0).
07:09
<@Reiver>
...charAt(0) doing?
07:12
< McMartin>
What it sounds like
07:12 * Reiver tries to find the static method in Character.
07:12
< McMartin>
Returning the first character.
07:12
< McMartin>
String.charAt
07:12
<@Reiver>
Ach!
07:12
< McMartin>
But there may be a Character.toUpper
07:13
<@Reiver>
toUpperCase(char ch)
07:13
<@Reiver>
Yay!
07:13 * Mahal patpat Reiver!
07:13 * Mahal hands chocolate, also issues polite reminder to eat.
07:15 * Reiver nrom chocolate, then soop!
07:15 * Reiver hrm at supers.
07:16
<@Reiver>
What I want to do is to have the peice subclass be where it defines the letter of the peice.
07:16
<@Reiver>
Is it bad to call super(x, y, colour, k) to set a king?
07:16
<@Reiver>
With the first three being set by the subclass who only /recieved/ (x, y, colour) in it's constructor?
07:17 * Reiver pauses. This seems very messy.
07:18
< McMartin>
Ordinarily, I would not use a separate class for each piece, honestly.
07:18
< McMartin>
However, that will be what is expected of you.
07:18
< McMartin>
But no, many times a subclass will force defaults in a superclass.
07:19
<@Reiver>
Well, seperating the classes for the peices /does/ allow for having an abstracted isLegal method that is type-specific.
07:19
<@Reiver>
...Then again, all else you'd need to have a case statement.
07:19
<@Reiver>
Heh.
07:19
<@Reiver>
Oh well! I shall be extra OO anyway.
07:20
<@Raif>
McMartin: Indeed.
07:20 * Reiver hrmm.
07:21
<@Reiver>
So my superclass constructor involves four variables, but the subclass constructor, which /calls/ the superclass constructor, involves three?
07:21
<@Raif>
Can.
07:22
<@Reiver>
Better way of asking: Is there a cleaner way?
07:22
<@Reiver>
>.>
07:22
<@Raif>
what's the 4th variable?
07:22
<@Raif>
This is an academic assignment, right?
07:23 Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
07:23 mode/#code [+o Chalcy] by ChanServ
07:23
<@Reiver>
Yes.
07:23
<@Reiver>
And the fourth variable is the letter that is used to represent the chess peice.
07:24
<@Reiver>
k or K for kings, r or R for rooks...
07:24 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout]
07:25
<@Raif>
Run away!
07:25
<@Reiver>
...
07:25
<@Reiver>
Right?
07:25
<@Reiver>
:p
07:25
<@Raif>
This is a prime example of the weaknesses of inheritance. :)
07:26
<@Raif>
(It's usually elegant on the surface but you pay for that with all kinds of complexity and nitty gritty crap)
07:26
<@Reiver>
It would be healthy if I managed to keep it not too weak, then. >.>
07:26
<@Reiver>
As my lecturer seems crazy-keen on inheritance.
07:26
<@Raif>
Anyway, you could do that or you could have a member variable you inherit from Piece. Call the parent constructor with the usual 3 variables and then set m_type = whatever
07:26
<@Raif>
Anyway, I'm being stolen by the SO. Toodles.
07:27
<@Raif>
Oh, also...
07:27
< McMartin>
I'd generally keep the letters out of the pieces entirely, but that requires massive overengineering in the display part.
07:27
<@Raif>
The way I do this in C++ is to set up a pure virtual function in the parent MyType
07:28
< McMartin>
Java calls those abstract functions, idly.
07:28
<@Raif>
Inherit by the child, implement MyType() { return "Fuckall"; } :)
07:28
<@Raif>
McM: I'm aware of the term.
07:29
<@Raif>
I generally consider Java more of an evil rather than putting myself in the mindset required to develop in a Java-esque way.
07:29
<@Raif>
Personal preference thing. :P
07:29
<@Raif>
Night.
07:29
<@Mahal>
Night Raif
07:30 * McMartin would, in fact, ditch OO entirely for such a problem and use an enum for pieces.
07:30 * Reiver ended up doing Raif's, if that is clean.
07:30 * Reiver chuckles.
07:30
<@Reiver>
So would I, really... but I think the idea is that we use it for Everything(tm).
07:31
< McMartin>
Yes. One of the things you will thus learn is when Inheritance plays Fourteen Kinds of Hell with separation of concerns.
07:31 * Reiver nods.
07:32
<@Reiver>
Hrm, sidepoint:
07:32
< McMartin>
Composition is almost always superior in every conceivable way to inheritance, and is no different semantically from having two or three variables elsewhere.
07:32 * Reiver nods.
07:32
< McMartin>
(Places where inheritance wins are things like the Player interface.)
07:32 * Reiver nod.
07:33
< McMartin>
In any event. Side point?
07:33
<@Reiver>
We have to use the code in the pdf for trapping textual input.
07:33
<@Reiver>
It gives it to us as a string.
07:33
< McMartin>
Yes.
07:33
<@Reiver>
It's not going to be messy trying to deparse that into variables, is it?
07:34
< McMartin>
My idea of "messy" is probably much, much messier than yours.
07:34
< McMartin>
That said, it should be straightforward, and not require much outside of the String class's many, many methods.
07:34
< McMartin>
It may, however, be Kind Of Long.
07:34
< Vornicus>
Messy is a very relative term.
07:35 * Reiver nods.
07:35
<@Reiver>
...Actually I think I get how.
07:35
<@Reiver>
Hey, that's easy, neat.
07:35
< McMartin>
You aren't required to gracefully handle erroneous input, are you?
07:35
<@Reiver>
...Although kind of verbose.
07:35
<@Reiver>
Uh... sort of.
07:36
<@Reiver>
"Error. Try again." is about the limit of it.
07:36
< McMartin>
OK, that's just a single try/catch block that catches Exception, then~
07:36
<@Reiver>
Yus.
07:36
<@Reiver>
And spits out "Error: Illegal Move"
07:37 * Reiver eyes the next bit.
07:37
<@Reiver>
Must be startable with "ChessGame h h", "ChessGame h c", or "ChessGame c c"
07:37
<@Reiver>
Having the player object makes that easy.
07:38
< McMartin>
Yes.
07:38
<@Reiver>
That is caught by Main(string args[]), yes?
07:38
<@Reiver>
And the string you'd get would be "h h", yes?
07:38
< McMartin>
No
07:38
<@Reiver>
No?
07:38
<@Reiver>
hrm
07:38
< McMartin>
You'd get an array of two strings
07:38
< McMartin>
"h" and "h".
07:38
<@Reiver>
...
07:39
< McMartin>
Hence the []
07:39
<@Reiver>
So I can retrieve them via args[0] and args[1]?
07:39
< McMartin>
Yes
07:39
<@Reiver>
Nice!
07:39
<@Reiver>
That should not be hard, then.
07:39 * Mahal patpat Reiv
07:39
< McMartin>
Dealing with arguments is really the command shell's job.
07:39 * Reiver nods.
07:41
<@Reiver>
...
07:41
<@Reiver>
Is it possible to call methods inside a constructor?
07:41 * Reiver pokes.
07:42
<@Reiver>
It should be, surely.
07:42
< Vornicus>
Yes.
07:43
<@Reiver>
Is it possible to call a method declared public in the superclass when you are calling from the subclass constructor?
07:43
< Vornicus>
You can call methods from a constructor. Being inside the constructor means that all the variables are "set up" - allocated but not yet assigned to, so you get errors if you try to talk about it yet.
07:44
< McMartin>
So you have to be careful about doing so.
07:44
< Vornicus>
But you can assign stuff, and call methods as long as they only refer to things you've already assigned to.
07:44
< Vornicus>
It is possible to call superclass methods only after you call super()
07:46 * Reiver nods.
07:46
<@Reiver>
Ok, I got it.
07:46
<@Reiver>
Cheers
07:46
<@Reiver>
(It was giving me "Can't find this method!" errors. I had to rearrange a few things.)
07:47
<@Reiver>
Whoops, nope.
07:47
<@Reiver>
Still an undefined method type.
07:47
< Vornicus>
Show me.
07:47
<@Reiver>
Subclass constructor:
07:47
<@Reiver>
Rook(int newX, int newY, boolean side) {
07:47
<@Reiver>
super(newX, newY, side);
07:47
<@Reiver>
setType('r');
07:47
<@Reiver>
}
07:48
<@Reiver>
superclass method:
07:48
<@Reiver>
public char setType(char ch) {
07:48
<@Reiver>
if(Colour == BLACK)
07:48
<@Reiver>
type = ch;
07:48
<@Reiver>
else
07:48
<@Reiver>
type = character.toUpperCase(ch);
07:48
<@Reiver>
}
07:48
< Vornicus>
And the error?
07:49
<@Reiver>
"The method set setType is undefined for type Rook"
07:49
< Vornicus>
and do you actually say Rook extends Piece?
07:49
<@Reiver>
public class Rook extends Peice {
07:50
< Vornicus>
Oh, and why do you say setType returns a Char? It obviously isn't.
07:50
<@Reiver>
...
07:51
<@Reiver>
That may have been a Stupid(tm).
07:51
< Vornicus>
heh
07:51
< McMartin>
Shower time. Back in a bit.
07:51
< Vornicus>
should be void, probably.
07:51
<@Reiver>
is now yes
07:51 * Reiver pause, poke again.
07:52
<@Reiver>
Have changed it to "Peice.setType('r');" for a lark.
07:52
<@Reiver>
New error:
07:52
< Vornicus>
Old error: LEARN TO SPELL
07:52 * Reiver pthbt.
07:52
< Vornicus>
YOu will save your maintenance coders a lot of grief.
07:52 * Reiver may consider hitting "Refactor -> change all words Peice to Piece" before handing it in. >.>
07:53
<@Mahal>
Dyslexia is a bitch, huh? :)
07:53
<@Mahal>
(... is it you that's dyslexic?)
07:53
<@Reiver>
...Sort of.
07:53
<@Reiver>
Yes, but I've learned to cope
07:54
<@Reiver>
But catch is I hardwired the ei ie /the wrong way round/.
07:54
<@Mahal>
... oh dear :)
07:54
<@Reiver>
Theif Deity Peice Reiver...
07:54
<@Reiver>
Catch is the last one is correct. >.>
07:54 * Reiver can't think of any other examples, but he just... /does that/.
07:54
< McMartin>
You got Deity right too.
07:55
<@Reiver>
I'm told that one is either-or.
07:55
<@Reiver>
But.
07:55
< McMartin>
No.
07:55
< McMartin>
Agnus Dei.
07:55
<@Mahal>
Deity = Deity not Diety.
07:55
< McMartin>
Diety is like, using Splenda instead of Saccharine.
07:55
<@Reiver>
Oh.
07:55 * Reiver snerrrk
07:55 * Mahal grin
07:55
<@Reiver>
I didn't know that one. Always get shouted at it.
07:57
<@Reiver>
"Cannot make a static reference to the non-static method setType from the type Peice"
07:57
<@Reiver>
...Oh, don't tell me setType is already taken by another command somewhere.
07:57 * Reiver chanegs the name to see if it make any diff.
07:57
< McMartin>
How did you invoke setType again?
07:58
< McMartin>
No, that looks OK
07:58
< McMartin>
Character needs to be capitalized, mind you
07:58
< McMartin>
THe error implies you've called "Peice.setType" somewhere.
07:58
< Vornicus>
Yeah, that's how he tried to fix it.
07:58
< McMartin>
Which isn't allowed. You have to call it on a real one.
07:59
< Vornicus>
I'm trying to figure out what's wrong with the original.
07:59
< McMartin>
"character" is not capitalized like it should be.
07:59
<@Reiver>
It is in the code, sorry
08:00
< McMartin>
What line number has the error?
08:00
<@Reiver>
public class Rook extends Peice {
08:00
<@Reiver>
Rook(int newX, int newY, boolean side) {
08:00
<@Reiver>
super(newX, newY, side);
08:00
<@Reiver>
setType('r');
08:00
<@Reiver>
}
08:00
<@Reiver>
(Have since removed the Peic.setType back to setType)
08:01
< McMartin>
That's four lines.
08:01
<@Reiver>
It's erroring on 'setType', complaining it's undefined.
08:01
< McMartin>
... Does Peice.java compile?
08:02
< McMartin>
Java's dependency management leaves a bit to be desired.
08:02
< McMartin>
Or, rather, Javac's does.
08:02
< McMartin>
A full Java development platform includes Ant and somebody who can make it work.
08:03 * Vornicus is apparently part of a full java development platform.
08:03
< Vornicus>
better than being part of this complete breakfast, I guess.
08:05
<@Reiver>
Hrm, no it doesn't compile witout error.
08:05 * Reiver pokes.
08:05
<@Reiver>
Why is Chessboard.BLACK no worky, I wonder...
08:05 * Reiver checks his imports.
08:05
< McMartin>
... what directory are you in, and what's your classpath?
08:05
< McMartin>
try "cd .." and then "javac chs/*.java"
08:06
<@Reiver>
Well, I'm in windows for a start >.>
08:06
< McMartin>
OK, make that javac chs\*.java
08:06
<@Reiver>
From commandline?
08:06
<@Reiver>
Or from somewhere clever in Eclipse?
08:06
< McMartin>
What are you using?
08:06 * Reiver coughs.
08:06
<@Reiver>
Eclipse.
08:06
< McMartin>
Ah, Eclipse.
08:06
< McMartin>
Um
08:06
< McMartin>
How many Problems are listed?
08:06
< McMartin>
And why isn't it highlighting errors instantly?
08:06
<@Reiver>
one
08:07
<@Reiver>
And yes it is highlighting instantly.
08:07
<@Reiver>
This is why I'm poking at it and wondering.
08:07
< McMartin>
Hit Ctrl-Shift-O to fix all imports.
08:07
< McMartin>
And, if Peice.java had problems, how can you have had issues in Rook.java?
08:07
< McMartin>
And still only have one issue?
08:08
<@Reiver>
Still only one issue.
08:08
< McMartin>
So, the one in Rook went away?
08:08
< McMartin>
What did you change?
08:08
<@Reiver>
package chs;
08:08
<@Reiver>
>.<
08:09 * Reiver forgot to add it to the subclass.
08:09
< McMartin>
All your files should have that at the start.
08:09
<@Reiver>
Okay.
08:09
< McMartin>
And I'm really rather surprised Eclipse didn't create that line for you.
08:09
<@Reiver>
I, er, forgot that subclass != importing imports.
08:09
<@Reiver>
(And it usually does which is why I never clicked. >.<)
08:09
< McMartin>
Everything's in the same package, and so no imports should ever be necessary.
08:10
< McMartin>
Across your code so far, anyway
08:10
<@Reiver>
Chessboard.BLACK cannot be resolved...
08:11
< Vornicus>
show me the code.
08:11
<@Reiver>
In Chessboard:
08:11
<@Reiver>
public static final boolean BLACK = true;
08:11
< Vornicus>
previous line.
08:11
<@Reiver>
public class Chessboard {
08:11
<@Reiver>
private Peice[][] boardArray = new Peice[8][8]; // 8x8 array of null
08:11
<@Reiver>
public static Chessboard instance = new Chessboard();
08:11
<@Reiver>
public static final boolean BLACK = true;
08:11
<@Reiver>
public static final boolean WHITE = false;
08:12
< Vornicus>
...shit, I don't know.
08:12
< Vornicus>
zap gremlins.
08:12
< McMartin>
Type Chessboard. and see what it offers as completions.
08:13
< McMartin>
Do a Build All and see what all breaks
08:13
< McMartin>
You really should have more than one error message at once here.
08:13
<@Reiver>
It is puzzling.
08:14
<@Reiver>
(Where is "Build all" command?)
08:14
< Vornicus>
time for bed.
08:14
<@Reiver>
Ni, Vorn
08:14
<@Reiver>
Thank you for the help.
08:16 Vornicus is now known as Vornicus-Latens
08:16
<@Reiver>
...O-kay
08:17
<@Reiver>
chs.Chessboard.BLACK works.
08:17
<@Reiver>
It has package chs; at the top of that file, though.
08:17
<@Reiver>
Oh.
08:17
<@Reiver>
No, that didn't fix it.
08:18 * Reiver puts those constants back in at the top of the file and declears "I can tidy you up later".
08:40
<@Reiver>
...Except that you're doing it to my other methods too.
08:40
<@Reiver>
Selectively.
08:40
<@Reiver>
wtf?
08:40
< McMartin>
You don't have a "Build All" button
08:40
< McMartin>
?
08:40
< McMartin>
Not to sound like an idiot, but, uh, this is a Java Project and not some other kind, right?
08:41
<@Reiver>
Oh, fixed.
08:42
< McMartin>
Your Eclipse is not behaving in a manner I consider consistent with my experience with the platform.
08:43
<@Reiver>
Actually I was missing a semicolon in another place which was messing up the /other/ method... but where would I find the 'build all' button?
08:43
< McMartin>
Under "Project".
08:44
< McMartin>
How many /warnings/ do you have?
08:48
<@Reiver>
"Project" has it greyed out.
08:48
< McMartin>
...
08:48
<@Reiver>
And no warnings.
08:48
< McMartin>
Give me a screenshot of your Eclipse, please. You have it configured wrong.
08:48
< McMartin>
Or rather, I suspect you may.
08:49
<@Reiver>
With any menu bar or dialogue in particular open?
08:49
< McMartin>
Package Explorer.
08:49
< McMartin>
Though if you have access to the Package Explorer, the biggest problem probably isn't a problem.
08:50
<@Reiver>
http://vorn.dyndns.org/theonewiki/Chess?action=AttachFile&do=view&target=Eclipse .png
08:51
< McMartin>
All right.
08:51
<@Reiver>
This is wrong?
08:51
< McMartin>
No, it looks fine. But now I'm wondering how the *hell* it didn't catch your missing package statements as errors.
08:52
< McMartin>
You should have gotten multiple errors of the form "The declared package does not match the expected package 'chs'"
08:52
<@Reiver>
Oh.
08:52
<@Reiver>
Huh.
08:52 * Reiver dunno?
08:53
<@Reiver>
(Is it just me that is amused that it is the Pawn that is far and above the most complex peice to write rules for?)
08:54
< McMartin>
It's got the most special cases.
08:54
<@Reiver>
And very odd directional rules.
08:54
< McMartin>
Do you have to handle en passant captures and castling?
08:54
<@Reiver>
Nope!
08:54
<@Reiver>
Thank the gods.
08:55
<@Reiver>
Nor check.
08:55
<@Reiver>
(I asked about that one.)
08:55
< EvilDarkLord>
...that makes things pretty easy for the king.
08:55
<@Reiver>
Yes.
08:55 * Reiver grins.
08:55
<@Reiver>
The other way is not impossible, I note.
08:55
<@Reiver>
Given I will be writing a script to check all possible moves on the board for the AI...
08:55
<@Reiver>
I could just use that to check for verboten squares.
08:55
< McMartin>
Yeah, check wouldn't be tough to work out.
08:56
<@Reiver>
Etc.
08:56 * Reiver nods.
08:56
< McMartin>
Cycles Are Cheap
08:56
<@Reiver>
But... no, don't have to. Ergo, yey!
08:57
< EvilDarkLord>
En passant isn't that bad either. Several ways to do it. But since similar sentiments apply, yey!
08:58
<@Reiver>
Yus.
08:58
< EvilDarkLord>
So er. Are random unexplained errors your main problem at the moment?
08:59
<@Reiver>
They're McM's, it appears... >.<
08:59
<@Reiver>
I've cleared them off for the moment.
08:59
<@Reiver>
Am now doing the math for pawns.
08:59
<@Reiver>
They are proving... somewhat inconvinient. But will not be once I figure out how to get the blasted directional thingy working.
08:59
<@Reiver>
...Actually, that's just... hrmmmm.
08:59
<@Reiver>
Hey, McM?
09:00
<@Reiver>
If I set a private final instance variable inside the pawn subclass, is that allowed to be a different value in different pawns?
09:00 * Reiver is thinking of having a DIRECTION value or something, +1 if white, -1 if black.
09:02
< McMartin>
Yes, but you only get to assign it once.
09:03 * Reiver pauses, ponders.
09:03 * Reiver checks something.
09:03
<@Reiver>
Ah!
09:03
<@Reiver>
Yes. Of course I have that detail.
09:04
<@Reiver>
private final DIRECTION = colourDirection();
09:51
<@Reiver>
...Hrm.
09:51
<@Reiver>
Pawns are tricky.
09:56
<@Reiver>
...Simple fencepost question.
09:56
<@Reiver>
There are 8 squares on the chessboard.
09:56
<@Reiver>
Being an array, they start at 0.
09:56
<@Reiver>
I am trying to have a method measure "Squares from [players] side", for use with pawns.
10:07
<@Reiver>
Eh, no, it's fine.
10:07
<@Reiver>
But, argh!
10:07
<@Reiver>
Severity and Description Path Resource Location Creation Time Id
10:07
<@Reiver>
Cannot make a static reference to the non-static method isClear(int, int) from the type Chessboard Chess/chs Pawn.java line 17 1156237631333 146
10:07 * Reiver stabs, tries to work out what's up.
10:09 * Mahal huggles Reiv
10:09
< McMartin>
You did Chessboard.isClear(), instead of Chessboard.instance.isClear().
10:10
<@Reiver>
...
10:10
<@Reiver>
Stupid me, I did too.
10:10
<@Reiver>
Thank you.
10:11
< McMartin>
That error always means that, idly~
10:11
<@Reiver>
Thankye. :)
10:11
<@Reiver>
if((xOffset(newX) == 0 && newY == posY+pawnDirection && checkPath(newX, newY+pawnDirection) || //normal movement: One square advance, no obstruction in destination square (checkClear thus checks one square further ahead than usual.)
10:11
<@Reiver>
(xOffset(newX) == 0 && posY == pawnRow(2) && newY == posY+2 && checkPath(newX, newY+1)) || //starting square movement: Two squares advance, no obstruction in destination square or traveled square. (checkClear thus checks one square further ahead than usual.)
10:11
<@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).
10:12
<@Reiver>
checkDestination returns true if there is either null, or an opposing peice (As it's usually okay to move to a square that can make a capture, or is empty).
10:13
<@Reiver>
Should I instead be over-writing checkDestination with a different rule that misses out the 'null' bit?
10:13
<@Reiver>
It seems vaugely more using-inheritances, but also strikes me as needless work.
10:13
<@Reiver>
But then, teachers love that stuff right?~
10:17 * Reiver ponders queening, and king capture. It is tempting to make them part of the MoveTo(); command. But isn't it better OO to have the rules regarding each peice as part of that peice?
10:19
<@Reiver>
Chessboard has the movePeice command. For those two bits, if one moves somewhere special, it turns into a different peice. If the other is moved /onto/, game ends...
10:35 Mahal [~Mahal@Nightstar-5107.worldnet.co.nz] has quit [Quit: sleeping time.]
11:01
<@Reiver>
Got it.
11:01
<@Reiver>
Ho-kay.
11:02 * Reiver hrmms.
11:02
<@Reiver>
That's the peice rules.
11:02
<@Reiver>
Now I need to program the player object so I can give it instructions~
11:02 * Reiver fiddles.
11:02 * Reiver hrms.
11:03
<@Reiver>
What would be ideal would be if you could do Player play1 = new Player(args[0]);
11:04
<@Reiver>
And then have the Player class itself work out if it needs to be a subclass ComputerPlayer, or HumanPlayer...
11:04
<@Reiver>
...But you've already created the object by that point.
11:05 * Reiver frowns. Unless you can have a constructor inside a creating object change the class, you really need to have the object type decleration /outside/ the object...?
11:09
<@Reiver>
...Actually, what you want is.
11:09 * Reiver hrm.
11:09
<@Reiver>
You want a CurrentPlayer... object? Or is that just held in Main?
11:10
<@Reiver>
Or do you have one Player object/interface(?), that spawns two PlayerType objects (Which is where you get your subclasses from?)
11:43 Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout]
11:54 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
11:54 mode/#code [+o Chalcedon] by ChanServ
12:06 himi [~himi@Nightstar-29007.ACT.netspace.net.au] has joined #code
12:08
< himi>
Fire away . . .
12:09
<@Reiver>
Okay.
12:09
<@Reiver>
I am creating a chessboard.
12:09
<@Reiver>
I have created the board itself, and the rules for the peices.
12:09
<@Reiver>
(I hope, anyway.)
12:09
<@Reiver>
(We'll see if they work right, um, later.)
12:10
<@Reiver>
However, what I am currently trying to program is the interface to the rules - the players.
12:10 * himi nods
12:10
< EvilDarkLord>
How far along on this are you?
12:10
<@Reiver>
There are two types of player - an AI, whose actual methodology I know how to do, and Human, whose general input/output I have arranged as well.
12:11
<@Reiver>
I'm thinking the two types should be subclasses of the general Player class.
12:11
<@Reiver>
...But how to initalise the two is a bit beyond me.
12:12
< himi>
This, unfortunately, is also beyond me
12:12 * himi hasn't done any java in a /long/ time
12:13
< EvilDarkLord>
Er. Initialising as in Player player = new Player(AI); ?
12:13
<@Reiver>
Okay.
12:13
<@Reiver>
EDL: There are three possible modes of play, all set at runtime. Um.
12:14
<@Reiver>
The game is started like thus: ChessGame x x
12:14
<@Reiver>
x is either h or c
12:14
<@Reiver>
h h is himan input for both sides.
12:14 * EvilDarkLord nods, gets.
12:14
<@Reiver>
h c is human input for one, AI for the other
12:14
<@Reiver>
c c AI plays both.
12:15
<@Reiver>
I need to ponder two things: Is CurrentPlayer an object, or is that just part of Main, or...
12:15 * Reiver ...
12:15 * Reiver wonders if that is a good idea or not.
12:16
<@Reiver>
Creating and destroying the objects as you go... so you have CurrentPlayer as your only object, and it calls human or AI objects as the turns switch.
12:16
< EvilDarkLord>
This works like a normal chess game, with turns shifting after each move?
12:17
< himi>
That sounds overly complicated
12:18
< EvilDarkLord>
private boolean whitesturn;
12:18
< himi>
Why would you do that?
12:18
<@Reiver>
himi: Because then it makes initialising which player does what much more straight forward.
12:19
< himi>
. . . . how?
12:19
< EvilDarkLord>
So you have Player objects?
12:19
<@Reiver>
You'd have a CurrentPlayer object.
12:19
< himi>
Aren't you just feeding input from somewhere into the game engine?
12:19
<@Reiver>
Pretty much, yes.
12:19
<@Reiver>
It would flip between Player1 and Player2.
12:19
< himi>
You want an interface between some source of inputs, and some way to know who's turn it is
12:20
< himi>
erm
12:20
<@Reiver>
Yes.
12:20
< himi>
whose
12:20
< EvilDarkLord>
Why don't you stick Player1 and Player2 in an array and work with that?
12:20
<@Reiver>
That's not teh hard part, EDL
12:20
< himi>
Implement the AI player as a source of inputs, not as a "player"
12:21
<@Reiver>
Planning to, himi
12:21
<@Reiver>
Both will simply be methods of inputting valid moves to the game, basically.
12:21
<@Reiver>
AI runs an automated script to do so, Human parses the commands.
12:21
<@Reiver>
>.>
12:21
< himi>
So, all you need to do is have a loop which does a get_next_command()
12:22
<@Reiver>
Basically.
12:23
< himi>
get_next_command() pulls from whatever the value of a static turn tracker points to
12:23
< himi>
Behind that is either an interface to the user, or the AI player
12:24
< himi>
. . . . and I'll be damned if I know how to do that in a perfectly OO way without giving it lots more thought, but hey, that's /your/ problem ;-P
12:24
<@Reiver>
It's the interface approach that throws me, yeah. >.>
12:24
< himi>
/Don't/ create new objects at every turn
12:24
< himi>
That will make whoever reads your code feel ill
12:25
<@Reiver>
Aww.
12:25
< himi>
Yes, it's a worthy cause, but still - /don't/
12:25
<@Reiver>
so much for CurrentPlayer = new Player(Colour, playerType)
12:25
<@Reiver>
:p
12:26
< EvilDarkLord>
Brr.
12:26
< EvilDarkLord>
What kind of data does your Player object contain?
12:35 Serah [~Shemhazai@Nightstar-27025.bynxx4.adsl-dhcp.tele.dk] has joined #Code
12:35
<@Reiver>
...Mostly methods, really.
12:35
<@Reiver>
And player type.
12:36
<@Reiver>
Colour, type(Human/AI), and methods.
12:36
< Serah>
And ninjas.
12:37
<@Reiver>
...Quite.
13:02 Serah [~Shemhazai@Nightstar-27025.bynxx4.adsl-dhcp.tele.dk] has quit [Ping Timeout]
13:15 Serah [~Shemhazai@Nightstar-27025.bynxx4.adsl-dhcp.tele.dk] has joined #Code
14:11 * Reiver tries to work out how, exactly, try/catch statements work right.
14:14 * Serah is gonna jump.
14:17 * Reiver suggests you refrain; as he hasn't gotten very good at catching...
14:18 Serah [~Shemhazai@Nightstar-27025.bynxx4.adsl-dhcp.tele.dk] has quit [Ping Timeout]
14:42
<@ToxicFrog>
Reiver:
14:42
<@ToxicFrog>
try {
14:42
<@ToxicFrog>
/* block of code that might throw an exception */
14:42
<@ToxicFrog>
} catch(ExceptionType E) {
14:42
<@ToxicFrog>
/* block of code to handle E */
14:42
<@ToxicFrog>
}
14:43
<@ToxicFrog>
If the stuff inside the try block throws an exception, and there's a catch block with the right exception type (note that 'Exception' will catch everything, since all other exception types are subclasses of this), control will jump immediately to the start of the catch block.
14:44
<@Reiver>
Right.
14:44
<@Reiver>
Are you able to give pointers on how I should be initialising my Players?
14:44
<@Reiver>
I keep trying to make a CurrentPlayer object that flips between the two, and I'm not sure if that's genius or idiocy.
14:45
<@ToxicFrog>
Well. Concerning CurrentPlayer, make it a reference rather than an object in its own right.
14:45
<@ToxicFrog>
Player player1 = new HumanPlayer();
14:45
<@ToxicFrog>
Player player2 = new AIPlayer();
14:45
<@ToxicFrog>
Player currentPlayer = player1;
14:45
<@ToxicFrog>
/* ... stuff ... */
14:45
<@ToxicFrog>
currentPlayer = player2;
14:45
<@ToxicFrog>
Etc.
14:45
<@Reiver>
...
14:46 * Reiver ponders.
14:46
<@Reiver>
But, um.
14:46
<@ToxicFrog>
Yeeeeeees?
14:46
<@Reiver>
The type of each player depends on what is specified at startup.
14:46
<@ToxicFrog>
Yes, I know.
14:46
<@ToxicFrog>
I was just demonstrating.
14:46
<@Reiver>
Right
14:46
<@Reiver>
But it's that bit that catches me.
14:47
<@ToxicFrog>
In actuality you'd have something more like:
14:47
<@ToxicFrog>
Player player1;
14:47
<@ToxicFrog>
Player player2;
14:47
<@Reiver>
As I'm pretty sure you should have choosing what each /type/ of player is /inside/ the object, yesno?
14:47
<@ToxicFrog>
I did. Read the declarations again.
14:47
<@ToxicFrog>
for(int i = 0; i < argc; ++i) {
14:47
<@ToxicFrog>
if(String.equals("h", argv[i]) {
14:48
<@ToxicFrog>
players[i] = new HumanPlayer();
14:48
<@ToxicFrog>
} else {
14:48
<@ToxicFrog>
players[i] = new AIPlayer();
14:48
<@ToxicFrog>
}
14:48
<@ToxicFrog>
}
14:48
<@ToxicFrog>
And declare players as 'Player[] players = new Player[2];'
14:48 Chalcy [~Chalceon@60.234.221.ns-21239] has joined #code
14:48 mode/#code [+o Chalcy] by ChanServ
14:48 * Reiver blinks.
14:48
<@Reiver>
Wait.
14:48
<@ToxicFrog>
In practice of course you'd put some error checking in there and sutff.
14:49
<@Reiver>
So is that inside the Player class, or the Main class that grabs the args?
14:49
<@ToxicFrog>
So that entering 'ChessGame a b' gives you an error.
14:49
<@ToxicFrog>
...main.
14:49
<@Reiver>
Right.
14:49
<@Reiver>
It's not meant to be inside the Player as a constructor or other arcane tomfoolery?
14:49
<@ToxicFrog>
No.
14:49
<@Reiver>
(You know, keep object stuff within the object...)
14:49
<@Reiver>
Ah.
14:50
<@ToxicFrog>
Yes, but this isn't player-specific stuff.
14:50 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout]
14:50
<@Reiver>
That's what I was trying to do, and get up in knots over. >.>
14:50
<@Reiver>
It's not?
14:50
<@ToxicFrog>
"Who's playing" is a /game/ question, not a player question.
14:50
<@Reiver>
...
14:50
<@Reiver>
Of course it is. Thanks.
14:50
<@ToxicFrog>
"What move should I make" is a player question.
14:50 * Reiver nods.
14:52
<@ToxicFrog>
After that it's pretty much just:
14:52
<@ToxicFrog>
for(ever) {
14:52
<@ToxicFrog>
for(p in players) {
14:52 fhtagncaps [~scs105@Nightstar-20994.york.ac.uk] has joined #code
14:52
<@ToxicFrog>
p.doMoveThingy();
14:52
<@ToxicFrog>
insertVictoryCheckHere();
14:52
<@ToxicFrog>
}
14:52
<@ToxicFrog>
}
14:53
<@ToxicFrog>
!caps. Have a dwarf.
14:53
< fhtagncaps>
...
14:53
< fhtagncaps>
Is this some kind of obscure Java hacker's greeting?
14:54
<@ToxicFrog>
(1) I'm not a Java hacker, thank god and (2) no.
14:54
<@ToxicFrog>
I've been playing Dwarf Fortress.
14:54
<@Reiver>
OH!
14:54
<@Reiver>
Victorycheck.
14:54
<@Reiver>
And Queening.
14:54
< fhtagncaps>
Aha. And yes, I knew (1), I just thought I'd annoy you by implication.
14:54
<@ToxicFrog>
Under your modified rules, I think a victory check is just checking to see if one player is missing their king.
14:54
<@Reiver>
I was sorta wondering; I couldn't figure out how the hell you got them to to stay inside the Peice class along with the rest of the Peice-specific rules.
14:55
<@ToxicFrog>
Or, alternately, setting a flag when the king is taken and then checking that.
14:55 * Reiver nods. Aye.
14:55
<@ToxicFrog>
You don't. "Who won" is also a game question.
14:55
<@Reiver>
Queening is not a peice question?
14:55
<@ToxicFrog>
Queening is, I think.
14:55 * Reiver hmms. Actually, one /could/ put it into the class, but it'd be somewhat messy...
14:55
<@ToxicFrog>
But victory is not, although you may wish to have the king set a victory condition flag when taken.
14:55 * Reiver nods.
14:56
<@ToxicFrog>
Which makes checking easier (since you don't have to search the pieces for the king, just see if the flag is set)
15:00
<@ToxicFrog>
Onul Lularudib, Miner cancels task Contruct Building: interrupted by alligator.
15:05 * Reiver nods.
15:05
<@Reiver>
...
15:05
<@Reiver>
Ow.
15:07 * Reiver ponders the for loop TF suggested. Do you still need the Player player1; bit? It seems extraneous?
15:18
<@ToxicFrog>
No, you don't.
15:18
<@ToxicFrog>
I realized halfway through that it's easier to use an array of Player[2].
15:19 * Reiver nods.
15:20
< fhtagncaps>
(Which is what I suggested in #fleetdesign. Yayme.>.>)
15:21
<@Reiver>
(You so did!)
15:21 * Reiver patpat.
15:26
< himi>
hm
15:26
< himi>
Isn't this Java?
15:26
< himi>
Shouldn't you be raising an IWonMuahahaha exception?
15:27
< himi>
To break out of the loop, that is
15:28
<@Reiver>
Uh. Maybe.
15:30 * himi lobs a spanner in the direction of Reiver's head
15:30 * Reiver 's mind breaks, fragile as it is at 3AM.
15:30 * himi snickers
15:30
< himi>
2:30
15:30
< himi>
When's it due?
15:31
<@Reiver>
5PM tomorrow.
15:31
<@Reiver>
But more to the point I'm enjoying coding right now so I don't want to stop.
15:31
<@Reiver>
I could go to bed.
15:32
<@Reiver>
But I feel more productive now than I will be in the morning, so...
15:32
<@Reiver>
(I'm also pretty sure I'm getting close to finishing. I've been pottering at this for a couple weeks.)
15:32
< himi>
Just make sure you run the code you're writing now through a sanity check
15:32
<@Reiver>
It's very sane.
15:32
< himi>
You say this /now/
15:32
<@Reiver>
I just need to make sure the methods don't multiply too much and all will be well. ^^;
15:33
< himi>
Check again when you're properly awake
15:33
< himi>
Trust me on this
15:33 * Reiver , uh. Is somewhat chronic at the 'don't write the same line twice' mantra when he gets tired...
15:33 * Reiver once had more lines of C dedicated to calling and implimenting functions than he did actual code. >.>
15:33
<@Reiver>
Peoples minds sorta broke a lot.
15:33
<@Reiver>
But the functions were really short!
15:33
<@Reiver>
Um.
15:33
<@Reiver>
Yes.
15:34
< himi>
Keep writing while you're feeling productive, but make sure to sanity check
15:34
<@Reiver>
Yeah, I will.
15:37
< himi>
Okay, time for bed for me
15:37 himi is now known as himi-sleeping
15:39
<@ToxicFrog>
himi-sleeping: you'll note that I didn't specify how to leave the loop once victory was detected~
15:40
< himi-sleeping>
True . . .
16:16 Chalc [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
16:18 * Reiver fiddles.
16:18 Chalcy [~Chalceon@60.234.221.ns-21239] has quit [Ping Timeout]
16:33
<@Reiver>
Severity and Description Path Resource Location Creation Time Id
16:33
<@Reiver>
Illegal modifier for parameter currentPlayer; only final is permitted Chess/chs Chess.java line 10 1156260715629 205
16:34 * ToxicFrog eyebrows.
16:34
<@ToxicFrog>
How did you declare it?
16:36
<@Reiver>
Idiotically.
16:36 * Reiver carries on.
16:36 * Reiver pokes at a new thing.
16:36 * GeoTube watches it poke back, with a new script
16:37
<@Reiver>
for(int i = 0; i < args.length; i++) {
16:37
<@Reiver>
if(String.equals("h",args[i]))
16:37
<@Reiver>
Severity and Description Path Resource Location Creation Time Id
16:37
<@Reiver>
The method equals(Object) in the type String is not applicable for the arguments (String, String) Chess/chs Chess.java line 13 1156260922598 213
16:37
<@Reiver>
Whassit not reading the second object for?
16:37
<@ToxicFrog>
Umm.
16:37
<@Reiver>
Er. Second string.
16:38
<@Reiver>
Thing.
16:38
<@ToxicFrog>
Try: if(args[i].equals("h"))
16:38
<@Reiver>
...I knew that.
16:38
<@Reiver>
>.<
16:39
<@ToxicFrog>
I couldn't remember if it was public static bool String::equals(String, Object) or public bool String::equals(Object).
16:39
<@Reiver>
And because I was looking at written code rather than thinking about it properly I didn't pick up on it.
16:49
<@Reiver>
...So am I able to have public getters and setters in my primary class?
16:49
<@Reiver>
I have class Chess, with public static void main in it.
16:50
<@Reiver>
I stuck a public getCurrentPlayer() kinda method in.
16:50
<@Reiver>
Is giving me static-reference-type-errors...
16:50
<@ToxicFrog>
Chess's members have to be static.
16:51
<@ToxicFrog>
It's never instanced.
16:51
<@Reiver>
Oh, bugger.
16:51
<@Reiver>
So how do I obtain the current player from this game, then?
16:52
<@ToxicFrog>
You declare that static too.,
16:52
<@Reiver>
...Right.
16:52
<@Reiver>
Yes, that'd make sense.
16:53
<@ToxicFrog>
(this is not net3d; static means something completely different from const)
16:53
<@Reiver>
Means "Global".
16:53
<@Reiver>
Final -> Const.
16:53
<@Reiver>
But man is it easy to mix up. >.>
16:53
<@ToxicFrog>
No, it doesn't.
16:54
<@ToxicFrog>
It means tied to the class definition rather than any specific instance of the class.
16:57
<@Reiver>
augh...
16:57
<@Reiver>
Severity and Description Path Resource Location Creation Time Id
16:57
<@Reiver>
Cannot make a static reference to the non-static method sideColour() from the type Chess Chess/chs Chessboard.java line 92 1156262178489 239
16:58
<@Reiver>
Does everything in the Chess class need to be explicitly static?
16:58
<@Reiver>
...Wait, it already is...
16:58 * Reiver unstatics it to see.
16:59
<@Reiver>
Nope, don't help. Must be something else I'm doing.
16:59 * Reiver pokes at it.
16:59
<@ToxicFrog>
Stuff that's nonstatic can't be referred to without error.
16:59
<@ToxicFrog>
Since it's never instanced, so all you can access are the static members.
16:59
<@Reiver>
Ok.
17:00
< Syloqs-AFH>
Because if dont use a dryer sheet then static members get all that built up charge.
17:00
<@Reiver>
So how does one read the thingy from the whatsit?
17:00
<@Reiver>
...
17:00
<@Reiver>
Ok, I am going to go to bed soon.
17:00 * Reiver tries again.
17:01
<@Reiver>
I need to be able to get the currentPlayer() so that I can compare it to peices on the board.
17:01
<@Reiver>
So that I can tell if they're a legit peice to be moving or not.
17:01 himi-sleeping [~himi@Nightstar-29007.ACT.netspace.net.au] has quit [Ping Timeout]
17:02
<@Reiver>
I can't do this if currentPlayer() is static? And I can't have something in the Chess method without it being also static? If this is the case, what should I be doing? This seems all very odd. >.>
17:03
<@ToxicFrog>
currentPlayer has to be static if it's part of Chess.
17:03
<@ToxicFrog>
You'd do something like:
17:03
<@ToxicFrog>
public static Player current_player;
17:03
<@ToxicFrog>
public static Player currentPlayer() { return current_player; }
17:03 himi-sleeping [~himi@Nightstar-29007.ACT.netspace.net.au] has joined #code
17:05
<@Reiver>
Aha.
17:05
< fhtagncaps>
...how /were/ you doing it?
17:05
<@ToxicFrog>
What were you doing?
17:05 * Reiver had thought for some reason you couldn't do that... something about not being able to reference instance variables from statics.
17:05
<@ToxicFrog>
That is correct.
17:05
<@ToxicFrog>
You cannot reference instance variables from static member functions of the same class.
17:06
<@Reiver>
So I'd put the public static current_player in the wrong spot. ^^;
17:06
<@Reiver>
Ok.
17:06
<@Reiver>
Theoretically
17:06
<@ToxicFrog>
However, current_player is not an instance variable, it's a static member variable.
17:06
<@Reiver>
Right - I'd messed that bit.
17:06
<@Reiver>
One more class/method thing to code the framework for, and we should be on the home straight.
17:06
<@Reiver>
(Ahahahahaha I'm funny.)
17:07
<@Reiver>
(This would involve me not finding any bugs written in a program that has been primarily coded in the hours of midnight to 2AM over several consecutive weeks.)
17:07
<@Reiver>
(Yes. Um. ¬¬)
17:08
<@ToxicFrog>
17:11 Vornicus [~vorn@Nightstar-18307.slkc.qwest.net] has joined #code
17:11 mode/#code [+o Vornicus] by ChanServ
17:15
<@Reiver>
VORN
17:16
<@Vornicus>
meep
17:19
<@Vornicus>
yes?
17:21 * Reiver mostly just huggles hello. :)
17:21
<@Reiver>
hm
17:22
<@Reiver>
ArrayList<Peice> peiceList = new ArrayList;
17:22
<@Reiver>
What stupid have I done now to make the 'new' not parse right...
17:23
<@Vornicus>
YOu need to use the template in the newification too.
17:23
<@Vornicus>
ArrayList<Piece> piece_list = new ArrayList<Piece>
17:24
<@Reiver>
Ohhh. Whups.
17:25
<@Reiver>
...Didn't like that.
17:25 * Reiver frown.
17:30
<@Vornicus>
ArrayList<Piece> piece_list = new ArrayList<Piece>(); <--- try that.
17:31
<@Reiver>
...done. *sigh* I am not seeing the silly errors, I apologise.
17:31
<@Reiver>
Hrm.
17:31 * Reiver tries to remember how you iterate through the bloody lists, now, in order to generate a valid set of moves.
17:33
<@Reiver>
Iterator! Or not.
17:35
< Syloqs-AFH>
piece_list[index] ?
17:35
< Syloqs-AFH>
thats a simple way
17:38
<@Reiver>
Arraylists don't work like that, do they?
17:38
<@Reiver>
...ANd I hope to god I got this right the first time through because man oh man... o.o
17:38
<@Reiver>
public void setMove() {
17:38
<@Reiver>
17:38
<@Reiver>
for(int y=0;y<8;y++) {
17:38
<@Reiver>
for(int x=0;x<8;x++) {
17:38
<@Reiver>
if(Chessboard.instance.getSquare(x, y).getSide() == Chess.currentPlayer()) {
17:38
<@Reiver>
for(int i=0;i<8;i++) {
17:38
<@Reiver>
for(int j=0;j<8;j++) {
17:38
<@Reiver>
if(Chessboard.instance.getSquare(x, y).isLegal(j, i))
17:38
<@Reiver>
peiceList.add(Chessboard.instance.getSquare(x, y));
17:38
<@Reiver>
} //end x loop of move check
17:38
<@Reiver>
} //end y loop of move check
17:38
<@Reiver>
} //end if
17:38
<@Reiver>
} //end x loop of peice check
17:38
<@Reiver>
} //end y loop of peice check
17:38
<@Reiver>
} //end method
17:39
<@Vornicus>
...that looks right
17:39
<@Reiver>
Go through the board, check to see if there's a peice that matches your colour.
17:39
<@Vornicus>
...except that it's a n^4 algorithm even before you get to the intermediaries check.
17:39
<@Reiver>
If so, throw every possible destination square at that peice to see if it's legal.
17:40
<@Reiver>
Vorn: Yes, I realise this. >.>
17:40 Schlock [~schlock@Nightstar-6915.hsd1.or.comcast.net] has joined #code
17:40 mode/#code [+v Schlock] by ChanServ
17:40
<@Reiver>
!roll 16*64
17:40
<+Schlock>
Dice Rolled For Reiver: 16*64 = 1024
17:40
<@Reiver>
But there's only ever 16 peices of one side on the board at a time.
17:41
<@Reiver>
Actually it would be 17*64, because you have to read the entire board once to find the peices.
17:41
<@Reiver>
But.
17:42
< Syloqs-AFH>
heh, looks cpu intensive...
17:42
<@Reiver>
A thousand cycles per AI move.
17:43
<@Reiver>
I think, given modern machinery, we can probably handle it. >.>
17:43
<@Reiver>
...I /hope/, given modern machinery, we can handle it...
17:43
<@ToxicFrog>
A thousand operations.
17:43
< Syloqs-AFH>
Is it calculating just its move or trying to make a decision?
17:43
<@ToxicFrog>
That's a lot more than a thousand cycles.
17:43
<@Reiver>
Point
17:43
<@ToxicFrog>
Some of those will be more than one cycle to begin with, and furthermore they're executing inside the JVM, causing massive bloat.
17:43
<@Reiver>
Syloq: Just calculating possile moves.
17:44
<@ToxicFrog>
But it still shouldn't be a problem on modern hardware.
17:44
<@Reiver>
So.
17:44
<@Reiver>
How do I /randomly/ pick a reference from inside an ArrayList?
17:45
< Syloqs-AFH>
heh, crazy
17:45
<@Reiver>
I can theoretically generate the random number... I just need to remember how one digs up ArrayList[x].
17:45 * Reiver ponders, looks up the documentation again, because it should be there.
17:45
< Syloqs-AFH>
doesn't arraylist have a count?
17:45
<@Reiver>
I know it has a .length
17:46
< Syloqs-AFH>
probably is a similar effect
17:46
<@Reiver>
So you can go (int) Math.random * peiceList.length to get your random number.
17:46
<@Reiver>
Ah!
17:46
<@Reiver>
Get.
17:46
< Syloqs-AFH>
i'm pretty sure you can select a range to get a number from..
17:47
<@Reiver>
Amazingly complex that was.
17:47 * Reiver was searching for getIndex and wondering why it was the wrong thing...
17:50
<@Reiver>
Hm! A fatal flaw.
17:50
<@Reiver>
I need a Move object - because a Peice does not store where it would /go/, only where it /is/.
17:51
<@Reiver>
So saving that data is something of a waste of time.
17:59
<@Reiver>
moveList.add(new AIMoves(x,y,j,i));
17:59
<@Reiver>
Replacing the peiceList line in the aforementioned loops.
18:12
<@Reiver>
Ok!
18:12
<@Reiver>
Now to, um.
18:12
<@Reiver>
Make the program work. >.>
18:12
<@Reiver>
Lesse.
18:13
<@Reiver>
It declares the player objects. This is good.
18:13
<@Reiver>
Now it needs to... take turns! Right! Amazing that.
18:18
<@Vornicus>
yey
18:19
<@Reiver>
...Oh, Vorn? I dunno how much of the code you need for it, but
18:19
<@Reiver>
I have a function I am not sure will work, not least due to fencepost errors.
18:19
<@Reiver>
You too busy to have a poke? You seem good at the mathy-kinda-stuff.
18:21
<@Vornicus>
I'm not too busy. I'm waiting for someone else to get off the phone so I can make a phone call so I can save the universe, but other than that.
18:21
<@Reiver>
protected boolean checkPath(int destX, int destY) {
18:21
<@Reiver>
int x = posX;
18:21
<@Reiver>
int y = posY;
18:21
<@Reiver>
int distance = getDistance(destX, destY);
18:21
<@Reiver>
int deltaX = direction(posX, destX);
18:21
<@Reiver>
int deltaY = direction(posY, destY);
18:22
<@Reiver>
18:22
<@Reiver>
for(int i = 0; i<distance; i++) {
18:22
<@Reiver>
x += deltaX;
18:22
<@Reiver>
y += deltaY;
18:22
<@Reiver>
if(!Chessboard.instance.isClear(x,y))
18:22
<@Reiver>
return false;
18:22
<@Reiver>
}
18:22
<@Reiver>
return true;
18:22
<@Reiver>
}
18:22
<@Reiver>
...You probably could do with some of the methods couldn't you.
18:23
<@Reiver>
('pos' is the current position, 'dest' is the desired destination.)
18:26
<@Reiver>
I'm also quite sure that it is a rather clumsy way of doing things, but.
18:30
<@Vornicus>
gimme a couple minutes
18:31
<@Reiver>
NP!
18:49
<@Vornicus>
Hokay. I need getDistance and direction.
18:50 * fhtagncaps ponders that code.
18:50
<@Vornicus>
...looks like direction returns one of -1 0 1
18:50
< fhtagncaps>
Is it just me, or is that broken for non-orthodiagonal moves? (Not that that's a problem for chess, but...)
18:50
< fhtagncaps>
Vorn: this is what I assume, yes.
18:50
<@Vornicus>
It is broken for non-orthodiagonal moves.
18:51
<@Vornicus>
...I don't see any problems with that code. If you had more time I would say unit test aggressively.
18:59
<@Reiver>
Direction returs -1 0 +1 yes
18:59
<@Reiver>
protected int getDistance(int destX, int destY) { //determines the number of squares between the target peice and the destination peice.
18:59
<@Reiver>
return Math.max(Math.abs(xOffset(destX)), Math.abs(yOffset(destY)));
18:59
<@Reiver>
}
18:59
<@Reiver>
19:00
<@Reiver>
Offset is simply oldX-newX.
19:00
<@Reiver>
etc
19:24
<@Reiver>
My code is not working.
19:24 * Reiver pokes at it.
19:24
<@Reiver>
Why are you not working, you naughty code?
19:24
<@Reiver>
One minute an infinite loop, the next minute null reference pointers.
19:25
<@Reiver>
$#@! input method we're not allowed to fiddle with, yet not explaining exactly how we're meant to utilise it... clearly, I did a booboo.
19:56 Reiver is now known as ReivZzz
20:45 Mahal [~Mahal@Nightstar-5107.worldnet.co.nz] has joined #code
20:45 mode/#code [+o Mahal] by ChanServ
21:00 EvilDarkLord is now known as EvilAwayLord
21:35
<@Vornicus>
Ah, unit testing the internet.
21:35
<@Vornicus>
"Cannot resolve " + address + " but I expected to be able to."
21:36
<@Vornicus>
and the opposite: "Can resolve " + address + " but I expected to not be able to." ... though I don't know why that would happen.
21:39
< fhtagncaps>
Possibly an invalid IP address range?
21:40
<@Vornicus>
I guess it's the wrong name. It's a hostname.
21:40
<@Vornicus>
If your DNS is saying "yeah that exists" for nowhere.zz, there is something /seriously/ wrong.
21:41
< McMartin>
Somebody h4xx0r3d your routing tables?
21:41
<@Vornicus>
indeed
21:43
<@Vornicus>
someone set up us the dns spoof.
21:59
<@Vornicus>
muchos muchos grande pantusos!
21:59 Chalc is now known as Chalcedon
22:42
<@Mahal>
Perl.
22:42
<@Mahal>
Who knows any perl.
22:45
<@Vornicus>
Not me, thankfully.
22:45
<@Mahal>
Rats.
22:47
< fhtagncaps>
TW knows Perl, but he probably won't be accessible for another 12 hours or so.
22:47
<@Mahal>
Is cool :)
22:47
<@Mahal>
Is no rush, i"m just... poking a script, wondering how to alter it.
22:54
<@ToxicFrog>
Rewrite it something other than perl~
22:55
<@Mahal>
I acquired it, and it works as is :)
22:55
< fhtagncaps>
Like Lua?~
22:55
<@Mahal>
I just want to poke at it.
22:56
<@Mahal>
PHP is the only language I know vaguely well, and i"m not funcitonal enough in it to use that anyway, so.
22:59
<@Vornicus>
Ruby~
22:59
< fhtagncaps>
Python~
22:59
<@Vornicus>
<McM> Inform 7~
23:00 * Vornicus meanieheads all over the channel.
23:00 * Mahal grin
23:00
< fhtagncaps>
I'm waiting for someone to write a useable non-IF game in any dialect of Inform.
23:00
< fhtagncaps>
(That's not me being snarky, it's me stating a genuine expectation that it will happen.)
23:01
<@Vornicus>
Someone implemented d20 combat.
23:01
< fhtagncaps>
Not bad.
23:01
<@Vornicus>
Rather, it's a worked example in the documentation.
23:01
< fhtagncaps>
...it is?
23:05
<@Vornicus>
http://inform-fiction.org/I7Downloads/Examples/rota/ <--- I believe this is it.
23:05 ReivZzz is now known as Reiver
23:06
< fhtagncaps>
Cool.
23:06 * Reiver enquires with teh Vorn, who was poking at code last night?
23:07
<@Vornicus>
which code was this?
23:08
<@Reiver>
Er. The checkClear funcion?
23:08
<@Vornicus>
Oh, that code. It looks fine. Though... I don't know if you're checking if it's orthodiagonal elsewhere, because this code breaks if it's not.
23:09
<@Reiver>
orthodiagonal, as in 45 degree?
23:09
<@Reiver>
If so, yes.
23:09
< McMartin>
fhtagncaps: The most famous non-IF in Inform is the first one, called "Freefall".
23:09
< McMartin>
Saying what it is would spoil the effect, so I'll just link it:
23:10
<@Vornicus>
orthodiagonal, as in you're going along one of the cardinal or secondary compass points.
23:10
< McMartin>
http://ifarchive.heanet.ie/if-archive/games/zcode/freefall.z5
23:10
<@Reiver>
isStraight and isDiagonal are used - and this checkClear is only used in methods where those are also called, yes.
23:10
< McMartin>
(Looking up the "Z-Abuse" genre will give many more.)
23:11
<@Vornicus>
I have on one occasion attempted to use Inform 7 to make an interface prototype.
23:11
<@Reiver>
(The only case where they aren't is Knights, and they don't collision detect.)
23:11
<@Reiver>
Vorn: Does the code check between point X1, Y1, and X2, Y2?
23:11
<@Vornicus>
It does appear to, yes.
23:11
<@Reiver>
Or does it check a starting point or end point?
23:11
< McMartin>
I7 isn't very good for direct screen control; at least not to the extent that I6 is.
23:11
<@Reiver>
'cuz it's the fencepost errors that'll getcha. >.>
23:11
<@Vornicus>
THough, again, I would highly recommend unit testing aggressively.
23:11 * Reiver nods.
23:11 * Reiver er.
23:12
<@Reiver>
Speaking of unit testing, I had an infinite loop, and I've broken my code in fixing it. >.<
23:12
<@Reiver>
It's mostly the input-text-parser that's throwing me.
23:12
<@Reiver>
As it would appear to not be doing what I was hoping it would do~
23:14
<@Reiver>
Exception in thread "main" java.lang.NullPointerException
23:14
<@Reiver>
at chs.Human.parseInput(Human.java:38)
23:14
<@Reiver>
at chs.Human.setMove(Human.java:12)
23:14
<@Reiver>
at chs.Chess.main(Chess.java:20)
23:14
< McMartin>
What's at Human.java:38?
23:15
<@Reiver>
The first line of my string parser.
23:15
<@Reiver>
locX = Character.getNumericValue(input.charAt(0)-'a');
23:15
< McMartin>
Where is "input" defined?
23:17
< fhtagncaps>
In fact, /is/ "input" defined?
23:17
< fhtagncaps>
(Incidently, McM, freefall is... awesome.)
23:17
< GeoTube>
maybe it is procedulary generated!
23:19
<@Reiver>
Innstance variable.
23:19
<@Reiver>
It supposedly has input piped to it by the text input method we have to use.
23:19
< McMartin>
What's the line that you think is assigning it?
23:19
<@Reiver>
My code is breaking before it gets to that point, though...
23:19
<@Reiver>
(As it is breaking on runtime, without typing.)
23:19
< McMartin>
input is null, which means it's either being assigned "null" or it's never being assigned at all
23:24 * Reiver pokes.
23:24
<@Reiver>
...
23:24
<@Reiver>
Y'know.
23:25
< McMartin>
I suggest reading input before trying to parse it.
23:26
< fhtagncaps>
I suggest checking input is non-null before trying to parse it.
23:26
<@Reiver>
http://vorn.dyndns.org/theonewiki/Chess
23:26
< McMartin>
caps: I would also suggest, for your z-abuse edification, the incomprehensible Robot Finds Kitten http://ifarchive.heanet.ie/if-archive/games/zcode/kitten.z5 and the unusually complex http://ifarchive.heanet.ie/if-archive/games/zcode/lists.z5
23:27
<@Reiver>
I'd love to know how to do those. >.>
23:27
<@Vornicus>
RObot Find Kitten in Inform!
23:27
< McMartin>
fhtagncaps: You can just catch NullPointerException or IndexOutOfBoundsException.
23:27
< McMartin>
Vorn: I actually found the Inform version first.
23:27
<@Vornicus>
heh
23:28
<@Vornicus>
The first one i saw was in FLash.
23:28
< McMartin>
The disturbing bit is that one of the Non-Kitten Items is a reference to my old neighbor in the dorms.
23:29
<@Vornicus>
oh?
23:29
< McMartin>
One of the Non-Kitten Items is the Floating ASCII Head of Seth D. Schoen.
23:29
<@Vornicus>
hee
23:31
< McMartin>
The "Final Thought" in Robotfindskitten is also wonderful.
23:31
<@Reiver>
I... um... turn out to not have any call to the text catcher at all. Um.
23:31
<@Reiver>
Hehehehe.
23:31
<@Vornicus>
haa-haa!
23:31
< McMartin>
That would be a Problem (tm).
23:32
<@Reiver>
In the code above (With a few corrections, as I sort of pasted it midtyping out the System.out.println("Please enter the move for X") bit), er... I want it in the parseInput, don't I?
23:32
< McMartin>
Probably
23:33
< McMartin>
http://robotfindskitten.org/aw.cgi?main=thought.rfk
23:33
< McMartin>
"There is no kitten!" cackles the old crone. You are shocked by her blasphemy.
23:35
<@Reiver>
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
23:35
<@Reiver>
at chs.Chessboard.getSquare(Chessboard.java:63)
23:35
<@Reiver>
at chs.Chessboard.movePeice(Chessboard.java:92)
23:35
<@Reiver>
at chs.Human.parseInput(Human.java:44)
23:35
<@Reiver>
at chs.Human.setMove(Human.java:12)
23:35
<@Reiver>
at chs.Chess.main(Chess.java:21)
23:35
<@Reiver>
It would appear it choked on my request to... er...
23:35 * Reiver tries to work out what broke.
23:37
< McMartin>
What's the line, first off
23:37
< McMartin>
Second off, it tried to access array element -1, probably on board.
23:37
< McMartin>
Which does not exist
23:38
<@Vornicus>
...strange.
23:39
< McMartin>
So some index is being miscomputed.
23:39
<@Vornicus>
...very strange.
23:39
<@Vornicus>
used to be that when I used sed to do templating with an svn commit message as input, it would go "blarg"
23:39
<@Vornicus>
now it does not.
23:40 * Reiver nods.
23:41
<@Reiver>
Ah!
23:41
<@Reiver>
Input: a7a6
23:41
<@Reiver>
Parseput: -2:54:-2:53
23:42
< fhtagncaps>
...
23:42 * Reiver goes to look at his code again to work out dur whuh?
23:42
<@Reiver>
That /should/ have parsed to 0,6,0,5
23:43
< McMartin>
You subtracted 1 from the number chars instead of '1'
23:43
< McMartin>
'1' being actually 49.
23:43
<@Vornicus>
'7'.ascii = 55
23:44
<@Reiver>
...Whoops?
23:44 * Reiver pauses. Eyes that.
23:44
<@Vornicus>
I don't know what's up with your numbers.
23:44
<@Vornicus>
letters.
23:44
<@Vornicus>
those things, you know, that are, uh, shiny.
23:44 * Reiver patpat Vorn?
23:44
< fhtagncaps>
coins?
23:44
< fhtagncaps>
Squirrels?
23:44
< McMartin>
Kittens.
23:44
<@Reiver>
I thought I'd converted things to integers before subtracting one...
23:45 * Reiver hrms.
23:45
<@Vornicus>
Kittens.
23:45
< fhtagncaps>
Ahh.
23:45
<@Vornicus>
So once robot finds kitten, what does robot do?
23:45
< McMartin>
win.
23:45
< fhtagncaps>
CONSUMES.
23:45
< fhtagncaps>
No, wait, McM had it.
23:45
<@Vornicus>
fhtagncaps: :(
23:45
<@Vornicus>
does it, uh
23:46
<@Vornicus>
rate the kitten?
23:46
< fhtagncaps>
It surely gives it a 10.
23:46
< McMartin>
The Final Thoughts seem to imply that Robot is just a grey box on wheels
23:46
< fhtagncaps>
...if you're going to suggest Robot Rates Kitten, Vorn...
23:47
<@Vornicus>
Does it scoop up kitten so robot's creator can rate kitten?
23:49
<@Reiver>
...Ok that wasn't what we needed then
23:49
<@Reiver>
heh
23:49
<@Reiver>
-50 >.<
23:49
<@Reiver>
So we don't want to subtract '1' from things.
23:50
< fhtagncaps>
Not '1', no.
23:50
< fhtagncaps>
1, possibly.
23:51
< McMartin>
Well, but he's reading characters
23:51
< McMartin>
So he's reading in '7' and subtracting 1, giving him fifty-some.
23:51
<@Reiver>
Not yet.
23:51
< fhtagncaps>
...surely there is an atoi() in Java?
23:51
<@Reiver>
locX = Character.getNumericValue(input.charAt(0)-'a');
23:51
<@Reiver>
I'm entering in a.
23:51
<@Reiver>
It's going 'a'-'a', right?
23:52
<@Reiver>
And giving me... -1?
23:52
<@Reiver>
(It was -50 when I had '1' by accident.)
23:52
< fhtagncaps>
...
23:52
< McMartin>
fhtagncaps: He wants ctoi(), which is not a C function because the compiler does it behind your back.
23:52
< fhtagncaps>
Ah, true.
23:52
< McMartin>
-1 means "not a number", I imagine.
23:52
< McMartin>
Or rather
23:53
< McMartin>
I may be wrong
23:53
<@Reiver>
...Aha.
23:53
< McMartin>
What, exactly, does getNumericValue do?
23:53
<@Reiver>
getNumericValue(char ch)
23:53
<@Reiver>
Returns the int value that the specified Unicode character represents.
23:53
< Syloqs-AFH>
gets a numeric value.
23:53
< fhtagncaps>
I assumed it was an internally provided function.
23:54
< McMartin>
... that's... unusually vague.
23:54
< Syloqs-AFH>
thats java!
23:54
< fhtagncaps>
...well, since you're using it on charAt()-'a'...
23:54
<@Reiver>
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html#getNumericValue (int)
23:54
<@Reiver>
If that helps?
23:54 * Reiver thought it was the right one...
23:54
< fhtagncaps>
shouldn't you be using it as getNumericValue(input.charAt(0)) - 65, or whatever?
23:55
< McMartin>
"The letters A-Z in their uppercase ('\u0041' through '\u005A'), lowercase ('\u0061' through '\u007A'), and full width variant ('\uFF21' through '\uFF3A' and '\uFF41' through '\uFF5A') forms have numeric values from 10 through 35. This is independent of the Unicode specification, which does not assign numeric values to these char values."
23:55
< fhtagncaps>
Because I'm not sure what Java does if you subtract characters from each other.
23:55
< McMartin>
So, getNumericValue(charAt(0)) - 10.
23:55
< fhtagncaps>
Quite.
23:55
< McMartin>
And getNumericValue(charAt(1)) - 1 for the numeric portions.
23:55 * Reiver tries that.
23:56
< McMartin>
Returns -1 if the character (such as \u0000) has no numeric value.
23:56
< McMartin>
It is important to actually read the full description of the function, particularly the "Returns" section and any discussion above it of what the various terms mean.
23:57
<@Reiver>
Input: a7a6
23:57
<@Reiver>
:
23:57
<@Reiver>
Illegal move!
23:57
<@Reiver>
Input: a7a6
23:57
<@Reiver>
Parseput: 32:6:32:5
23:57
< fhtagncaps>
...at least it's in the right range.
23:57
< McMartin>
Numbers work now, at least.
23:57
<@Reiver>
Yes indeed.
23:57
<@Reiver>
It would appear... oh.
23:57
<@Reiver>
Oh, wait.
23:58
<@Reiver>
A-Z is 1-26, lowercase are /after/
23:58
< fhtagncaps>
So, you need to subtract 42 from letters.
23:58
< fhtagncaps>
...yes.
23:58
<@Vornicus>
yeah, those are lowercase letters, not uppercase ones, so they're 32 away.
23:58
<@Reiver>
So yes, need to -42.
23:59
< McMartin>
... that's a bug in it or your documentation, then.
23:59
<@Reiver>
...In my documentation?
--- Log closed Wed Aug 23 00:00:01 2006
code logs -> 2006 -> Tue, 22 Aug 2006< code.20060821.log - code.20060823.log >