コード例 #1
0
void Java_com_ysaito_shogi_BonanzaJNI_computerMove(
    JNIEnv *env,
    jclass unused_bonanza_class,
    jint instance_id,
    jobject result) {
    int status = R_OK;
    pthread_mutex_lock(&g_lock);
    if (AnotherInstanceStarted(env, instance_id, result)) {
        pthread_mutex_unlock(&g_lock);
        return;
    }

    CHECK2_GE(com_turn_start(&tree, 0), 0, "error: %s", str_error);

    unsigned int move = last_pv_save.a[1];
    const char* move_str = NULL;
    if (move != 0) {
        move_str = str_CSA_move( move );
        LOG_DEBUG("Comp: %x %s", move, move_str);
    } else {
        // Computer likely have resigned
    }
    status = GameStatusToReturnCode();
    FillResult("Computer", env, status, NULL, move_str, move, &tree, result);
    pthread_mutex_unlock(&g_lock);
}
コード例 #2
0
ファイル: io.c プロジェクト: ilovemochida/hyperDiceShogi
static void manual_move( char **last, char *dice )
{
  const char *p = strtok_r( NULL, DELIM, last );
  unsigned int move;
  
  move = CSA2Internal( p );
  if( move == MOVE_NULL )
    {
      out(" Invalid Move\n");
      return;
    }

  if( is_mated() == 1 ) history_dice( 0 );
  else {
    if( dice == NULL || strcmp( dice, "1" ) < 0 || strcmp( dice, "6" ) > 0 )
      {
	out(" Invalid Number\n");
	return;
      }
    history_dice( atoi( dice ) );
  }

  char str_move[8];
  str_CSA_move( str_move, move );
  out("%s\n", str_move);
  MAKE_MOVE( move );
  out_position();

}
コード例 #3
0
ファイル: io.c プロジェクト: ilovemochida/hyperDiceShogi
int out_record( int resign )
{
  /* ret = 0; succeeded
          -1; failed    */
  FILE *fp;
  int i, dice;
  char str[8], filename[ SIZE_FILENAME];
  struct tm *date;
  time_t timer;
  time( &timer );
  date = localtime( &timer );
  
  sprintf( filename, "../records/%04d_%02d_%02d_%02d%02d%02d.msk",
           date->tm_year +1900, date->tm_mon +1, date->tm_mday,
           date->tm_hour      , date->tm_min,    date->tm_sec);
  
  fp = fopen( filename, "w" );

  if( fp == NULL )
    {
      out(" Error: Cannot create %s\n", filename);
      return -1;
    }

  out_file( fp, "\nV1_MSK\n\n" );
  out_file( fp, "\nPI\n+\n");
  
  
  for( i = 0; i < N_PLY; i++ )
    {
      str_CSA_move( str, history[ i ].move );
      dice = history[ i ].dice;
      if( i % 2 )
        { out_file( fp, "-" ); }
      else
        { out_file( fp, "+" ); }
      out_file( fp, "%s:", str );
      out_file( fp, "%d\n", dice );
    }

  if( resign )
    out_file( fp, "%%TORYO\n" );
  
  fclose( fp );

  out( " %s has been output.\n", filename );
  return 0;
}
コード例 #4
0
ファイル: io.c プロジェクト: ilovemochida/hyperDiceShogi
void out_legalmoves( unsigned int moves[], int count )
{
  int i;
  char buf[8];

  out(" Legal Moves( %d ) =\n ", count);
  
  for( i=0; i < count; i++)
    {
      str_CSA_move( buf, moves[ i ] );
      out(" %s",buf);
      if( i%10 == 9 )
        out("\n ");
    }
  out("\n");
  return;
}