Exemple #1
0
std::auto_ptr<ElementoLexico> ProwlLexer::getSigElemento()
{
    std::string token;
    std::auto_ptr<ElementoLexico> toret( GeneralLexer::getSigElemento() );

    if ( dynamic_cast<NoIdentificado *>( toret.get() ) != NULL ) {
        unsigned int linea = toret->getLinea();
        unsigned int columna = toret->getColumna();

        if ( Operadores.find( getCaracterActual() ) != std::string::npos ) {
            token.push_back( getCaracterActual() );
            toret.reset( new Operador( token, linea, columna ) );

            avanzar();
        }
        else
        if ( chkSig( Begin ) ) {
            toret.reset( new AperturaDeBloque( linea, columna ) );
            avanzar( Begin.length() );
        }
        else
        if ( chkSig( End ) ) {
            toret.reset( new CierreDeBloque( linea, columna ) );
            avanzar( End.length() );
        }
    }

    return toret;
}
Exemple #2
0
void Magnetman::actualizar(real deltaT)
{
	#ifndef compiling_server
	avanzar(deltaT);
	#endif
	actualizarMaquinaEstados(deltaT);
	Enemigo::actualizar(deltaT);
}
Exemple #3
0
int main(int argc, char ** argv)
{
	FILE *fp;
	int _pid,_hl,_dr,_pr,_tk;//, m;
	//thread t;
	thread * pt;
	fp = fopen(argv[1], "r");
	if(fp == NULL) {
		printf("No se pudo abrir el archivo\n");
		exit(0);
	}
	highest = 0;
	while (fscanf(fp, "%d %d %d %d %d\n", &_pid,&_hl,&_dr,&_pr,&_tk) == 5) {
		pt = (thread*)malloc(sizeof(thread));
		pt->PID = _pid;
		pt->HL = _hl;
		pt->DR = _dr;
		pt->PR = _pr;
		pt->TK = _tk;
		tt+=_dr;
		if(_tk > highest) highest = _tk;
		procesos.vector[procesos.pos++] = pt;
	}
	int s = 0;
	for(s = 0; s<tt + 1024; s++) {
		avanzar(s);
		correr(s);
	}
	FILE * fs = fopen(argv[2], "wb+");
	DFIFO.diagrama[DFIFO.pos++] = '\0';
	DRR_2.diagrama[DRR_2.pos++] = '\0';
	DRR_3.diagrama[DRR_3.pos++] = '\0';
	DSJF_NE.diagrama[DSJF_NE.pos++] = '\0';
	DSJF_EX.diagrama[DSJF_EX.pos++] = '\0';
	DHPF_EX.diagrama[DHPF_EX.pos++] = '\0';
	DHPF_NE.diagrama[DHPF_NE.pos++] = '\0';
	DLTS.diagrama[DLTS.pos++] = '\0';
	fprintf(fs," FIFO: %s\n",DFIFO.diagrama);
	fprintf(fs," RR2: %s\n",DRR_2.diagrama);
	fprintf(fs," RR3: %s\n",DRR_3.diagrama);
	fprintf(fs," SJF_NE: %s\n",DSJF_NE.diagrama);
	fprintf(fs," SJF_EX: %s\n",DSJF_EX.diagrama);
	fprintf(fs," HPF_EX: %s\n",DHPF_EX.diagrama);
	fprintf(fs," HPF_NE: %s\n",DHPF_NE.diagrama);
	fprintf(fs," Lottery: %s\n",DLTS.diagrama);
	fclose(fp);	
	fclose(fs);
	return 0;
}
Exemple #4
0
DWORD WINAPI fnCoches(LPVOID parametro)
{
	int posicion, carril, color, sum;
	int velocidad, tcarril;

	srand((unsigned int)time(NULL));

	do
	{
		carril = randgen(0, 1);
		sum = carril * 137;
		posicion = randgen(0, 136);
	} while (cruce(posicion, carril) || WaitForSingleObject(IPC.posiciones[posicion + sum], 0) != WAIT_OBJECT_0);

	velocidad = randgen(1, 99);
	color = randgen(0, 7);

	/*Situamos el coche en la posicion y carril calculadas arriba*/
	DLL.inicio_coche(&carril, &posicion, color);

	/*Avisamos que nos hemos creado*/
	SetEvent(IPC.evento_creacion);
	WaitForSingleObject(IPC.semaforo_pistoletazo, INFINITE); //Esperamos por el pistoletazo

	while (1)
	{
		/*Garantizamos que  estando en estas posiciones avanzo o espero que el semaforo cambie*/
		if ((posicion == 20 && carril == 0) || (posicion == 22 && carril == 1))
			WaitForSingleObject(IPC.posiciones[274], INFINITE);
		if ((posicion == 105 && carril == 0) || (posicion == 98 && carril == 1))
			WaitForSingleObject(IPC.posiciones[275], INFINITE);

		tcarril = carril;

		avanzar(&posicion, &carril, color);

		/*Incremento el contador de vueltas si estoy en estas posiciones y no cambio de carril*/
		if (((posicion == 133 && carril == 0) || (posicion == 131 && carril == 1)) && tcarril == carril)
			InterlockedIncrement((long*)(parametro));

		/*Si he cogio los mutex de arriba los libero para que el semaforo pueda cambiar de color*/
		ReleaseMutex(IPC.posiciones[274]);
		ReleaseMutex(IPC.posiciones[275]);

		DLL.velocidad(velocidad, carril, posicion);
	}

	return 1;
}
void processStateSolving(Scope *pScope)
{
	pScope->heroe.x = pScope->laberinto.entradaX;
	pScope->heroe.y = pScope->laberinto.entradaY;
	pScope->heroe.orientacion = SUR;
	char casillero = '\0';

	while(casillero != 'O' && casillero != 'I')
	{
		casillero = mirarALaDerecha(pScope);

		if(casillero == 'X')
		{
			casillero = mirarAdelante(pScope);
			if(casillero == 'X')
			{
				casillero = mirarALaIzquierda(pScope);
				if(casillero == 'X')
				{
					girarAciaAtras(&pScope->heroe);
				}else if(casillero == ' ' || casillero == 'O' || casillero == 'I')
				{
					girarALaIzquierda(&pScope->heroe);
				}
			}
		}else if(casillero == ' ' || casillero == 'O' || casillero == 'I')
		{
			girarALaDerecha(&pScope->heroe);
		}

		avanzar(&pScope->heroe);
		mostrarLaberinto(pScope);
		putCasilleroXYScreen(pScope->heroe.x, pScope->heroe.y, '@', pScope);
		flushScreen(pScope);
		delay(pScope->config.delay);
	}
	if(casillero == 'I')
	{
		printf("El robot volvió al punto de partida sin encontrar la salida. El laberinto no tiene solución\n");
		clearKeyboardBuffer();
	}
	passToStateMenu(pScope);
}
Exemple #6
0
// Intenta moverse en una direccion
int intentar(paso_t ** S, char D) {
	int c;

	c = camino(*S, D);
	// Encontramos la salida
	if(c == SALIDA) {
		printf("Encontramos la salida!\n");
	}
	// El camino esta cerrado
	else if (c == CERRADO) {
		cerrar(*S, D);	// Si no se puede seguir, cerramos
		printf("Intento hacia %c, camino cerrado.\n", D);
	}
	// Se puede continuar
	else {
		cerrar(*S, D);
		avanzar(S, nodo());
		cerrar(*S, opuesto(D));
		printf("Avanzando hacia %c...\n", D);
	}

	return c;
}
Exemple #7
0
// Soluciona la mazmorra
int solucion(void) {
	int i;
	paso_t * L = NULL; 
	paso_t * p = NULL;

	// Agrego paso inicial, ingresando al laberinto hacia el norte
	p = nodo();
	cerrar(p, 'S');
	avanzar(&L,p);

	// Ciclo hasta salir del laberinto
	do {
		usleep(PAUSA);
		if(L==NULL) {
			printf("Volvimos a la entrada, el laberinto no tiene salida!\n");
			exit(1);
		}
		if(L->N == ABIERTO) {
			i=intentar(&L,'N');
		}
		else if (L->S == ABIERTO) {
			i=intentar(&L,'S');	
		}
		else if (L->O == ABIERTO) {
			i=intentar(&L, 'O');
		}
		else if (L->E == ABIERTO) {
			i=intentar(&L, 'E');
		}
		else {
			printf("No se puede avanzar, retrocediendo un paso...\n");
			retroceder(&L);
		}
	} while (i!=SALIDA);
	return 0;
}
Exemple #8
0
void ProwlLexer::pasarFinInstr()
{
    if ( getCaracterActual() != OperadorFinInstruccion[ 0 ] )
            throw Zero::ESintaxis( "se esperaba ';'" );
    else    avanzar();
}