//*********************************************
//     BLOOD GROUP for HR2 THE SIMULATOR
//
//  NAME     :  FULL COLOR ERG USER type A
//  PURPOSE  :  get ERG->build ORDER
//  CHARACTER:  Majime
//
//  WRITER   :  ARTDINK 1994/12/01
//*********************************************

main()
{
	int	echk ;
	int	ans ;
	int	o ;

	echk = buggage() ;
	if( echk == FAIL ){
		ans = lets_go( ERG ) ;
		if( ans == SUCCESS ){
			ans = get() ;
		}
	}
	else{
		o = -1 ;
		if( echk == YELLOW )		o=STAIR ;
		else if( echk == BLUE )		o=FLOOR ;
		else if( echk == L_GRAY )	o=WINDOW ;
		else if( echk == D_GRAY )	o=PILAR ;
		else if( echk == WHITE )	o=WALL ;
		if( o != -1 ){
			ans = lets_go( o ) ;
			if( ans == FAIL && o == WINDOW ){
				ans = lets_go( GATE ) ;
			}
			if( ans == SUCCESS ){
				ans = put() ;
			}
		}
	}
	if( ans == FAIL ){
		if( echk == FAIL ){
			error_act( LEFT,LEFT ) ;
		}
		else{
			error_act( RIGHT,RIGHT ) ;
		}
	}
	return( ans ) ;
}

lets_go( int target )
{
	int	ans ;
	int	p ;
	int	h ;

	ans = find( target ) ;
	if( ans != FAIL ){
		p = place() ;
		h = high() ;
		do{
			ans = go( p,h ) ;
		}while( ans == CONT ) ;
	}
	return( ans ) ;
}

error_act( int dir1,int dir2 )
{
	int	i ;
	int	chk ;
	int	dir ;
	for( i=0 ; i<4 ; i++ ){
		chk = i%2 ;
		dir = dir1 ;
		if( chk != 0 )	dir = dir2 ;
		round( dir ) ;
	}
}


