Beispiel #1
0
/* TODO: be more tolerant regarding unmatched character in the needle.
 * Right now, we implicitly accept unmatched characters at the end of the
 * needle but absolutely not at the start.  e.g. "xpy" won't match "python" at
 * all, though "pyx" will. */
static inline gint
get_score (const gchar *needle,
           const gchar *haystack)
{
  if (! needle || ! haystack) {
    return needle == NULL;
  } else if (! *needle || ! *haystack) {
    return *needle == 0;
  }
  
  if (IS_SEPARATOR (*haystack)) {
    return get_score (needle + IS_SEPARATOR (*needle), haystack + 1);
  }

  if (IS_SEPARATOR (*needle)) {
    return get_score (needle + 1, next_separator (haystack));
  }

  if (*needle == *haystack) {
    gint a = get_score (needle + 1, haystack + 1) + 1 + IS_SEPARATOR (haystack[1]);
    gint b = get_score (needle, next_separator (haystack));
    
    return MAX (a, b);
  } else {
    return get_score (needle, next_separator (haystack));
  }
}
Beispiel #2
0
static void set_load_hs_v1(fs_file fp, struct set *s, char *buf, int size)
{
    struct level *l;
    int i, n;

    /* First line holds level states. */

    n = MIN(strlen(buf), s->count);

    for (i = 0; i < n; i++)
    {
        l = &level_v[i];

        l->is_locked    = (buf[i] == 'L');
        l->is_completed = (buf[i] == 'C');
    }

    get_score(fp, &s->time_score);
    get_score(fp, &s->coin_score);

    for (i = 0; i < n; i++)
    {
        l = &level_v[i];

        get_score(fp, &l->scores[SCORE_TIME]);
        get_score(fp, &l->scores[SCORE_GOAL]);
        get_score(fp, &l->scores[SCORE_COIN]);
    }
}
Beispiel #3
0
void show_scorematrix(scorematrix* sm)
{
  int i,j,print;
  for (i = 'A'-1; i <= '['; i++)
  {
    print = 0;
    for (j = 'A'-1; j <= '['; j++)
    {
      if (i == 'A'-1 && j == 'A'-1)
      {
        printf("  ");
      }
      else if (i == 'A'-1 && get_score(sm,j,'A') < INF)
      {
        printf(" %c ", j);
        print = 1;
      }
      else if (j == 'A'-1 && get_score(sm,i,'A') < INF)
      {
        printf("%c ", i);
        print = 1;
      }
      else if (i >= 'A' && j >= 'A' && get_score(sm,i,j) < INF)
        printf("%2d ", get_score(sm,i,j));
      else
        ;//printf("   ");
    }
    if (print)
      printf("\n");
  }

}
Beispiel #4
0
/*get max match score */
int match_score(int i, int j, int f, int x)
{
	int case1, case2, case3;
	int result, come;
	int k;
	if(f == 0){/* compare to make genelogical tree */
		case1 = dp[i-1][j-1] + get_score(pro[0].seq[i], pro[x].seq[j]);
		case2 =	dp[i-1][j] + GAP;
		case3 =	dp[i][j-1] + GAP;
	}
	else{/* compare to make result and make average score of cluster*/
		for(k = 0; k < x; k++){
			case1 = dp[i-1][j-1] + get_score(pro[k].seq[i], pro[x].seq[j]);
			case2 =	dp[i-1][j] + GAP;
			case3 =	dp[i][j-1] + GAP;
		}
		case1 /= k;
		case2 /= k;
		case3 /= k;
	}
	result = case1;
	come = 1;
	if(case2 > result){
		result = case2;
		come = 2;
	}
	else if(case3 > result){
		result = case3;
		come = 3;
	}
	trace[i][j] = come;
	/*come form*/
	return result;
}
Beispiel #5
0
/*get max match score */
int match_score(int i, int j, int x, int y, int f)
{
	int case1, case2, case3;
	int result, come;
	int k;
	if(f == 0){/* compare to make genelogical tree */
		case1 = dp[i-1][j-1] + get_score(pro[x].seq[i], pro[y].seq[j]);
		case2 =	dp[i-1][j] + GAP;
		case3 =	dp[i][j-1] + GAP;
	}
	else{
		for(k = 0; cluster[k].name[0] != '\0'; k++){
				case1 = dp[i-1][j-1] + get_score(cluster[k].seq[i], pro[x].seq[j]);
				case2 =	dp[i-1][j] + GAP;
				case3 =	dp[i][j-1] + GAP;
		}
	}
	result = case1;
	come = 1;
	if(case2 > result){
		result = case2;
		come = 2;
	}
	else if(case3 > result){
		result = case3;
		come = 3;
	}
	trace[i][j] = come;
	/*come form*/
	return result;
}
Beispiel #6
0
static void set_load_hs_v2(fs_file fp, struct set *s, char *buf, int size)
{
    struct score time_score;
    struct score coin_score;

    int set_score = 0;
    int set_match = 1;

    while (fs_gets(buf, size, fp))
    {
        int version = 0;
        int flags = 0;
        int n = 0;

        strip_newline(buf);

        if (strncmp(buf, "set ", 4) == 0)
        {
            get_score(fp, &time_score);
            get_score(fp, &coin_score);

            set_score = 1;
        }
        else if (sscanf(buf, "level %d %d %n", &flags, &version, &n) >= 2)
        {
            struct level *l;

            if ((l = find_level(s, buf + n)))
            {
                /* Always prefer "locked" flag from the score file. */

                l->is_locked = !!(flags & LEVEL_LOCKED);

                /* Only use "completed" flag and scores on version match. */

                if (version == l->version_num)
                {
                    l->is_completed = !!(flags & LEVEL_COMPLETED);

                    get_score(fp, &l->scores[SCORE_TIME]);
                    get_score(fp, &l->scores[SCORE_GOAL]);
                    get_score(fp, &l->scores[SCORE_COIN]);
                }
                else set_match = 0;
            }
            else set_match = 0;
        }
    }

    if (set_match && set_score)
    {
        s->time_score = time_score;
        s->coin_score = coin_score;
    }
}
Beispiel #7
0
//--------------------------------------------------------------------  
// Score-Funktion für alle Elemente des Datensatzes
// und für die drei untersuchten Häusersysteme berechnen  
//--------------------------------------------------------------------  
  int get_total_score( struct _hordat hordat[], 
                       int size, 
                       struct _score *sc) {
    int i,rc=0;
    
    for (i=0;i<size;i++) {  
      sc->vehlow   += get_score( &(hordat[i]), 'V');
      sc->koch     += get_score( &(hordat[i]), 'K');
      sc->placidus += get_score( &(hordat[i]), 'P');
      }    

    return rc;

    }                               
