예제 #1
0
void CControl_Manager::reinit()
{
	if(	m_object->CCustomMonster::use_simplified_visual() ) return;
	// todo: make it simpler
	// reinit pure first, base second, custom third
	CONTROLLERS_MAP_IT it;

	for (it = m_control_elems.begin(); it != m_control_elems.end(); ++it)  
		if (is_pure(it->second)) it->second->reinit();
	
	for (it = m_control_elems.begin(); it != m_control_elems.end(); ++it)  
		if (is_base(it->second)) it->second->reinit();
	
	for (it = m_control_elems.begin(); it != m_control_elems.end(); ++it)  
		if (!is_pure(it->second) && !is_base(it->second)) it->second->reinit();

	// fill active elems
	m_active_elems.clear	();
	m_active_elems.reserve	(ControlCom::eControllersCount);
	for (it = m_control_elems.begin(); it != m_control_elems.end(); ++it)  {
		if (it->second->is_active() && !is_locked(it->second)) {
			m_active_elems.push_back(it->second);
		}
	}

}
예제 #2
0
파일: quest.c 프로젝트: FredrIQ/nhfourk
/* external hook for do.c (level change check) */
boolean
ok_to_quest(boolean verbose)
{
    if (!(Qstat(got_quest)) && !(Qstat(got_thanks))) {
        if (verbose) {
            if (Hallucination)
                You_hear("the man telling you what you can and can't do.");
            else
                You_hear("a mysterious voice say "
                         "\"You must have permission to descend.\"");
        }
    } else if (is_pure(TRUE) <= 0) {
        if (verbose) {
            if (Hallucination)
                You_hear("someone whining about how you should treat %s "
                         "better.", halu_gname(u.ualignbase[A_ORIGINAL]));
            else
                You_hear("a mysterious voice say "
                         "\"Only the faithful of %s may descend.\"",
                         align_gname(u.ualignbase[A_ORIGINAL]));
        }
    } else
        return TRUE;

    if (verbose) {
        if (Hallucination)
            pline("This staircase is a lie, man!");
        else
            pline("A mysterious force prevents you from descending.");
    }
    return FALSE;
}
예제 #3
0
void CControl_Manager::unlock(CControl_Com *com, ControlCom::EControlType type)
{
	VERIFY	(is_pure(m_control_elems[type]));
	VERIFY	(m_control_elems[type]->ced()->capturer() == com);

	m_control_elems[type]->ced()->set_locked(false);
	
	// it's unlocked so add to active list
	check_active_com(m_control_elems[type], eAdd);
}
예제 #4
0
void CControl_Manager::lock(CControl_Com *com, ControlCom::EControlType type)
{
	VERIFY	(is_pure(m_control_elems[type]));
	VERIFY	(m_control_elems[type]->ced()->capturer() == com);
	
	m_control_elems[type]->ced()->set_locked();
	
	// it's now locked so remove from active list
	check_active_com(m_control_elems[type], eRemove);
}
예제 #5
0
void GL_navigate_layer_2::mouseReleaseEvent(QMouseEvent *e) {
	switch (s) {
		case PAN:
			s = NONE;
			break;
		case ZOOM:
			s = NONE;
			break;
		case ZOOM_RECT:
			rubber_band->hide();
			delete rubber_band;
			rubber_band = 0;
			widget->repaintGL();

			if((e->x() != first_x) && (e->y() != first_y)) {
				double x, y, xfirst2, yfirst2;
				x = widget->x_real(e->x());
				y = widget->y_real(e->y());
				xfirst2 = widget->x_real(first_x);
				yfirst2 = widget->y_real(first_y);

				double	xmin, xmax, ymin, ymax;
				if(x < xfirst2) {xmin = x; xmax = xfirst2;}
				else {xmin = xfirst2; xmax = x;};
				if(y < yfirst2) {ymin = y; ymax = yfirst2;}
				else {ymin = yfirst2; ymax = y;};

				if (is_alt(e)) widget->set_window(xmin, xmax, ymin, ymax);
				else smooth_zoom(xmin, xmax, ymin, ymax);
			} else if (widget->has_boundingbox()) {
				// jump to bounding box
				double x_min = widget->get_bounding_xmin();
				double x_max = widget->get_bounding_xmax();
				double y_min = widget->get_bounding_ymin();
				double y_max = widget->get_bounding_ymax();
				if (x_min != x_max && y_min != y_max)	{
					double margin_percent= BOUNDING_BOX_MARGIN_PERCENT;
					double x_margin = (x_max - x_min) * margin_percent;
					double y_margin = (y_max - y_min) * margin_percent;
					x_min -= x_margin;	x_max += x_margin;
					y_min -= y_margin;	y_max += y_margin;
					if (is_alt(e)) widget->set_window(x_min, x_max, y_min, y_max);
					else smooth_zoom(x_min, x_max, y_min, y_max);
				}
			}
			s = NONE;
			break;
	}
	if (is_pure(e) || is_alt(e) || is_shift(e)) widget->setCursor(QCursor( QPixmap( (const char**)hand_xpm)));
	else {
			QCursor c = widget->get_default_cursor();
			c.setShape(Qt::CrossCursor);
			widget->setCursor(c);
	}
}
예제 #6
0
void GL_navigate_layer_2::mousePressEvent(QMouseEvent *e) {
	if (is_pure(e) || is_alt(e)) {
		switch (e->button()) {
			case Qt::LeftButton:
				if (s != PAN) {
					widget->setCursor(QCursor( QPixmap( (const char**)holddown_xpm)));
					first_x = e->x();
					first_y = e->y();
					s = PAN;
				}
				break;
			case Qt::RightButton:
				if (s != ZOOM && s != ZOOM_RECT) {
					widget->setCursor(QCursor( QPixmap( (const char**)zoomin_xpm)));
					first_x = e->x();
					first_y = e->y();
					s = ZOOM;
				}	
				break;
			case Qt::MidButton:
				if (s != ZOOM_RECT) {
					widget->setCursor(QCursor( QPixmap( (const char**)zoomin_rect_xpm)));
					s = ZOOM_RECT;
					rubberBand_origin = e->pos();
					if (!rubber_band) {
						rubber_band = new QRubberBand(QRubberBand::Rectangle, widget);
						windows_style = new QWindowsStyle();
						rubber_band->setStyle(windows_style);
					}
					rubber_band->setGeometry(QRect(rubberBand_origin, QSize()));
					rubber_band->show();
					first_x = e->x();
					first_y = e->y();
				}	
				break;
		}
	}
}
예제 #7
0
파일: quest.c 프로젝트: vaLinBSD/nethack
/* external hook for do.c (level change check) */
boolean
ok_to_quest()
{
	return((boolean)((Qstat(got_quest) || Qstat(got_thanks)))
			&& (is_pure(FALSE) > 0));
}
예제 #8
0
/**
 * Train the classifier with a new sample.
 *
 * We collect the training data, until the number of collected
 * samples exceeds the "active set size" of the gaussian process
 * classifier.
 * If we have already decided which labels to train, the input data
 * will be filtered immediately. Samples with other labels will be
 * thrown away.
 * If we have not yet decided which labels to train, we fill the buffer
 * matrix with all samples we get, then decide which labels to classify
 * and filter the data we got so far.
 *
 * @param s the sample to be trained
 */
