int Pawn_Move_Fail(int xdiff, int ydiff, int capturing){
	//pawn
	//check that move is no more than 1 space in correct direction (cept first turn)  
	// remember En Passant
	//has 4 posible moves from any position

	//check verticle movement, must move up/down
	if(ydiff == 0)
		return 1;
	//check not moving backwards
	if(my_team_color){ //black top
		if(move.destination.y > move.source.y)
			return 1;
	}else{ //white bottom
		if(move.destination.y < move.source.y)
			return 1;
	}

	//check that x movement is no greater than 1
	if(xdiff > 1)
		return 1;
	//check that y is no greater than 1 unless first turn ... 
	if(ydiff > 1){
		if(ydiff != 2 || my_pieces[my_pcount].first_turn != 1)
			return 1;
		//check that not moving thru an occupied space (can only happen on first turn)
		for(pcount=0; pcount<16; pcount++){
			if(oponent_pieces[pcount].alive && oponent_pieces[pcount].position.x == move.destination.x){
				if(my_team_color){ //if black
					if(oponent_pieces[pcount].position.y == move.destination.y+1)
						return 1;
				}else{ //white
					if(oponent_pieces[pcount].position.y == move.destination.y-1)
						return 1;
				}
			}
			if(pcount == my_pcount)
				continue;
			if(my_pieces[pcount].alive && my_pieces[pcount].position.x == move.destination.x){
				if(my_team_color){ //if black
					if(my_pieces[pcount].position.y == move.destination.y+1)
						return 1;
				}else{ //white
					if(my_pieces[pcount].position.y == move.destination.y-1)
						return 1;
				}
			}
		}
	}

	//check that enemy is not on space if moving forward
	if(capturing){
		if(xdiff == 0)
			return 1;
	}
	//check that enemy is on space if moving diag
	if(xdiff == ydiff){
		if(!capturing)
			return 1;
	}
	return 0;
}

int Rook_Move_FAIL(int xdiff, int ydiff, int capturing) )
	//rook
	//implement castling later
	//check not moving diagonal
	if(xdiff > 0 && ydiff > 0)
		return 1;
	//check not moving thru a piece
	if(xdiff > 0 && ydiff == 0){
		//moving sideways
		for(pcount=0; pcount<16; pcount++){
			if(oponent_pieces[pcount].alive){
				if(oponent_pieces[pcount].position.y == move.destination.y){
					if(oponent_pieces[pcount].position.x < move.destination.x && oponent_pieces[pcount].position.x > move.source.x)
						return 1;
					if(oponent_pieces[pcount].position.x > move.destination.x && oponent_pieces[pcount].position.x < move.source.x)
						return 1;
				}
			}
			if(my_pieces[pcount].alive){
				if(my_pieces[pcount].position.y == move.destination.y){
					if(my_pieces[pcount].position.x < move.destination.x && my_pieces[pcount].position.x > move.source.x)
						return 1;
					if(my_pieces[pcount].position.x > move.destination.x && my_pieces[pcount].position.x < move.source.x)
						return 1;
				}
			}
		}
	}
	if(ydiff > 0 && xdiff == 0){
		//moving up/down
		for(pcount=0; pcount<16; pcount++){
			if(oponent_pieces[pcount].alive){
				if(oponent_pieces[pcount].position.x == move.destination.x){
					if(oponent_pieces[pcount].position.y < move.destination.y && oponent_pieces[pcount].position.y > move.source.y)
						return 1;
					if(oponent_pieces[pcount].position.y > move.destination.y && oponent_pieces[pcount].position.y < move.source.y)
						return 1;
				}
			}
			if(my_pieces[pcount].alive){
				if(oponent_pieces[pcount].position.x == move.destination.x){
					if(my_pieces[pcount].position.y < move.destination.y && my_pieces[pcount].position.y > move.source.y)
						return 1;
					if(my_pieces[pcount].position.y > move.destination.y && my_pieces[pcount].position.y < move.source.y)
						return 1;
				}
			}
		}
	}
	return 0;
}

int Bishop_Move_FAIL(xdiff, ydiff, capturing) )
	//bishop
	//check that move is diagonal
	if(xdiff != ydiff)
		return;
	//check that not moving thru a piece
	for(pcount=0; pcount<16; pcount++){
		if(capturing){
			if(pcount == piece_to_capture){
				continue;
			}
		}
		if(!oponent_pieces[pcount].alive)
			continue;
		//(x2-x1)*(y3-y1) = (x3-x1)*(y2-y1)
		if( (move.destination.x-move.source.x)*(oponent_pieces[pcount].position.y-move.source.y) == 
		    (oponent_pieces[pcount].position.x-move.source.x)*(move.destination.y-move.source.y) ){
			if(oponent_pieces[pcount].position.x > move.source.x && oponent_pieces[pcount].position.x < move.destination.x){
				return;
			}
			if(oponent_pieces[pcount].position.x < move.source.x && oponent_pieces[pcount].position.x > move.destination.x){
				return;
			}
		}
	}
	for(pcount=0; pcount<16; pcount++){
		if(!my_pieces[pcount].alive)
			continue;
		if(pcount == my_pcount)
			continue;
		//if( move.destination.x == my_pieces[pcount].position.x && move.destination.y == my_pieces[pcount].position.y){
		//	return;
		//}
		//y = mx + b
		if( (move.destination.x-move.source.x)*(my_pieces[pcount].position.y-move.source.y) ==
		    (my_pieces[pcount].position.x-move.source.x)*(move.destination.y-move.source.y) ){

			//if(my_pieces[pcount].position.y == my_pieces[pcount].position.x + move.destination.y - move.destination.x){
			if(my_pieces[pcount].position.x > move.source.x && my_pieces[pcount].position.x < move.destination.x){
				return;
			}
			if(my_pieces[pcount].position.x < move.source.x && my_pieces[pcount].position.x > move.destination.x){
				return;
			}
		}
	}
	return 0;
}

