head	1.15;
access;
symbols
	tonic_4:1.15
	tonic_3:1.15
	tonic_2:1.15
	demo:1.12.0.2
	design_report:1.12
	oral_presentation_freeze:1.1.0.4
	DAVEG_CDP:1.1.0.2;
locks; strict;
comment	@ * @;


1.15
date	95.12.15.08.06.13;	author daveg;	state Exp;
branches;
next	1.14;

1.14
date	95.12.14.23.15.58;	author daveg;	state Exp;
branches;
next	1.13;

1.13
date	95.12.14.09.07.02;	author jered;	state Exp;
branches;
next	1.12;

1.12
date	95.12.11.20.45.10;	author jered;	state Exp;
branches;
next	1.11;

1.11
date	95.12.11.09.23.56;	author hartmans;	state Exp;
branches;
next	1.10;

1.10
date	95.12.07.17.16.00;	author daveg;	state Exp;
branches;
next	1.9;

1.9
date	95.12.06.14.12.41;	author daveg;	state Exp;
branches;
next	1.8;

1.8
date	95.12.03.19.56.08;	author hartmans;	state Exp;
branches;
next	1.7;

1.7
date	95.12.03.09.35.00;	author daveg;	state Exp;
branches;
next	1.6;

1.6
date	95.12.03.07.48.40;	author hartmans;	state Exp;
branches;
next	1.5;

1.5
date	95.12.03.01.17.14;	author hartmans;	state Exp;
branches;
next	1.4;

1.4
date	95.12.01.13.58.09;	author daveg;	state Exp;
branches;
next	1.3;

1.3
date	95.12.01.04.53.13;	author daveg;	state Exp;
branches;
next	1.2;

1.2
date	95.11.30.10.26.01;	author daveg;	state Exp;
branches;
next	1.1;

1.1
date	95.11.25.05.07.42;	author daveg;	state Exp;
branches;
next	;


desc
@@


1.15
log
@fixed pawn promotion
@
text
@#include <6170.h>
#include <chess_capture_move.h>
#include <chess_display_board.h>

typeinfo_t chess_capture_move::typeinfo = new_typeinfo();

chess_capture_move:: chess_capture_move (int from_x, int from_y, 
					 int to_x, int to_y,
					 chess_display_board::chess_piece piece,
					 chess_display_board::color piece_color,
					 bool promotion) {
    p.x1 = from_x;
    p.y1 = from_y;
    p.x2 = to_x;
    p.y2 = to_y;
    c  = piece_color;
    piecetaken = piece;
    promoted = promotion;
}

chess_capture_move::chess_capture_move (int x1i, int y1i, int x2i, int y2i,
					const chess_display_board *b)
{
    p.x1 = x1i;
    p.x2 = x2i;
    p.y1 = y1i;
    p.y2 = y2i;
    piecetaken = b->fetch(y2i,x2i).piece_type;
    c = b->fetch(y2i,x2i).piece_color;
    if ((((y2i==7) && (b->fetch(y1i,x1i).piece_color == 
		       chess_display_board::white))
	 || (y2i==0) && (b->fetch(y1i,x1i).piece_color == 
			 chess_display_board::black))
	&& (b->fetch(y1i, x1i).piece_type==chess_display_board::pawn))
	promoted = true;
    else
	promoted = false;
}


chess_capture_move::chess_capture_move (const chess_capture_move &m){
    p = m.get_path();
    piecetaken = m.get_piece_taken();
    c = m.get_color_taken();
    promoted = m.was_promotion();
}

void chess_capture_move::display(extensions *ext, ostream &body){
    body << (char)('a'+p.x1) << p.y1+1 << "-"<< (char)('a'+p.x2)<<p.y2+1 << 
      endl;
}

bool chess_capture_move::operator == (move &m) {
    chess_capture_move *mv = (chess_capture_move *) m.force(typeinfo);
    if (!mv)
	return false;
    
    chess_display_board::path temp = mv->get_path();
    return ((temp.x1==p.x1) && (temp.y1==p.y1) && (temp.x2==p.x2) && (temp.y2==p.y2)
	    && (mv->get_piece_taken() == piecetaken) &&
	    (mv->get_color_taken() == c) && (promoted == mv->promoted));
}

move* chess_capture_move::copy(){
    return new chess_capture_move(*this);
}

void *chess_capture_move::force(typeinfo_t &t)
{
    if (t == typeinfo) return this;
    else return 0;
 }


char piecetoc(chess_display_board::chess_piece p,
	      chess_display_board::color pc) {
    switch(p){
    case chess_display_board::none:
	return '-';
    case chess_display_board::invalid:
	return '-';
    case chess_display_board::pawn:
	if (pc == chess_display_board::black)
	    return 'p';
	else
	    return 'P';
    case chess_display_board::rook:
	if (pc == chess_display_board::black)
	    return 'r';
	else
	    return 'R';
    case chess_display_board::knight:
	if (pc == chess_display_board::black)
	    return 'n';
	else
	    return 'N';
    case chess_display_board::bishop:
	if (pc == chess_display_board::black)
	    return 'b';
	else
	    return 'B';
    case chess_display_board::queen:
	if (pc == chess_display_board::black)
	    return 'q';
	else
	    return 'Q';
    case chess_display_board::king:
	if (pc == chess_display_board::black)
	    return 'k';
	else
	    return 'K';
    }
    return '-'; // default to turn off warning
}
@