void GPC::update(const Sample& s) {

	buffered_samples->push_back(s);

	// update the label counter
	if(label_counter->find(s.y) == label_counter->end()) {
		label_counter->insert(std::map<Label,int>::value_type(s.y,1));
	} else {
		(*label_counter)[s.y]++;
	}


	switch(state) {
/*
	case INIT:
		if(!is_pure() && buffered_samples->size() > active_set_size) {
			choose_labels_from_buffer();
			state = TRAIN;
		}

		break;
*/
	case TRAIN:
		// check if we have collected enough data to initiate training
		if(!is_pure() && (*label_counter)[1] + (*label_counter)[-1] > active_set_size) {

			// copy the relevant samples into a matrix
			CMatrix* training_labels;
			CMatrix* training_features;
			get_training_matrices(training_labels, training_features);

			// is this the first learning cycle?
			if(predictor == NULL) {
				// no noise model existing yet => create new noise model
				noise = new CProbitNoise( training_labels );
			}
			else {
				// noise model is already existing => adapt model
				CMatrix noiseParams(1, noise->getNumParams());
				noise->getParams( noiseParams );
				noise->setTarget( training_labels );
				noise->setParams( noiseParams );
			}

			// update the gaussian process model
			predictor = new CIvm(training_features, training_labels, kernel, noise, select_crit, active_set_size, 3);

			if(default_optimization_params)
				predictor->optimise();
			else
				predictor->optimise(max_iters, kern_iters, noise_iters);

			// reset the counters for the labels
			delete buffered_samples;
			delete label_counter;
			buffered_samples = new std::vector<Sample>();
			label_counter = new std::map<Label,int>();
		}

		break;
	}

}
예제 #9
0
파일: quest.c 프로젝트: FredrIQ/nhfourk
static void
chat_with_leader(void)
{
/* Rule 0: Cheater checks.                                 */
    if (Uhave_questart && !Qstat(met_nemesis))
        Qstat(cheater) = TRUE;

/* It is possible for you to get the amulet without completing
 * the quest.  If so, try to induce the player to quest.
 */
    if (Qstat(got_thanks)) {
/* Rule 1: You've gone back with/without the amulet.       */
        if (Uhave_amulet)
            finish_quest(NULL);

/* Rule 2: You've gone back before going for the amulet.   */
        else
            qt_pager(QT_POSTHANKS);
    }

/* Rule 3: You've got the artifact and are back to return it. */
    else if (Uhave_questart) {
        struct obj *otmp;

        for (otmp = invent; otmp; otmp = otmp->nobj)
            if (is_quest_artifact(otmp))
                break;

        finish_quest(otmp);

/* Rule 4: You haven't got the artifact yet.       */
    } else if (Qstat(got_quest)) {
        qt_pager(rn1(10, QT_ENCOURAGE));

/* Rule 5: You aren't yet acceptable - or are you? */
    } else {
        if (!Qstat(met_leader)) {
            qt_pager(QT_FIRSTLEADER);
            Qstat(met_leader) = TRUE;
            Qstat(not_ready) = 0;
        } else
            qt_pager(QT_NEXTLEADER);
        /* the quest leader might have passed through the portal into the
           regular dungeon; none of the remaining make sense there */
        if (!on_level(&u.uz, &qstart_level))
            return;

        if ((is_pure(FALSE) > 0) && (u.ulevelmax < 2) &&
            ((!challengemode) || !(u.uconduct[conduct_killer]))) {
            qt_pager(QT_LOWLEVEL);
            if (yn_function("Confirm your readiness and start the quest?",
                            "yn", 'n') == 'y') {
                pline("\"Go on then.\"");
                Qstat(got_quest) = TRUE;
                /* TODO: levelport the player straight to Quest 2? */
                historic_event(FALSE, FALSE, "embarked upon an epic quest.");
            } else {
                qt_pager(QT_BADLEVEL);
                expulsion(FALSE);
            }
            return;
        }
        if (not_capable()) {
            qt_pager(QT_BADLEVEL);
            expulsion(FALSE);
        } else if (is_pure(TRUE) < 0) {
            com_pager(QT_BANISHED);
            expulsion(TRUE);
        } else if (is_pure(FALSE) == 0) {
            qt_pager(QT_BADALIGN);
            if (Qstat(not_ready) == MAX_QUEST_TRIES) {
                qt_pager(QT_LASTLEADER);
                expulsion(TRUE);
            } else {
                Qstat(not_ready)++;
                expulsion(FALSE);
            }
        } else {        /* You are worthy! */
            qt_pager(QT_ASSIGNQUEST);
            Qstat(got_quest) = TRUE;
            historic_event(FALSE, FALSE, "embarked upon an epic quest.");
        }
    }
}
예제 #10
0
static void
chat_with_leader(void)
{
/* Rule 0: Cheater checks.                                 */
    if (u.uhave.questart && !Qstat(met_nemesis))
        Qstat(cheater) = TRUE;

/* It is possible for you to get the amulet without completing
 * the quest.  If so, try to induce the player to quest.
 */
    if (Qstat(got_thanks)) {
/* Rule 1: You've gone back with/without the amulet.       */
        if (u.uhave.amulet)
            finish_quest(NULL);

/* Rule 2: You've gone back before going for the amulet.   */
        else
            qt_pager(QT_POSTHANKS);
    }

/* Rule 3: You've got the artifact and are back to return it. */
    else if (u.uhave.questart) {
        struct obj *otmp;

        for (otmp = invent; otmp; otmp = otmp->nobj)
            if (is_quest_artifact(otmp))
                break;

        finish_quest(otmp);

/* Rule 4: You haven't got the artifact yet.       */
    } else if (Qstat(got_quest)) {
        qt_pager(rn1(10, QT_ENCOURAGE));

/* Rule 5: You aren't yet acceptable - or are you? */
    } else {
        if (!Qstat(met_leader)) {
            qt_pager(QT_FIRSTLEADER);
            Qstat(met_leader) = TRUE;
            Qstat(not_ready) = 0;
        } else
            qt_pager(QT_NEXTLEADER);
        /* the quest leader might have passed through the portal into the
           regular dungeon; none of the remaining make sense there */
        if (!on_level(&u.uz, &qstart_level))
            return;

        if (not_capable()) {
            qt_pager(QT_BADLEVEL);
            exercise(A_WIS, TRUE);
            expulsion(FALSE);
        } else if (is_pure(TRUE) < 0) {
            com_pager(QT_BANISHED);
            expulsion(TRUE);
        } else if (is_pure(TRUE) == 0) {
            qt_pager(QT_BADALIGN);
            if (Qstat(not_ready) == MAX_QUEST_TRIES) {
                qt_pager(QT_LASTLEADER);
                expulsion(TRUE);
            } else {
                Qstat(not_ready)++;
                exercise(A_WIS, TRUE);
                expulsion(FALSE);
            }
        } else {        /* You are worthy! */
            qt_pager(QT_ASSIGNQUEST);
            exercise(A_WIS, TRUE);
            Qstat(got_quest) = TRUE;
            historic_event(FALSE, "embarked upon an epic quest.");
        }
    }
}