Exemple #1
0
/* FIXME double check and remove editMove, unnecessary */
void Tree::doPass(bool /*sgf*/, bool /*fastLoad*/)
{
//	if (lastValidMove == NULL)
//	{
//		stoneHandler->checkAllPositions();
//	}

/////////////////FIXME We may have a problem at first move with handicap games ...
	StoneColor c = (current->getColor() == stoneWhite) ? stoneBlack : stoneWhite;
	
//	currentMove++;
	addMove(c, 20, 20);
#ifdef OLD
	if (!sgf)
		addMove(c, 20, 20);
	else  // Sgf reading
	{
		if (current->parent != NULL)
			c = current->parent->getColor() == stoneBlack ? stoneWhite : stoneBlack;
		else
			c = stoneBlack;
		if (!fastLoad)
			editMove(c, 20, 20);
	}
#endif //OLD
	if (current->parent != NULL)
		current->setCaptures(current->parent->getCapturesBlack(),
		current->parent->getCapturesWhite());
}
void postTechOption(AI* ai)
{
    if (chance(GET_UP_ATTACK_PROB))
    {
        addMove(ai, &_mv_jab);
    }
    else
    {
        addMove(ai, &_mv_spotDodge);
    }
}
bool HelloWorld::onTouchBegan( Touch *touch, Event *unused_event )
{   
	if(_gameOver)
	{
		return false;
	}
	if (!_circles.empty())
	{
		for (auto pair : _circles)
		{
			auto circle = pair.second;
			Point local = convertToNodeSpace(touch->getLocation());
			Rect r = circle->getBoundingBox();
			if (r.containsPoint(local))
			{   
				if (!circle->IsSelect())
				{   
				    circle->setSelect();
					addMove();
				}
				break;
			}
		}
	}
	return true;
}
PlayerOctopus::PlayerOctopus(Character* c, GridOctopus* grid)
    : OctopusBaby(PLAYER_WIDTH, PLAYER_HEIGHT), _character(c), _grid(grid), destination_cell(_character->getCell())
{
    if (!_basic_player.valid())
    {
        _basic_player = (*ServiceLocator::getTextureManager())["knight"];

        // compute ratio
        double ratiox = (double)_relative_rect.w / _basic_player.getWidth();
        double ratioy = (double)_relative_rect.h / _basic_player.getHeight();
        _ratio = min(ratioy, ratiox);

        // calculate padding
        int xpadding = -5;
        int ypadding = 7;
        PADDINGFaceLeft = Point(-_basic_player.getWidth() * _ratio / 2 + xpadding, -_basic_player.getHeight() * _ratio + ypadding);
        PADDINGFaceRight = Point(PADDINGFaceLeft.x -2*xpadding, PADDINGFaceLeft.y);

    }
    setBgColor(Color::TRANSPARENT);

    // event registration
    EventService* evs = EVENTSERVICE;
    evs->listen(typeid(MoveEvent), [=](Event* e) {
        MoveEvent* ev = dynamic_cast<MoveEvent*>(e);
        if (ev && ev->getCharacter() == _character)
            addMove(ev->destination, ev->move_wanted);
    }
               );
}
Exemple #5
0
/**
* Attempt to move the player right one space
*
* @param dungeon A pointer to the dungeon
* @param object A pointer to the object to move
*
* @return RESULT_WIN if the player has won the game
*         RESULT_DIE if the player has died in the game
*         else 0
*/
int moveRight(Dungeon* dungeon, Object* object) {
    Coordinate next_space_coord;
    Object *next_space;
    int result=0;

    next_space_coord.x = object->position->x+1;
    next_space_coord.y = object->position->y;
    if(!(next_space = getObjectByCoord(dungeon->start, next_space_coord)))
        _terminate(OBJECT_NOT_FOUND_ERROR);

    if(object->id == PLAYER_NUM)
        addMove(dungeon, object, dungeon->moveTypes.right);

    if(next_space->id == FLOOR_NUM) {
        if(object->id == ZOMBIE_NUM || object->id == BAT_NUM)
            object->direction->x = DIR_LEFT;
        return result;
    } else if(next_space->id == WALL_NUM) {
        if(object->id == ZOMBIE_NUM || object->id == BAT_NUM)
            object->direction->x = DIR_LEFT;
        return result;
    } else if (next_space->id == TREASURE_NUM) {
        if(object->id == ZOMBIE_NUM || object->id == BAT_NUM)
            object->direction->x = DIR_LEFT;
        if(object->id == PLAYER_NUM)
            return RESULT_WIN;
        return result;
    } else if (next_space->id == BAT_NUM) {
        if(object->id == PLAYER_NUM) {
            sendKillMessage(BAT_KILL_MSG);
            return RESULT_DIE;
        }
        if(object->id == ZOMBIE_NUM || object->id == BAT_NUM)
            object->direction->x = DIR_LEFT;
        return result;
    }
    else if (next_space->id == ZOMBIE_NUM) {
        if(object->id == PLAYER_NUM) {
            sendKillMessage(ZOMBIE_KILL_MSG);
            return RESULT_DIE;
        }
        if(object->id == ZOMBIE_NUM || object->id == BAT_NUM)
            object->direction->x = DIR_LEFT;
        return result;
    }
    else if (next_space->id == PLAYER_NUM)
        return RESULT_DIE;
    else if (next_space->id == EMPTY_NUM) {
        Coordinate tmp;
        tmp.x = object->position->x;
        tmp.y = object->position->y;
        setObjectByCoord(dungeon->start, next_space_coord, object);
        setObjectByCoord(dungeon->start, tmp, next_space);

        return 0;
    }

    return 0;
}
void Rubik::D(bool isAddToMoves) {
	shift(this->corners, 18, 12, 13, 3);
	shift(this->corners, 20, 21, 11, 2);
	shift(this->corners, 10, 4, 5, 19);
	shift(this->edges, 20, 17, 21, 2);
	shift(this->edges, 8, 5, 9, 14);

	if (isAddToMoves)
		addMove(this->movesDictionary[_D]);
}
void Rubik::Di(bool isAddToMoves) {
	shift(this->corners, 3, 13, 12, 18);
	shift(this->corners, 2, 11, 21, 20);
	shift(this->corners, 19, 5, 4, 10);
	shift(this->edges, 2, 21, 17, 20);
	shift(this->edges, 14, 9, 5, 8);

	if (isAddToMoves)
		addMove(this->movesDictionary[_Di]);
}
void Rubik::Ri(bool isAddToMoves) {
	shift(this->corners, 9, 15, 5, 3);
	shift(this->corners, 7, 21, 19, 1);
	shift(this->corners, 17, 23, 13, 11);
	shift(this->edges, 7, 22, 9, 1);
	shift(this->edges, 19, 10, 21, 13);

	if (isAddToMoves)
		addMove(this->movesDictionary[_Ri]);
}
void Rubik::F(bool isAddToMoves) {
	shift(this->corners, 8, 10, 11, 9);
	shift(this->corners, 18, 19, 17, 16);
	shift(this->corners, 2, 3, 1, 0);
	shift(this->edges, 15, 14, 13, 12);
	shift(this->edges, 3, 2, 1, 0);

	if (isAddToMoves)
		addMove(this->movesDictionary[_F]);
}
void Rubik::Fi(bool isAddToMoves) {
	shift(this->corners, 9, 11, 10, 8);
	shift(this->corners, 16, 17, 19, 18);
	shift(this->corners, 0, 1, 3, 2);
	shift(this->edges, 12, 13, 14, 15);
	shift(this->edges, 0, 1, 2, 3);

	if (isAddToMoves)
		addMove(this->movesDictionary[_Fi]);
}
void Rubik::B(bool isAddToMoves) {
	shift(this->corners, 13, 4, 14, 7);
	shift(this->corners, 23, 5, 20, 6);
	shift(this->corners, 15, 21, 12, 22);
	shift(this->edges, 10, 5, 23, 4);
	shift(this->edges, 22, 17, 11, 16);

	if (isAddToMoves)
		addMove(this->movesDictionary[_B]);
}
void Rubik::Bi(bool isAddToMoves) {
	shift(this->corners, 7, 14, 4, 13);
	shift(this->corners, 6, 20, 5, 23);
	shift(this->corners, 22, 12, 21, 15);
	shift(this->edges, 4, 23, 5, 10);
	shift(this->edges, 16, 11, 17, 22);

	if (isAddToMoves)
		addMove(this->movesDictionary[_Bi]);
}
void Rubik::R(bool isAddToMoves) {
	shift(this->corners, 3, 5, 15, 9);
	shift(this->corners, 1, 19, 21, 7);
	shift(this->corners, 11, 13, 23, 17);
	shift(this->edges, 1, 9, 22, 7);
	shift(this->edges, 13, 21, 10, 19);

	if (isAddToMoves)
		addMove(this->movesDictionary[_R]);
}
void Rubik::U(bool isAddToMoves) {
	shift(this->corners, 7, 6, 16, 9);
	shift(this->corners, 23, 22, 8, 1);
	shift(this->corners, 17, 15, 14, 0);
	shift(this->edges, 6, 12, 7, 4);
	shift(this->edges, 19, 16, 18, 0);

	if (isAddToMoves)
		addMove(this->movesDictionary[_U]);
}
void Rubik::Ui(bool isAddToMoves) {
	shift(this->corners, 9, 16, 6, 7);
	shift(this->corners, 1, 8, 22, 23);
	shift(this->corners, 0, 14, 15, 17);
	shift(this->edges, 4, 7, 12, 6);
	shift(this->edges, 0, 18, 16, 19);

	if (isAddToMoves)
		addMove(this->movesDictionary[_Ui]);
}
void Rubik::L(bool isAddToMoves) {
	shift(this->corners, 22, 4, 2, 16);
	shift(this->corners, 12, 10, 0, 6);
	shift(this->corners, 14, 20, 18, 8);
	shift(this->edges, 11, 8, 3, 6);
	shift(this->edges, 23, 20, 15, 18);

	if (isAddToMoves)
		addMove(this->movesDictionary[_L]);
}
void Rubik::Li(bool isAddToMoves) {
	shift(this->corners, 16, 2, 4, 22);
	shift(this->corners, 6, 0, 10, 12);
	shift(this->corners, 8, 18, 20, 14);
	shift(this->edges, 6, 3, 8, 11);
	shift(this->edges, 18, 15, 20, 23);

	if (isAddToMoves)
		addMove(this->movesDictionary[_Li]);
}
Exemple #18
0
void getUpFromGround(AI* ai)
{
    if (chance(GET_UP_ATTACK_PROB))
    {
        addMove(ai, &_mv_getUpAttack);
    }
    else
    {
        hitTech(ai);
    }
}
Exemple #19
0
/**
* Attempt to move the player as instructed
*
* @param dungeon A pointer to the dungeon
* @param move The move to make
*
* @return RESULT_WIN if the player has won the game
*         RESULT_DIE if the player has died in the game
*         INVALID_MOVE if the move is invalid
*         else 0
*/
int makeMove(Dungeon* dungeon, char move) {
    Object *player;
    int result=0;
    int len;

    if(!dungeon->moveList) {
        dungeon->moveList = malloc(EXTEND_MOVE*4+1);
        bzero(dungeon->moveList, EXTEND_MOVE*4+1);
    }

    len = cgc_strlen(dungeon->moveList);
    sprintf(&dungeon->moveList[len], "!H", (unsigned char) move);

    if(!(player = getObjectById(dungeon->start, PLAYER_NUM)))
        _terminate(OBJECT_NOT_FOUND_ERROR);

    if(move == dungeon->moveTypes.left) {
        player->direction->x = 0;
        if((result = moveLeft(dungeon, player)))
            return result;
        if((result = moveEnemies(dungeon, player->moves)))
            return result;
        sendCurrentDungeonView(dungeon->start);
        if((result = checkFloor(dungeon, player)))
            return result;
    } else if(move == dungeon->moveTypes.right) {
        player->direction->x = 0;
        if((result = moveRight(dungeon, player)))
            return result;
        if((result = moveEnemies(dungeon, player->moves)))
            return result;
        sendCurrentDungeonView(dungeon->start);
        if((result = checkFloor(dungeon, player)))
            return result;
    }
    else if(move == dungeon->moveTypes.jump)
        return jump(dungeon, player);
    else if (move == dungeon->moveTypes.jumpleft)
        return jumpLeft(dungeon, player);
    else if (move == dungeon->moveTypes.jumpright)
        return jumpRight(dungeon, player);
    else if (move == dungeon->moveTypes.wait) {
        addMove(dungeon, player, dungeon->moveTypes.wait);
        if((result = moveEnemies(dungeon, player->moves)))
            return result;
        sendCurrentDungeonView(dungeon->start);
        return 0;
    } else
        return INVALID_MOVE;

    return 0;

}
Exemple #20
0
/* Gets all moves of a certain king or knight */
void getDiscMoves(Board *brd, MoveList *list, int square) {

    int piece, toSquare, dir, j;

    piece = brd->piecesBySquare[square];

    for(j = 0; j < numOfDirections[piece]; j++) {
        dir = directionsOfPieces[piece][j];
        toSquare = square + dir;

        if(OnBoard(toSquare)) {

            if(brd->piecesBySquare[toSquare] != noPiece) {
                if( pieceCol[brd->piecesBySquare[toSquare]] == (brd->side ^ 1)) {
                    addMove(brd, square, toSquare, brd->piecesBySquare[toSquare], noPiece , 0, list);
                }
                continue;
            }
            addMove(brd, square, toSquare, noPiece, noPiece , 0, list);
        }
    }
}
PokemonEditorDialog::PokemonEditorDialog(MainEngineInterface *client) :
    ui(new Ui::PokemonEditorDialog), pokeModel(nullptr), movesModel(nullptr)
{
    ui->setupUi(this);

    for (int i = 0; i < LastLearning; i++) {
        ui->learningMethod->addItem(learningMethods[i]);
    }

    QCompleter *completer = new QCompleter(MoveInfo::Names(),this);
    completer->setCaseSensitivity(Qt::CaseInsensitive);
    completer->setCompletionMode(QCompleter::PopupCompletion);
    ui->newMove->setCompleter(completer);
    ui->newMove->installEventFilter(new KeyPressEater(this)); //Prevents Return from triggering the dialog

    setPokemon(client->trainerTeam()->team().poke(0).num());

    connect(ui->deletedMoves, SIGNAL(cellDoubleClicked(int,int)), SLOT(removeRow(int)));
    connect(ui->addedMoves, SIGNAL(cellDoubleClicked(int,int)), SLOT(removeRow(int)));
    connect(completer, SIGNAL(activated(QString)), SLOT(addMove()));
    connect(ui->newMove, SIGNAL(returnPressed()), SLOT(addMove()));
}
Exemple #22
0
void hitTech(AI* ai)
{
    addLogic(ai, &getOffGroundLogic);
    addLogic(ai, &resetOnHitLogic);
    addLogic(&cpuPlayer, &recoveryLogic);
    addLogic(&cpuPlayer, &onLedgeLogic);

    if (chance(HIT_TECH_PROB))
    {
        SET_TECH_DIR(getRandomTechDirection()); 
        addMove(ai, &_mv_tech);   
        addLogic(ai, &actAfterTechLogic);
    }
}
void Rubik::F2(bool isAddToMoves) {
	swap((Face**)this->corners, 3, 0);
	swap((Face**)this->corners, 2, 1);
	swap((Face**)this->corners, 8, 11);
	swap((Face**)this->corners, 10, 9);
	swap((Face**)this->corners, 18, 17);
	swap((Face**)this->corners, 19, 16);

	swap((Face**)this->edges, 2, 0);
	swap((Face**)this->edges, 3, 1);
	swap((Face**)this->edges, 15, 13);
	swap((Face**)this->edges, 14, 12);

	if (isAddToMoves)
		addMove(this->movesDictionary[_F2]);
}
void Rubik::R2(bool isAddToMoves) {
	swap((Face**)this->corners, 3, 15);
	swap((Face**)this->corners, 5, 9);
	swap((Face**)this->corners, 1, 21);
	swap((Face**)this->corners, 19, 7);
	swap((Face**)this->corners, 11, 23);
	swap((Face**)this->corners, 13, 17);

	swap((Face**)this->edges, 1, 22);
	swap((Face**)this->edges, 9, 7);
	swap((Face**)this->edges, 13, 10);
	swap((Face**)this->edges, 21, 19);

	if (isAddToMoves)
		addMove(this->movesDictionary[_R2]);
}
void Rubik::L2(bool isAddToMoves) {
	swap((Face**)this->corners, 22, 2);
	swap((Face**)this->corners, 4, 16);
	swap((Face**)this->corners, 12, 0);
	swap((Face**)this->corners, 10, 6);
	swap((Face**)this->corners, 14, 18);
	swap((Face**)this->corners, 20, 8);

	swap((Face**)this->edges, 11, 3);
	swap((Face**)this->edges, 8, 6);
	swap((Face**)this->edges, 23, 15);
	swap((Face**)this->edges, 20, 18);

	if (isAddToMoves)
		addMove(this->movesDictionary[_L2]);
}
Exemple #26
0
int main()
{
	int color = 1;
	int place;
	srand((unsigned)time(NULL));
	init_board();
	//expand_pattern3x3();
	for (;;) {
		print_board();
		printf("colorを1か2で入力してください\n");
		scanf("%d", &color);
		place = get_best_uct(color);
		addMove(place, color);
	}
	return 0;
}
void Rubik::U2(bool isAddToMoves) {
	swap((Face**)this->corners, 7, 16);
	swap((Face**)this->corners, 6, 9);
	swap((Face**)this->corners, 17, 14);
	swap((Face**)this->corners, 15, 0);
	swap((Face**)this->corners, 23, 8);
	swap((Face**)this->corners, 22, 1);

	swap((Face**)this->edges, 6, 7);
	swap((Face**)this->edges, 12, 4);
	swap((Face**)this->edges, 19, 18);
	swap((Face**)this->edges, 16, 0);

	if (isAddToMoves)
		addMove(this->movesDictionary[_U2]);
}
void Rubik::B2(bool isAddToMoves) {
	swap((Face**)this->corners, 13, 14);
	swap((Face**)this->corners, 4, 7);
	swap((Face**)this->corners, 23, 20);
	swap((Face**)this->corners, 5, 6);
	swap((Face**)this->corners, 15, 12);
	swap((Face**)this->corners, 21, 22);

	swap((Face**)this->edges, 10, 23);
	swap((Face**)this->edges, 5, 4);
	swap((Face**)this->edges, 22, 11);
	swap((Face**)this->edges, 17, 16);

	if (isAddToMoves)
		addMove(this->movesDictionary[_B2]);
}
void Rubik::D2(bool isAddToMoves){

	swap((Face**)this->corners, 3, 12);
	swap((Face**)this->corners, 11, 20);
	swap((Face**)this->corners, 19, 4);
	swap((Face**)this->corners, 2, 21);
	swap((Face**)this->corners, 18, 13);
	swap((Face**)this->corners, 10, 5);
	swap((Face**)this->edges, 2, 17);
	swap((Face**)this->edges, 21, 20);
	swap((Face**)this->edges, 14, 5);
	swap((Face**)this->edges, 9, 8);

	if (isAddToMoves)
		addMove(this->movesDictionary[_D2]);
}
Exemple #30
0
void
GestureRecognizer::detectMove(int x, int y, long int timeStamp)
{
    if (timeStamp - _lastMoveTS < _frequency)
        return;

    _lastMoveTS = timeStamp;
    int dx = x - _preX;
    int dy = y - _preY;

    if ((dx * dx + dy * dy) > _minDistance)
    {
        addMove(dx, dy);
        _preX = x;
        _preY = y;
        _path.push_back(Point(x, y));
    }
}