int Queen_Move_FAIL(xdiff, ydiff, capturing) ){
	//queen
	//check that move is either: diagonal, up/down, or right/left
	if(xdiff != ydiff){ //if not diagonal
		if(xdiff != 0){ //if x moved then y can't
			if(ydiff != 0)
				return;
			//moving sideways
			for(pcount=0; pcount<16; pcount++){
				if(oponent_pieces[pcount].alive){
					if(oponent_pieces[pcount].position.y == move.destination.y){
						if(oponent_pieces[pcount].position.x < move.destination.x && oponent_pieces[pcount].position.x > move.source.x)
							return;
						if(oponent_pieces[pcount].position.x > move.destination.x && oponent_pieces[pcount].position.x < move.source.x)
							return;
					}
				}
				if(my_pieces[pcount].alive){
					if(my_pieces[pcount].position.y == move.destination.y){
						if(my_pieces[pcount].position.x < move.destination.x && my_pieces[pcount].position.x > move.source.x)
							return;
						if(my_pieces[pcount].position.x > move.destination.x && my_pieces[pcount].position.x < move.source.x)
							return;
					}
				}
			}
		}
		if(ydiff != 0){ //if y moved then x can't
			if(xdiff != 0)
				return;
			//moving up/down
			for(pcount=0; pcount<16; pcount++){
				if(oponent_pieces[pcount].alive){
					if(oponent_pieces[pcount].position.x == move.destination.x){
						if(oponent_pieces[pcount].position.y < move.destination.y && oponent_pieces[pcount].position.y > move.source.y)
							return;
						if(oponent_pieces[pcount].position.y > move.destination.y && oponent_pieces[pcount].position.y < move.source.y)
							return;
					}
				}
				if(my_pieces[pcount].alive){
					if(oponent_pieces[pcount].position.x == move.destination.x){
						if(my_pieces[pcount].position.y < move.destination.y && my_pieces[pcount].position.y > move.source.y)
							return;
						if(my_pieces[pcount].position.y > move.destination.y && my_pieces[pcount].position.y < move.source.y)
							return;
					}
				}
			}
		}
	}

	//check that not moving thru a piece
	for(pcount=0; pcount<16; pcount++){
		if(oponent_pieces[pcount].alive){
			//slope of 1
			if( move.source.y-oponent_pieces[pcount].position.y / move.source.x-oponent_pieces[pcount].position.x ){
                                               //check if between source/dest x values
                                               if(oponent_pieces[pcount].position.x > move.source.x && oponent_pieces[pcount].position.x < move.destination.x){
                                                       //check if shares the same y intercept
                                                       if(move.source.y-move.source.x == oponent_pieces[pcount].position.y-oponent_pieces[pcount].position.x){
                                                               //don't count piece we are capturing
                                                                if(pcount != piece_to_capture)
                                                                        return;
                                                        }
                                                }
                                               if(oponent_pieces[pcount].position.x < move.source.x && oponent_pieces[pcount].position.x > move.destination.x){
                                                        if(move.source.y-move.source.x == oponent_pieces[pcount].position.y-oponent_pieces[pcount].position.x){
                                                                if(pcount != piece_to_capture)
                                                                        return;
                                                        }
                                                }
                                        }
                                }
                                if(my_pieces[pcount].alive){
                                        if( move.source.y-my_pieces[pcount].position.y / move.source.x-my_pieces[pcount].position.x ){
                                                if(my_pieces[pcount].position.x > move.source.x && my_pieces[pcount].position.x < move.destination.x){
                                                        if(move.source.y-move.source.x == my_pieces[pcount].position.y-my_pieces[pcount].position.x){
                                                                //don't count self
                                                                if(pcount != my_pcount)
                                                                        return;
                                                        }
                                                }
                                                if(my_pieces[pcount].position.x < move.source.x && my_pieces[pcount].position.x > move.destination.x){
                                                        if(move.source.y-move.source.x == my_pieces[pcount].position.y-my_pieces[pcount].position.x){
                                                                if(pcount != my_pcount)
                                                                        return;
                                                        }
                                                }
                                        }
                                }
                        }		
	return 0;
}

/*
void Adjust_Bounds(void){
	int xc, yc;
	float lx, ty, rx, by;
	float eighth_x, eighth_y;

	lx = win_x-board_x-(win_x-board_x)/2;
	ty = win_y-board_y-(win_y-board_y)/2;
	by = ty + board_y;
	rx = lx + board_x;

	eighth_x = board_x/8;
	eighth_y = board_y/8;

	for(xc=0; xc<8; xc++){
		for(yc=0; yc<8; yc++){
			//.x1 .y1 = left bottom  x2 y2 = right top
			bounds[xc][yc].x1 = lx + xc*eighth_x;
			bounds[xc][yc].y1 = by - yc*eighth_y;
			bounds[xc][yc].x2 = lx + eighth_x + xc*eighth_x;
			bounds[xc][yc].y2 = by - eighth_y - yc*eighth_y;
		}
	}
}
*/