Beispiel #8
0
static gint
key_score (const gchar *key_,
           const gchar *text_)
{
  gchar  *text  = g_utf8_casefold (text_, -1);
  gchar  *key   = g_utf8_casefold (key_, -1);
  gint    score;
  
  score = get_score (key, text) + get_score (key, path_basename (text)) / 2;
  
  g_free (text);
  g_free (key);
  
  return score;
}
Beispiel #9
0
int			main(void)
{
	t_env	env;
	int		ret;

	if (!power_two(WIN_VALUE))
		return (0);
	signal(SIGINT, sighandler);
	startwin(&env);
	while (true)
	{
		ret = menu(&env, 0, 0);
		if (ret == 2)
			break ;
		else if (ret == 1)
			highscore(&env);
		else if (ret == 0)
		{
			init_env_game(&env);
			game(&env);
			get_name(&env);
			get_score(&env, 0);
			del_env_game(&env);
		}
	}
	return (endwin(), 0);
}
JNIEXPORT int JNICALL Java_com_technegames_insectoiddefense_RendererWrapper_get_1score(JNIEnv* env, jclass cls)
{
	UNUSED(env);
	UNUSED(cls);

	return get_score();
}
Beispiel #11
0
/**
 * Initializes a new tree with one node.
 */
minmax_tree* create_tree(Board* board, int (*get_score)(Board* board)) {
    minmax_tree* tree;
    vertex* current_root;

    if ((tree = (minmax_tree*) calloc(1, sizeof(minmax_tree))) == NULL) {
        printf("ERROR: standard function malloc has failed\n");
        return NULL;
    }

    if ((current_root = (vertex*)calloc(1, sizeof(vertex))) == NULL) {
        printf("ERROR: standard function malloc has failed\n");
        free(tree);
        return NULL;
    }

    current_root->score = get_score(board);
    if ((current_root->current_move = (Move*) malloc(sizeof(Move))) == NULL) {
        printf("ERROR: standard function malloc has failed\n");
        free(tree);
        free(current_root);
        return NULL;
    }
    current_root->current_move->i = -1;
    current_root->current_move->j = -1;
    current_root->value = 1;
    current_root->children = NULL;

    tree->root = current_root;
    return tree;
}
Beispiel #12
0
/* 向二叉树插入节点 */
int insert_node(tree *_tree, node *_node)
{
	_node->score = get_score(_node->map);
	_tree->count++;
	/* 调用递归实现方式 */
	return insert_recursive(_tree->root, _node);
}
Beispiel #13
0
/** The Smith Waterman algorithm function. */
void smith_waterman_alignment(int thread_id, SizeT dag_size, BlockT* data_block) {

	int i, j, k, idx;
	TSCORE match_score, gap_x, gap_y, gap_tmp;
	int row = seq1->length+1;
	int col = seq2->length+1;
	int row_st = data_block->block_pos.x;
	int row_ed = row_st + data_block->block_size.row;
	int col_st = data_block->block_pos.y;
        int col_ed = col_st + data_block->block_size.col;
	if (row_st <= 0)	row_st = 1;
	if (row_ed > row)	row_ed = row;
	if (col_st <= 0)	col_st = 1;
	if (col_ed > col)	col_ed = col;
	for (i = row_st; i < row_ed; ++i) {
		for (j = col_st; j < col_ed; ++j) {
			idx = i * col + j;

			// The match score value of x(i) aligns to y(j)
			match_score = get_score(seq1->acids[i - 1], seq2->acids[j - 1]);
			match_score += score_values[idx - col - 1];

			// The score value of x(i) aligns to a gap after y(j)
			gap_x = NEG_INFINITY;
			for (k = 1; k <= i; ++k) {
				gap_tmp = score_values[idx - k * col] - gap_score(k);
				if (gap_tmp > gap_x) {
					gap_x = gap_tmp;
					vertical_gaps[idx] = k;
				}
			}

			// The score value of y(j) aligns to a gap after x(i)
			gap_y = NEG_INFINITY;
			for (k = 1; k <= j; ++k) {
				gap_tmp = score_values[idx - k] - gap_score(k);
				if (gap_tmp > gap_y) {
					gap_y = gap_tmp;
					horizontal_gaps[idx] = k;
				}
			}

			// The best score value of x(*-i) aligns to y(*-j)
			score_values[idx] = 0;
			directions[idx] = 0;
			if (score_values[idx] < match_score) {
				score_values[idx] = match_score;
				directions[idx] = 1;
			}
			if (score_values[idx] < gap_x) {
				score_values[idx] = gap_x;
				directions[idx] = 2;
			}
			if (score_values[idx] < gap_y) {
				score_values[idx] = gap_y;
				directions[idx] = 3;
			}
		}
	}
}
Beispiel #14
0
void comp_move(char board[3][3])
{
    int best_move, move_score = -1;
    for (int i = 0; i < 9; ++i) {
		if (board[i / 3][i % 3] == ' ') {
			board[i / 3][i % 3] = 'o';
			if (get_score(board, USR) > move_score) {
				move_score = get_score(board, USR);
				best_move = i;
			}
			board[i / 3][i % 3] = ' ';
		}
    }
    board[best_move / 3][best_move % 3] = 'o';
    return;
}
Beispiel #15
0
void test_move_sort_1(void)
{

    struct move_list mvl = {
        .moves = {0},
        .move_count = 0
    };

    uint32_t start_score = 3;
    uint32_t score_incr = 75;

    // create some dummy moves and scores
    for(int32_t i = 0; i < 20; i++) {
        // interested more in the score than squares or pieces

        uint32_t score = start_score + (uint32_t)(score_incr * i);
        mv_bitmap mv = MOVE(e5, e6, NO_PIECE, NO_PIECE, MFLAG_NONE);
        add_to_score(&mv, score);

        // add to move list
        mvl.moves[i] = mv;
        mvl.move_count++;
    }

    // sort to bring best score to top
    bring_best_move_to_top(0, &mvl);


    //print_move_list_details(&mvl);
    mv_bitmap top_mv = mvl.moves[0];
    assert_true(get_score(top_mv) == 1428);

}
bool PossibleWord::operator==(const PossibleWord& rhs) const
{
    return (is_valid() == rhs.is_valid() && 
            get_expression() == rhs.get_expression() &&
            get_tiles_to_use() == rhs.get_tiles_to_use() &&
            get_score() == rhs.get_score());
}
Beispiel #17
0
void query(unsigned short qid, unsigned short artist, unsigned short areltd[], unsigned short bdstart, unsigned short bdend) {
    unsigned int person_offset;
    unsigned long knows_offset, knows_offset2;

    Person *person, *knows;
    unsigned char score;

    unsigned int result_length = 0, result_idx, result_set_size = 1000;
    Result* results = malloc(result_set_size * sizeof (Result));
    printf("Running query %d\n", qid);

    for (person_offset = 0; person_offset < person_length/sizeof(Person); person_offset++) {
        person = &person_map[person_offset];

        if (person_offset > 0 && person_offset % REPORTING_N == 0) {
            printf("%.2f%%\n", 100 * (person_offset * 1.0/(person_length/sizeof(Person))));
        }
        // filter by birthday
        if (person->birthday < bdstart || person->birthday > bdend) continue;

        // person must not like artist yet
        if (likes_artist(person, artist)) continue;

        // but person must like some of these other guys
        score = get_score(person, areltd);
        if (score < 1) continue;

        // check if friend lives in same city and likes artist
        for (knows_offset = person->knows_first;
             knows_offset < person->knows_first + person->knows_n;
             knows_offset++) {

            unsigned int friend_person_offset = knows_map[knows_offset];
            knows = &person_map[friend_person_offset];

            // friend must already like the artist
            if (!likes_artist(knows, artist)) continue;

            // realloc result array if we run out of space
            if (result_length >= result_set_size) {
                result_set_size *= 2;
                results = realloc(results, result_set_size * sizeof (Result));
            }
            results[result_length].person_id = person->person_id;
            results[result_length].knows_id = knows->person_id;
            results[result_length].score = score;
            result_length++;

        }
    }

    // sort result
    qsort(results, result_length, sizeof(Result), &result_comparator);

    // output
    for (result_idx = 0; result_idx < result_length; result_idx++) {
        fprintf(outfile, "%d|%d|%lu|%lu\n", qid, results[result_idx].score,
                results[result_idx].person_id, results[result_idx].knows_id);
    }
}
Beispiel #18
0
double RestraintCache::get_score(kernel::Restraint *r, const Subset &s,
                                 const Assignment &a) const {
  IMP_OBJECT_LOG;
  set_was_used(true);
  Slice slice = get_slice(r, s);
  Assignment ra = slice.get_sliced(a);
  return get_score(r, ra);
}
int Mission::get_flower() {
	for (int i = 3; i > 0; i--) {
		if (get_score() >= flower[i - 1]) {
			return i;
		}
	}
	return 0;
}
Beispiel #20
0
void draw_score(void){
	move_cursor(SCORE_LABEL_X,SCORE_LABEL_Y);
	printf_P(PSTR("Score:"));
	move_cursor(SCORE_X,SCORE_Y);
	printf_P(PSTR("%d"),get_score());
	
	move_cursor(WIDTH,HEIGHT);
}
Beispiel #21
0
void printModel(struct Model *modelPtr) {
	int i = 0;
	printf("Score: %u\n", get_score(modelPtr));
	for(i = 0; i < NUM_ENEMIES; i++){
		printf("lane for enemy: %i,%i",i,get_enemy_posY(modelPtr,i));
	}
	printf("\n");
	
}
Beispiel #22
0
void EnsembleGenerator::add_one_state(const Ensemble& init_ensemble,
                                      Ensemble& new_ensemble) {

  std::priority_queue<boost::tuple<double, int, int>,
                      Vector<boost::tuple<double, int, int> >,
                      Comparator> bestK;

  // iterate over all init MultiStateModels and try to add a new state to each
  for(unsigned int i=0; i<init_ensemble.size(); i++) {
    unsigned int first_to_search = init_ensemble[i].get_last_state()+1;
    if(first_to_search<N_) {

      if(i>0 && i%100==0 && !bestK.empty()) {
        double curr_bestK_score = boost::get<0>(bestK.top());
        std::cout << "Extending ensemble: " << i << " out of "
                  << init_ensemble.size() << " last best "
                  << curr_bestK_score << std::endl;
      }

      MultiStateModel new_model(init_ensemble[i]);
      new_model.add_state(first_to_search);

      // try all possible additions of a new state
      for(unsigned int j=first_to_search; j<N_; j++) {
        new_model.replace_last_state(j);
        double curr_score = get_score(new_model);
        if(curr_score < 0.0) continue; // invalid model
        // add to bestK
        if(bestK.size() <= K_ || curr_score < boost::get<0>(bestK.top())) {
          bestK.push(boost::make_tuple(curr_score, i, j));
          if(bestK.size() > K_) bestK.pop();
        }
      }
    }
  }

  // save best scoring
  new_ensemble.assign(bestK.size(), MultiStateModel(0));
  int index = bestK.size()-1;
  // generate bestK new MultiStateModels
  while(!bestK.empty()) {
    double score;
    int ensemble_index, new_state_index;
    boost::tie(score, ensemble_index, new_state_index) = bestK.top();
    MultiStateModel new_model(init_ensemble[ensemble_index]);
    new_model.add_state(new_state_index);
    new_model.set_score(score);
    new_ensemble[index] = new_model;
    index--;
    bestK.pop();
  }
}
Beispiel #23
0
int main
(  int                  argc
,  const char*          argv[]
)  
   {  mclx* mx_score, *mx_start, *mx_end
   ;  mcxIO* xfs, *xfl, *xfr
   ;  dim i, j

   ;  if (argc != 4)
      mcxDie(1, me, "need score start end matrices")

   ;  xfs = mcxIOnew(argv[1], "r")
   ;  xfl = mcxIOnew(argv[2], "r")
   ;  xfr = mcxIOnew(argv[3], "r")

   ;  mx_score = mclxRead(xfs, EXIT_ON_FAIL)
   ;  mx_start = mclxRead(xfl, EXIT_ON_FAIL)
   ;  mx_end   = mclxRead(xfr, EXIT_ON_FAIL)

   ;  fprintf
      (  stdout
      ,  "%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s%10s\n"
      ,  "vid1"
      ,  "vid2"
      ,  "diff1"
      ,  "diff2"
      ,  "meet"
      ,  "score"
      ,  "mean"
      ,  "csn"
      ,  "euclid"
      ,  "frac"
      ,  "re1"
      ,  "re2"
      )

   ;  for (i=0;i< N_COLS(mx_score);i++)
      {  for (j=0;j<N_COLS(mx_score);j++)
         {  double s
         ;  s =
            get_score
            (  mx_score->cols+i
            ,  mx_score->cols+j
            ,  mx_start->cols+i
            ,  mx_start->cols+j
            ,  mx_end->cols+i
            ,  mx_end->cols+j
            )
      ;  }
      }
      return 0
;  }
Beispiel #24
0
static void	end_menu(t_core *core)
{
	if (core->end_game == 2)
	{
		clear();
		attron(COLOR_PAIR(1));
		mvwprintw(stdscr, 0, 0, "You win! - Score : %d", get_score(core));
		mvwprintw(stdscr, 1, 0, "'space' for continue");
		mvwprintw(stdscr, 2, 0, "'R' for restart");
		mvwprintw(stdscr, 3, 0, "'esc' for exit");
		attroff(COLOR_PAIR(1));
	}
	else if (core->end_game)
	{
		clear();
		attron(COLOR_PAIR(2));
		mvwprintw(stdscr, 0, 0, "You lose! - Score : %d", get_score(core));
		mvwprintw(stdscr, 1, 0, "'R' for restart");
		mvwprintw(stdscr, 2, 0, "'esc' for exit");
		attroff(COLOR_PAIR(2));
	}
}
Beispiel #25
0
int motif_hit (char *text, int col, struct MOTIF *motif, int *score)
{
    int i;

    *score = 0;
    for (i = 0; i < motif->len; i++)
        *score += get_score (motif->submat, text[col + i], i);
	
    if (*score >= motif->threshold)
	return 1;
    else 
	return 0;
}
Beispiel #26
0
int get_score(char board[3][3], enum player p)
{
    if (check_winner(board) != INCOM)
		return check_winner(board);
    int score = -1;
    for (int i = 0; i < 9; ++i) {
		if (board[i / 3][i % 3] == ' ') {
	    	if (p == USR) {
				board[i / 3][i % 3] = 'X';
				if (score == -1)
		    		score = get_score(board, COMP);
				else
		    		score = min(score, get_score(board, COMP));
	    	} else if (p == COMP) {
				board[i / 3][i % 3] = 'o';
				score = max(score, get_score(board, USR));
	    }
	    board[i / 3][i % 3] = ' ';
	}
    }
    return score;
}
Beispiel #27
0
void detect_lines(void) {
  unsigned int row_index;
  unsigned int count = 0;
  for (row_index = 0; row_index < NUMBER_OF_ROWS; row_index++) {
    if (is_row_completed(row_index)) {
      remove_row(row_index);
      count++;
    }
  }
  if (count > 0) {
    set_score(get_score() + 1 << (2 * (count - 1)));
  }
}
Beispiel #28
0
double ContAlign::align (const char* xseq, int xlen, const char* yseq, int ylen, bool unpack)
{
    int x, y;
    char* bp = btrmx;
    max_reached = false;
    last_reached = false;
    accum_hor_skip = 0;
    to_first = false, to_last = false;

    //check if enough memory allocated for band alignment
    if (ylen > max_ylen || xlen * ylen > max_size || xlen > max_xlen)
        ers << "align error: attempting to align sequences longer than declared, xlen = " << xlen << ", ylen = "  << ylen << Throw;

    bstep = ylen;
    xref = 0, yref = 0;

    // initialize homopolimer size indices
    fill_homo_tract_len (xseq, xlen, xhomo);
    fill_homo_tract_len (yseq, ylen, yhomo);

    //initialize left boundary
    //unpack Y sequence for faster processing
    for (y = 0; y < ylen; y++)
    {
        ap[y].w = 0;
        ap[y].h = low_score;
        ap[y].r = unpack? get_base (yseq, y) : yseq [y];
        ap[y].div = yhomo [y+1];
    }

    //find best local alignment
    double cur_w;
    max_w = last_w = - std::numeric_limits <double>::max ();
    max_bp = btrmx;
    for (x = 0; x < xlen; x++, bp += bstep)
    {
        cur_w = align_y_loop (ap, unpack ? get_base (xseq, x) : xseq [x+1], bp, x, xhomo [x], 0, ylen, true, 0.0);
        // remember X edge terminal scores
        if (last_w < cur_w)
            last_w = cur_w, last_bp = bp + ylen - 1, last_x = x, last_y = ylen-1, last_reached = true;
    }

#ifdef DEBUG_TRACE
    if (trace_mode)
        trclog << std::endl;
#endif
    if (logp_)
        (*logp_) << std::endl;

    return get_score ();
}
Beispiel #29
0
/** The Smith Waterman traceback algorithm function. Get result. */
static void smith_waterman_traceback(Result_t *result) {
	int i, j, idx, col, len, maxlen, gap_len;
	char acid1, acid2;
	char *reversed_markup; // revered markup

	col = seq2->length + 1;
	maxlen = seq1->length + seq2->length + 2; //the maximum length.
	reversed_markup = (char *) malloc(maxlen * sizeof(char));

	len = 0;
	result->score = trace_cell.value;
	result->identity = result->similarity = result->gaps = 0;

	i = trace_cell.row;
	j = trace_cell.col;
	while (idx = i * col + j, directions[idx] != 0) { 
		if (directions[idx] == 3) {
			for (gap_len = horizontal_gaps[idx]; gap_len > 0; --gap_len) {
				--j;
				reversed_markup[len++] = '2'; // Sequence #2.
				++result->gaps;
			}
		} else if (directions[idx] == 2) {
			for (gap_len = vertical_gaps[idx]; gap_len > 0; --gap_len) {
				--i;
				reversed_markup[len++] = '1'; // Sequence #1.
				++result->gaps;
			}
		} else if (directions[idx] == 1) {
			acid1 = seq1->acids[--i];
			acid2 = seq2->acids[--j];
			if (acid1 == acid2) {
				reversed_markup[len++] = '|';
				++result->identity;
				++result->similarity;
			} else if (get_score(acid1, acid2) > 0) {
				reversed_markup[len++] = ':';
				++result->similarity;
			} else {
				reversed_markup[len++] = '.';
			}
		}
	}

	result->start1 = i + 1;
	result->start2 = j + 1;
	result->length = len;
	result->markup = (char *) malloc(len * sizeof(char));
	reverse_copy(result->markup, reversed_markup, len);
}
void update_score(Leaderboard *leaderboard, char *username, bool win)
{
	Score *score;

	if (contains_user(leaderboard, username)) {
		score = get_score(leaderboard, username);
	} else {
		score = add_user(leaderboard, username);
	}

	score->games_played++;
	score->games_won += win;

	sort_leaderboard(leaderboard);
}