 xyToan = (x,y) ->
 	return (String.fromCharCode (x+96)) + y
 
+pieceFromChar = (c) ->
+	switch c
+		when "p" then new Pawn   false
+		when "r" then new Rook   false
+		when "n" then new Knight false
+		when "b" then new Bishop false
+		when "q" then new Queen  false
+		when "k" then new King   false
+		when "P" then new Pawn   true
+		when "R" then new Rook   true
+		when "N" then new Knight true
+		when "B" then new Bishop true
+		when "Q" then new Queen  true
+		when "K" then new King   true
+		else new BlankPiece
+
 
 
 # Board is from white's perspective.
 class Board
 	# fill in with peices
 	board =
-	for x in [0..7]
-		for y in [0..7]
+	for y in [0..7]
+		for x in [0..7]
 			# if x+y % 2 == 0 then it's a white square
 			new BlankPiece (x + y) % 2 == 0
 
 	# these work with either algebraic notation or x,y coordinates
 	set: (pos..., to) ->
+		# if we need to convert a char into a piece for placement
+		unless to instanceof Piece
+			to = pieceFromChar(to)
+
 		# convert if we are in algebraic notation
 		if pos.length == 1
 			pos = anToxy pos[0]
 
 		x = pos[0]
 		y = pos[1]
-
 		board[x][y] = to
 
 	get: (pos...) ->

		for piece in vis
			console.log piece.join(' ')





# some tests


		return board[x][y]

	# fills an 8x8 board array
	visual: ->
		for y in [0..7]
			for x in [0..7]
				@get(x,y).symbol

	# draw the board to the console
