Esempio n. 1
0
int Do_Markup(struct Node *n, struct Property *p, struct BoardStatus *st)
{
	int x, y;
	struct PropValue *v;
	U_SHORT flag;

	if(sgfc->info->GM != 1)		/* game != Go? */
		return(TRUE);

	v = p->value;
	flag = sgf_token[p->id].data;

	while(v)
	{
		x = DecodePosChar(v->value[0]) - 1;
		y = DecodePosChar(v->value[1]) - 1;
	
		if(st->markup[MXY(x,y)] & flag)
		{
			PrintError(E_POSITION_NOT_UNIQUE, v->buffer, "Markup", p->idstr);
			v = Del_PropValue(p, v);
			continue;
		}

		st->markup[MXY(x,y)] |= flag;
		st->mrkp_chngd = TRUE;
		v = v->next;
	}

	return(TRUE);
}
Esempio n. 2
0
int Do_Mark(struct Node *n, struct Property *p, struct BoardStatus *st)
{
	int x, y;
	struct PropValue *v;

	if(sgfc->info->GM != 1)		/* game != Go? */
		return(TRUE);

	v = p->value;
	while(v)
	{
		x = DecodePosChar(v->value[0]) - 1;
		y = DecodePosChar(v->value[1]) - 1;
	
		if(st->markup[MXY(x,y)] & ST_MARKUP)
		{
			PrintError(E_POSITION_NOT_UNIQUE, v->buffer, "Markup", p->idstr);
		}
		else
		{
			st->markup[MXY(x,y)] |= ST_MARKUP;
			st->mrkp_chngd = TRUE;

			if(st->board[MXY(x,y)])
				New_PropValue(n, TKN_TR, v->value, NULL, FALSE);
			else
				New_PropValue(n, TKN_MA, v->value, NULL, FALSE);
		}
		v = v->next;
	}

	return(FALSE);
}
Esempio n. 3
0
int Do_Letter(struct Node *n, struct Property *p, struct BoardStatus *st)
{
	int x, y;
	struct PropValue *v;
	char letter[2] = "a";

	if(sgfc->info->GM != 1)		/* game != Go? */
		return(TRUE);

	v = p->value;
	while(v)
	{
		x = DecodePosChar(v->value[0]) - 1;
		y = DecodePosChar(v->value[1]) - 1;
	
		if(st->markup[MXY(x,y)] & ST_LABEL)
		{
			PrintError(E_POSITION_NOT_UNIQUE, v->buffer, "Label", p->idstr);
		}
		else
		{
			st->markup[MXY(x,y)] |= ST_LABEL;
			st->mrkp_chngd = TRUE;
			New_PropValue(n, TKN_LB, v->value, letter, FALSE);
			letter[0]++;
		}

		v = v->next;
	}

	return(FALSE);
}
void db_FrameToReferenceRegistration::SmoothMotion(void)
{
  VP_MOTION inmot,outmot;

  double H[9];

  Get_H_dref_to_ins(H);

      MXX(inmot) = H[0];
    MXY(inmot) = H[1];
    MXZ(inmot) = H[2];
    MXW(inmot) = 0.0;

    MYX(inmot) = H[3];
    MYY(inmot) = H[4];
    MYZ(inmot) = H[5];
    MYW(inmot) = 0.0;

    MZX(inmot) = H[6];
    MZY(inmot) = H[7];
    MZZ(inmot) = H[8];
    MZW(inmot) = 0.0;

    MWX(inmot) = 0.0;
    MWY(inmot) = 0.0;
    MWZ(inmot) = 0.0;
    MWW(inmot) = 1.0;

    inmot.type = VP_MOTION_AFFINE;

    int w = m_im_width;
    int h = m_im_height;

    if(m_quarter_resolution)
    {
    w = w*2;
    h = h*2;
    }

#if 0
    m_stab_smoother.smoothMotionAdaptive(w,h,&inmot,&outmot);
#else
    m_stab_smoother.smoothMotion(&inmot,&outmot);
#endif

    H[0] = MXX(outmot);
    H[1] = MXY(outmot);
    H[2] = MXZ(outmot);

    H[3] = MYX(outmot);
    H[4] = MYY(outmot);
    H[5] = MYZ(outmot);

    H[6] = MZX(outmot);
    H[7] = MZY(outmot);
    H[8] = MZZ(outmot);

    Set_H_dref_to_ins(H);
}
Esempio n. 5
0
void Make_Capture(int x, int y, struct BoardStatus *st)
{
	if(path_board[MXY(x,y)] != path_num)
		return;

	st->board[MXY(x,y)] = EMPTY;
	path_board[MXY(x,y)] = 0;

	/* recursive calls */
	if(x > 0)	Make_Capture(x-1, y, st);
	if(y > 0)	Make_Capture(x, y-1, st);
	if(x < sgfc->info->bwidth-1)	Make_Capture(x+1, y, st);
	if(y < sgfc->info->bheight-1)	Make_Capture(x, y+1, st);
}
Esempio n. 6
0
void Capture_Stones(struct BoardStatus *st, int color, int x, int y)
{
	if(x < 0 || y < 0 || x >= sgfc->info->bwidth || y >= sgfc->info->bheight)
		return;		/* not on board */

	if(!st->board[MXY(x,y)] || st->board[MXY(x,y)] == color)
		return;		/* liberty or friend found */

	if(!path_num)
		memset(path_board, 0, sizeof(path_board));

	path_num++;

	if(Recursive_Capture(color, x, y, st))	/* made prisoners? */
		Make_Capture(x, y, st);				/* ->update board position */
}
Esempio n. 7
0
int Do_Move(struct Node *n, struct Property *p, struct BoardStatus *st)
{
	int x, y;
	char color;

	if(sgfc->info->GM != 1)		/* game != Go? */
		return(TRUE);

	if(st->annotate & ST_MOVE)	/* there's a move already? */
	{
		PrintError(E_TWO_MOVES_IN_NODE, p->buffer);
		Split_Node(n, 0, p->id, TRUE);
		return(TRUE);
	}

	st->annotate |= ST_MOVE;

	if(!strlen(p->value->value))	/* pass move */
		return(TRUE);

	x = DecodePosChar(p->value->value[0]) - 1;
	y = DecodePosChar(p->value->value[1]) - 1;
	color = (char)sgf_token[p->id].data;

	if(st->board[MXY(x,y)])
		PrintError(WS_ILLEGAL_MOVE, p->buffer);

	st->board[MXY(x,y)] = color;
	Capture_Stones(st, color, x-1, y);		/* check for prisoners */
	Capture_Stones(st, color, x+1, y);
	Capture_Stones(st, color, x, y-1);
	Capture_Stones(st, color, x, y+1);
	Capture_Stones(st, ~color, x, y);		/* check for suicide */

	if(option_del_move_markup)			/* if del move markup, then */
	{						/* mark move position as markup */
		st->markup[MXY(x,y)] |= ST_MARKUP;	/* -> other markup at this */
		st->mrkp_chngd = TRUE;			/* position will be deleted */
	}

	return(TRUE);
}
Esempio n. 8
0
int Recursive_Capture(int color, int x, int y, struct BoardStatus *st)
{
	if(!st->board[MXY(x,y)])
		return(FALSE);		/* liberty found */

	if(st->board[MXY(x,y)] == color)
		return(TRUE);		/* enemy found */

	if(path_board[MXY(x,y)] == path_num)
		return(TRUE);

	path_board[MXY(x,y)] = path_num;

	/* recursive calls */
	if(x > 0)	if(!Recursive_Capture(color, x-1, y, st))	return(FALSE);
	if(y > 0)	if(!Recursive_Capture(color, x, y-1, st))	return(FALSE);
	if(x < sgfc->info->bwidth-1)
				if(!Recursive_Capture(color, x+1, y, st))	return(FALSE);
	if(y < sgfc->info->bheight-1)
				if(!Recursive_Capture(color, x, y+1, st))	return(FALSE);

	return(TRUE);
}
Esempio n. 9
0
int Do_Addstones(struct Node *n, struct Property *p, struct BoardStatus *st)
{
	int x, y;
	char color;
	struct PropValue *v, *w;
	struct Property h;

	if(sgfc->info->GM != 1)		/* game != Go? */
		return(TRUE);

	h.value = NULL;
	h.valend = NULL;

	color = (char)sgf_token[p->id].data;

	v = p->value;
	while(v)
	{
		x = DecodePosChar(v->value[0]) - 1;
		y = DecodePosChar(v->value[1]) - 1;
	
		if(st->markup[MXY(x,y)] & ST_ADDSTONE)
		{
			PrintError(E_POSITION_NOT_UNIQUE, v->buffer, "AddStone", p->idstr);
			v = Del_PropValue(p, v);
			continue;
		}

		st->markup[MXY(x,y)] |= ST_ADDSTONE;
		st->mrkp_chngd = TRUE;

		if(st->board[MXY(x,y)] == color)		/* Add property is redundant */
		{
			w = v->next;
			Delete(&p->value, v);
			AddTail(&h.value, v);
			v = w;
			continue;
		}

		st->board[MXY(x,y)] = color;
		v = v->next;
	}

	if(h.value)
	{
		x = PrintError(WS_ADDSTONE_REDUNDANT, p->buffer, p->idstr);

		v = h.value;
		while(v)
		{
			if(x)	fprintf(E_OUTPUT, "[%s]", v->value);
			v = Del_PropValue(&h, v);
		}

		if(x)
			fprintf(E_OUTPUT, "\n");
	}

	return(TRUE);
}