static void write_piece_exchange(output_plaintext_move_context_type *context, move_effect_journal_index_type curr) { switch (move_effect_journal[curr].reason) { case move_effect_reason_exchange_castling_exchange: case move_effect_reason_messigny_exchange: /* already dealt with */ assert(0); break; case move_effect_reason_oscillating_kings: next_context(context,curr,"[","]"); WriteWalk(context->engine,context->file,get_walk_of_piece_on_square(move_effect_journal[curr].u.piece_exchange.from)); WriteSquare(context->engine,context->file,move_effect_journal[curr].u.piece_exchange.to); (*context->engine->fprintf)(context->file,"%s",(*context->symbol_table)[output_symbol_left_right_arrow]); WriteWalk(context->engine,context->file,get_walk_of_piece_on_square(move_effect_journal[curr].u.piece_exchange.to)); WriteSquare(context->engine,context->file,move_effect_journal[curr].u.piece_exchange.from); break; default: write_exchange(context,curr); break; } }
static void write_exchange(output_plaintext_move_context_type *context, move_effect_journal_index_type movement) { WriteWalk(context->engine,context->file,get_walk_of_piece_on_square(move_effect_journal[movement].u.piece_exchange.from)); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_exchange.to); (*context->engine->fprintf)(context->file,"%s",(*context->symbol_table)[output_symbol_left_right_arrow]); WriteWalk(context->engine,context->file,get_walk_of_piece_on_square(move_effect_journal[movement].u.piece_exchange.to)); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_exchange.from); }
static void write_history_recursive(ply ply) { if (parent_ply[ply]>ply_retro_move) write_history_recursive(parent_ply[ply]); fprintf(stdout," %u:",ply); WriteSquare(&output_plaintext_engine,stdout,move_generation_stack[CURRMOVE_OF_PLY(ply)].departure); fputs("-",stdout); WriteSquare(&output_plaintext_engine,stdout,move_generation_stack[CURRMOVE_OF_PLY(ply)].arrival); }
static void WriteMagicViews(int ply) { int i; for (i= magictop[ply-1]; i < magictop[ply]; i++) { WriteSquare(stdout,magicviews[i].pos_viewed); fputc(' ',stdout); WriteSquare(stdout,magicviews[i].viewedid); fputc(' ',stdout); WriteSquare(stdout,magicviews[i].magicpieceid); fputc(' ',stdout); fprintf(stdout, "%i", magicviews[i].line_identifier); fputc('\n',stdout); } }
static void HandleAddedPiece(square s, void *param) { piece_addition_settings * const settings = param; if (!is_square_empty(s)) { if (settings->type==piece_addition_initial) { WriteSquare(&output_plaintext_engine,stdout,s); output_plaintext_message(OverwritePiece); underworld_make_space(nr_ghosts); underworld[nr_ghosts-1].walk = get_walk_of_piece_on_square(s); underworld[nr_ghosts-1].flags = being_solved.spec[s]; underworld[nr_ghosts-1].on = s; } else { move_effect_journal_do_circe_volcanic_remember(move_effect_reason_diagram_setup, s); move_effect_journal_do_piece_removal(move_effect_reason_diagram_setup, s); } } if (settings->type==piece_addition_twinning) move_effect_journal_do_piece_creation(move_effect_reason_diagram_setup, s,settings->walk, settings->spec, no_side); else occupy_square(s,settings->walk,settings->spec); }
static void write_flags_change(output_plaintext_move_context_type *context, move_effect_journal_index_type curr) { switch (move_effect_journal[curr].reason) { case move_effect_reason_pawn_promotion: (*context->engine->fputc)('=',context->file); WriteSpec(context->engine,context->file, move_effect_journal[curr].u.flags_change.to, find_piece_walk(context,curr,move_effect_journal[curr].u.flags_change.on), false); break; case move_effect_reason_kobul_king: if (move_effect_journal[curr-1].type!=move_effect_piece_change || move_effect_journal[curr-1].reason!=move_effect_reason_kobul_king) /* otherwise the flags are written with the changed piece */ { next_context(context,curr,"[","]"); WriteSquare(context->engine,context->file,move_effect_journal[curr].u.flags_change.on); (*context->engine->fputc)('=',context->file); WriteSpec(context->engine,context->file, move_effect_journal[curr].u.flags_change.to, being_solved.board[move_effect_journal[curr].u.flags_change.on], false); } break; default: break; } }
static void write_transfer(output_plaintext_move_context_type *context, move_effect_journal_index_type removal, move_effect_journal_index_type addition) { next_context(context,removal,"[","]"); write_complete_piece(context, move_effect_journal[removal].u.piece_removal.flags, move_effect_journal[removal].u.piece_removal.walk, move_effect_journal[removal].u.piece_removal.on); (*context->engine->fprintf)(context->file,"%s",(*context->symbol_table)[output_symbol_right_arrow]); if (move_effect_journal[removal].u.piece_removal.flags !=move_effect_journal[addition].u.piece_addition.added.flags || (TSTFLAG(move_effect_journal[addition].u.piece_addition.added.flags,Royal) && is_king(move_effect_journal[removal].u.piece_removal.walk) && !is_king(move_effect_journal[addition].u.piece_addition.added.walk))) { WriteSpec(context->engine,context->file, move_effect_journal[addition].u.piece_addition.added.flags, move_effect_journal[addition].u.piece_addition.added.walk, false); WriteWalk(context->engine,context->file,move_effect_journal[addition].u.piece_addition.added.walk); } else if (move_effect_journal[removal].u.piece_removal.walk !=move_effect_journal[addition].u.piece_addition.added.walk) WriteWalk(context->engine,context->file,move_effect_journal[addition].u.piece_addition.added.walk); WriteSquare(context->engine,context->file,move_effect_journal[addition].u.piece_addition.added.on); }
static void write_singlebox_promotion(output_plaintext_move_context_type *context, move_effect_journal_index_type curr) { WriteSquare(context->engine,context->file,move_effect_journal[curr].u.piece_change.on); (*context->engine->fputc)('=',context->file); WriteWalk(context->engine,context->file,move_effect_journal[curr].u.piece_change.to); }
static void write_side_change(output_plaintext_move_context_type *context, move_effect_journal_index_type curr) { switch (move_effect_journal[curr].reason) { case move_effect_reason_andernach_chess: case move_effect_reason_volage_side_change: case move_effect_reason_magic_square: case move_effect_reason_circe_turncoats: (*context->engine->fputc)('=',context->file); (*context->engine->fputc)(tolower(ColourTab[move_effect_journal[curr].u.side_change.to][0]),context->file); break; case move_effect_reason_magic_piece: case move_effect_reason_masand: case move_effect_reason_hurdle_colour_changing: next_context(context,curr,"[","]"); WriteSquare(context->engine,context->file,move_effect_journal[curr].u.side_change.on); (*context->engine->fputc)('=',context->file); (*context->engine->fputc)(tolower(ColourTab[move_effect_journal[curr].u.side_change.to][0]),context->file); break; default: break; } }
static void write_no_capture(output_plaintext_move_context_type *context, move_effect_journal_index_type movement) { write_departure(context,movement); (*context->engine->fputc)('-',context->file); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.to); }
static void write_castling(output_plaintext_move_context_type *context, move_effect_journal_index_type movement) { if (CondFlag[castlingchess]) { WriteWalk(context->engine,context->file,move_effect_journal[movement].u.piece_movement.moving); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.from); (*context->engine->fputc)('-',context->file); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.to); } else { square const to = move_effect_journal[movement].u.piece_movement.to; output_symbol_type const symbol = to==square_g1 || to==square_g8 ? output_symbol_king_side_castling : output_symbol_queen_side_castling; (*context->engine->fprintf)(context->file,"%s",(*context->symbol_table)[symbol]); } }
static void write_complete_piece(output_plaintext_move_context_type *context, Flags spec, piece_walk_type piece, square on) { WriteSpec(context->engine,context->file,spec,piece,true); WriteWalk(context->engine,context->file,piece); WriteSquare(context->engine,context->file,on); }
static int WriteGoal(FILE *file, Goal goal) { int result = 0; result += fprintf(file,"%s",get_goal_symbol(goal.type)); if (goal.type==goal_target || goal.type==goal_kiss) result += WriteSquare(file,goal.target); return result; }
static void write_departing_piece(output_plaintext_move_context_type *context, move_effect_journal_index_type movement) { if (WriteSpec(context->engine,context->file, move_effect_journal[movement].u.piece_movement.movingspec, move_effect_journal[movement].u.piece_movement.moving, false) || move_effect_journal[movement].u.piece_movement.moving!=Pawn) WriteWalk(context->engine,context->file,move_effect_journal[movement].u.piece_movement.moving); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.from); }
static void write_capture(output_plaintext_move_context_type *context, move_effect_journal_index_type capture, move_effect_journal_index_type movement) { square const sq_capture = move_effect_journal[capture].u.piece_removal.on; write_departure(context,movement); (*context->engine->fputc)('*',context->file); if (sq_capture==move_effect_journal[movement].u.piece_movement.to) WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.to); else if (move_effect_journal[capture].reason==move_effect_reason_ep_capture) { WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.to); (*context->engine->fprintf)(context->file,"%s"," ep."); } else { WriteSquare(context->engine,context->file,sq_capture); (*context->engine->fputc)('-',context->file); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.to); } }
static void write_departure(output_plaintext_move_context_type *context, move_effect_journal_index_type movement) { move_effect_journal_index_type const phantom_movement = find_pre_move_effect(move_effect_piece_movement, move_effect_reason_phantom_movement); if (phantom_movement==move_effect_journal_index_null) write_departing_piece(context,movement); else { write_departing_piece(context,phantom_movement); (*context->engine->fputc)('-',context->file); WriteSquare(context->engine,context->file,move_effect_journal[movement].u.piece_movement.from); } }
static void write_imitator_movement(output_plaintext_move_context_type *context, move_effect_journal_index_type curr) { unsigned int const nr_moved = move_effect_journal[curr].u.imitator_movement.nr_moved; unsigned int icount; (*context->engine->fprintf)(context->file,"[I"); for (icount = 0; icount<nr_moved; ++icount) { WriteSquare(context->engine,context->file,being_solved.isquare[icount]); if (icount+1<nr_moved) (*context->engine->fputc)(',',context->file); } (*context->engine->fputc)(']',context->file); }
static void write_piece_movement(output_plaintext_move_context_type *context, move_effect_journal_index_type curr) { switch (move_effect_journal[curr].reason) { case move_effect_reason_moving_piece_movement: /* write_capture() and write_no_capture() have dealt with this */ assert(0); break; case move_effect_reason_castling_king_movement: /* write_castling() has dealt with this */ assert(0); break; case move_effect_reason_castling_partner_movement: if (CondFlag[castlingchess]) { (*context->engine->fputc)('/',context->file); write_complete_piece(context, move_effect_journal[curr].u.piece_movement.movingspec, move_effect_journal[curr].u.piece_movement.moving, move_effect_journal[curr].u.piece_movement.from); (*context->engine->fputc)('-',context->file); WriteSquare(context->engine,context->file,move_effect_journal[curr].u.piece_movement.to); } else { /* implicitly written in castling symbols */ } break; default: break; } }
static void write_piece_change(output_plaintext_move_context_type *context, move_effect_journal_index_type curr) { switch (move_effect_journal[curr].reason) { case move_effect_reason_pawn_promotion: case move_effect_reason_protean_adjustment: case move_effect_reason_chameleon_movement: case move_effect_reason_degradierung: case move_effect_reason_norsk_chess: case move_effect_reason_promotion_of_reborn: if (/* regular promotion doesn't test whether the "promotion" is * into pawn (e.g. in SingleBox); it's more efficient to test here */ move_effect_journal[curr].u.piece_change.to !=move_effect_journal[curr].u.piece_change.from) { square const on = move_effect_journal[curr].u.piece_change.on; Flags const flags = find_piece_flags(context,curr,on); (*context->engine->fputc)('=',context->file); WriteSpec(context->engine,context->file,flags,move_effect_journal[curr].u.piece_change.to,false); WriteWalk(context->engine,context->file,move_effect_journal[curr].u.piece_change.to); } break; case move_effect_reason_singlebox_promotion: /* type 3 is already dealt with, so this is type 2 */ next_context(context,curr,"[","]"); write_singlebox_promotion(context,curr); break; case move_effect_reason_kobul_king: next_context(context,curr,"[","]"); WriteSquare(context->engine,context->file,move_effect_journal[curr].u.piece_change.on); (*context->engine->fputc)('=',context->file); { Flags flags; if (move_effect_journal[curr+1].type==move_effect_flags_change && move_effect_journal[curr+1].reason==move_effect_reason_kobul_king) flags = move_effect_journal[curr+1].u.flags_change.to; else flags = BIT(Royal); WriteSpec(context->engine,context->file,flags,move_effect_journal[curr].u.piece_change.to,false); } WriteWalk(context->engine,context->file,move_effect_journal[curr].u.piece_change.to); break; case move_effect_reason_snek: { square const on = move_effect_journal[curr].u.piece_change.on; piece_walk_type const to = move_effect_journal[curr].u.piece_change.to; next_context(context,curr,"[","]"); WriteSquare(context->engine,context->file,on); (*context->engine->fputc)('=',context->file); WriteSpec(context->engine,context->file,being_solved.spec[on],to,false); WriteWalk(context->engine,context->file,to); break; } case move_effect_reason_einstein_chess: case move_effect_reason_football_chess_substitution: case move_effect_reason_king_transmutation: (*context->engine->fputc)('=',context->file); WriteWalk(context->engine,context->file,move_effect_journal[curr].u.piece_change.to); break; default: break; } }