1.14
log
@fixed pawn promotion
@
text
@d31 1
a31 1
		       chess_display_board::black))
@


1.13
log
@top_node, chess_capture_move, etc fixes, machine_player speedups.
@
text
@d30 5
a34 2
    if (((y2i==7) || (y2i==0)) && 
	(b->fetch(y1i, x1i).piece_type==chess_display_board::pawn))
d45 1
a45 1
    promoted = m.promoted;
@


1.12
log
@Display changes.
@
text
@d22 1
a22 1
					chess_display_board *b)
d46 1
a46 1
    body << (char)('a'+p.x1) << p.y1+1 << "->"<< (char)('a'+p.x2)<<p.y2+1 << 
@


1.11
log
@bug fixes
@
text
@d46 2
a47 2
    body << "("<<p.x1 << ","<<p.y1<< ")->("<<p.x2<<","<<p.y2 << 
	") takes= " << piecetoc(piecetaken, c) << "\n";
@


1.10
log
@and even more bug fixes
@
text
@d61 1
a61 1
 chess_capture_move * chess_capture_move::copy(){
@


1.9
log
@bug fixes
@
text
@d46 2
a47 3
    body << "x1= "<<p.x1 << " y1= "<<p.y1<< " x2= "<<p.x2<<" p.y2 "<<p.y2 << 
	" piece taken= " << piecetoc(piecetaken,c) << " promoted= "<<
	promoted << "\n";
@


1.8
log
@Make antichess/Makefile

	This sort of compiles until you get to antichess_board.C.
@
text
@d12 4
a15 4
					     p.x1 = from_x;
					     p.y1 = from_y;
					     p.x2 = to_x;
					     p.y2 = to_y;
d30 2
a31 1
    if (((y2i==7) || (y2i==0)) && (b->fetch(y1i, x1i).piece_type==chess_display_board::pawn))
a44 1
// I need to get specs before I can do this
d46 3
d73 40
@


1.7
log
@added promotion stuff
@
text
@d9 2
a10 2
					 chess_piece piece,
					 color piece_color,
d12 4
a15 4
    x1 = from_x;
    y1 = from_y;
    x2 = to_x;
    y2 = to_y;
d24 7
a30 6
    x1 = x1i;
    x2 = x2i;
    y1 = y1i;
    y2 = y2i;
    piecetaken = b->fetch(y2,x2).piece_type;
    if (((y2==7) || (y2==0)) && (b->fetch(y1, x1).piece_type==pawn))
d41 1
a41 1
    promoted = m.was_promoted();
d49 1
a49 1
    chess_capture_move mv = m.force(typeinfo);
d53 4
a56 4
    path temp = mv.get_path();
    return ((temp.x1==x1) && (temp.y1==y1) && (temp.x2==x2) && (temp.y2==y2)
	    && (mv.get_piece_taken() == piecetaken) &&
	    (mv.get_color_taken() == c) && (promoted == mv.was_promoted()));
d59 2
a60 2
virtual chess_capture_move * copy(){
    return new chess_capture_move(x1, y1, x2, y2, piecetaken, c, promoted);
d63 2
a64 1
void *chess_capture_move::force(typinfo_t &t){
@


1.6
log
@Fixes to misunderstanding about chess_display_board
@
text
@d10 2
a11 1
					 color piece_color){
d18 1
d22 1
a22 1
					chess_displaye_board *b)
d29 4
d40 1
d55 1
a55 1
	    (mv.get_color_taken() == c));
d59 1
a59 1
    return new chess_capture_move(x1, y1, x2, y2, piecetaken, c);
@


1.5
log
@Add chess_display_board::get; add
new constructor to chess_capture_move for use by get.
@
text
@d26 1
a26 1
    piecetaken = b->fetch(x2,y2).piece_type;
@


1.4
log
@finished evaluate
@
text
@d1 1
d3 1
d5 1
a5 1
chess_capture_move::typeinfo = new_typeinfo();
d18 11
@


1.3
log
@general clean up
@
text
@d7 2
a8 1
					 chess_piece piece){
d13 1
d18 3
a20 2
    p = m.get_path;
    piecetaken = m.get_piece_taken;
d34 2
a35 1
	    && (mv.get_piece_taken() == piecetaken));
d39 1
a39 1
    return new chess_capture_move(x1, y1, x2, y2, piecetaken);
@


1.2
log
@updated headers
@
text
@d24 6
a29 2
bool chess_capture_move::operator == (chess_capture_move &m) {
    path temp = m.get_path();
d31 1
a31 1
	    && (m.get_piece_taken() == piecetaken));
@


1.1
log
@version 1.0 of chess_capture_move.C
@
text
@a7 5
    check(((from_x>=0) && (from_x<=7)),"chess_capture_move: x out of range");
    check(((from_y>=0) && (from_y<=7)),"chess_capture_move: y out of range");
    check(((to_x>=0) && (to_x<=7)),"chess_capture_move: x out of range");
    check(((to_y>=0) && (to_y<=7)),"chess_capture_move: y out of range");

@
