예제 #1
0
bool sBus::load_cart() {
  if(cartridge.loaded() == true) return false;

  map_reset();
  map_generic();
  map_system();
  return true;
}
예제 #2
0
파일: main.c 프로젝트: woaks223/Tetris
void main() {
	char choice;
	setcursortype(NOCURSOR);
	choice = start();
	_beginthread(auto_down_blcok, 0, 0);
	if (choice == '1') {
		map_reset();
		while (1) {
			map();
			if (new_block_on == 1) new_block();
			key_ent();

		}
	}
	else {
		exit(1);
	}
	return;
}
예제 #3
0
int main(int argc, char *argv[]) {
    init_log();
    attackradius2 = 5;
    viewradius2 = 55;
    // puts(aroma_to_string());
    // printf("%f %f %f %f\n", aroma[0][0], aroma[0][1], aroma[0][2], aroma[0][3]);

    map_load_from_string(".%*%");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_stabilize();
    // puts(aroma_to_string());
    assert(aroma[0][0] == 0);
    assert(army_aroma[0][0] == 0);

    map_load_from_string("..*%");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_stabilize();
    // puts(aroma_to_string());
    assert(aroma[0][0] > 0);
    assert(army_aroma[0][0] == 0);

    map_load_from_string(".%*.");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_stabilize();
    // puts(aroma_to_string());
    assert(aroma[0][0] > 0);
    assert(army_aroma[0][0] == 0);

    // map_load_from_string(".%?%");
    // holy_ground_calculate();
    // threat_calculate();
    // mystery_reset();
    // aroma_stabilize();
    // assert(aroma[0][0] == 0);
    // 
    // map_load_from_string("..?%");
    // holy_ground_calculate();
    // threat_calculate();
    // mystery_reset();
    // aroma_stabilize();
    // puts(aroma_to_string());
    // assert(aroma[0][0] > 0);

    map_load_from_string(".%...%*%\n"
                         "...%...%\n"
                         "%%%%%%%%");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_stabilize();
    // puts(aroma_to_string());
    assert(aroma[0][0] > 0);
    assert(aroma[0][1] == 0);
    assert(aroma[0][2] > aroma[0][0]);
    assert(aroma[0][3] > aroma[0][2]);
    assert(aroma[0][4] > aroma[0][3]);
    assert(aroma[0][5] == 0);

    map_load_from_string("*1");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_reset();
    aroma_iterate(1);
    // puts(aroma_to_string());
    assert(aroma[0][0] == AROMA_FOOD);
    assert(aroma[0][1] == AROMA_ENEMY_HILL);

    map_load_from_string("0.............bb............................");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_reset();
    aroma_iterate(1);
    // puts(aroma_to_string());
    // puts(army_aroma_to_string());
    // printf("%f %f %f %f\n", aroma[0][11], aroma[0][12], aroma[0][13], aroma[0][14]);
    assert(aroma[0][13] == 0.0);
    assert(aroma[0][14] == AROMA_INTRUDER);
    assert(aroma[0][15] == 0.0);
    assert(aroma[0][16] == 0.0);
    assert(army_aroma[0][13] == 0.0);
    assert(army_aroma[0][14] == AROMA_INTRUDER);
    assert(army_aroma[0][15] == AROMA_ENEMY);
    assert(army_aroma[0][16] == 0.0);

    map_load_from_string("?.");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_reset();
    aroma_iterate(1);
    // puts(aroma_to_string());
    assert(aroma[0][0] >= AROMA_MYSTERY * MYSTERY_INITIAL / MYSTERY_MAX - 0.00001);
    assert(aroma[0][0] <= AROMA_MYSTERY * MYSTERY_INITIAL / MYSTERY_MAX + 0.00001);
    mystery[0][0] = MYSTERY_MAX;
    aroma_reset();
    aroma_iterate(1);
    assert(aroma[0][0] == AROMA_MYSTERY);

    map_load_from_string("..................\n"
                         "..................\n"
                         "..................\n"
                         "..................\n"
                         "..a...b...........\n"
                         "..................\n"
                         "..................\n"
                         "..................\n"
                         "..................\n"
                         "..................\n"
                         "..................");
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_reset();
    aroma_iterate(1);
    // puts(aroma_to_string());
    // puts(army_aroma_to_string());
    // printf("%f %f %f %f %f\n", aroma[4][2], aroma[4][3], aroma[5][2], aroma[3][2], aroma[4][1]);
    assert(aroma[4][3] == 0);

    // map_load_from_string("..................\n"
    //                      "aa................\n"
    //                      "..................\n"
    //                      "..................\n"
    //                      "..a...b...........\n"
    //                      "..................\n"
    //                      "..................\n"
    //                      "..................\n"
    //                      "..................\n"
    //                      "..................\n"
    //                      "..................");
    rows = 20;
    cols = 50;
    map_reset();
    map_begin_update();
    map_see_ant((point){5, 0}, 0);
    map_see_ant((point){5, 4}, 1);
    map_finish_update();
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_reset();
    aroma_iterate(1);
    // printf("%f %f %f %f %f\n", aroma[4][2], aroma[4][3], aroma[5][2], aroma[3][2], aroma[4][1]);
    assert(aroma[5][1] == 0);

    map_begin_update();
    map_see_ant((point){0, 0}, 0);
    map_see_ant((point){0, 1}, 0);
    map_see_ant((point){5, 0}, 0);
    map_see_ant((point){5, 4}, 1);
    map_finish_update();
    holy_ground_calculate();
    threat_calculate();
    mystery_reset();
    aroma_reset();
    aroma_iterate(1);
    assert(aroma[5][1] == AROMA_CONFLICT);

    puts("ok");
    return 0;
}
예제 #4
0
rt_public EIF_REFERENCE edclone(EIF_CONTEXT EIF_REFERENCE source)
{
    /* Recursive Eiffel clone. This function recursively clones the source
     * object and returns a pointer to the top of the new tree.
     */
    RT_GET_CONTEXT
    EIF_GET_CONTEXT
    EIF_REFERENCE root = (EIF_REFERENCE)  0;		/* Root of the deep cloned object */
    jmp_buf exenv;					/* Environment saving */
    struct {
        union overhead discard;		/* Pseudo object header */
        EIF_REFERENCE boot;					/* Anchor point for cloning process */
    } anchor;
    struct rt_traversal_context traversal_context;
    int volatile is_locked;

#ifdef DEBUG
    int xobjs;
#endif

    if (source == NULL) {
        return NULL;			/* Void source */
    }

    /* The deep clone of the source will be attached in the 'boot' entry from
     * the anchor structure. It all happens as if we were in fact deep cloning
     * the anchor pseudo-object.
     */

    memset (&anchor, 0, sizeof(anchor));	/* Reset header */
    anchor.boot = (EIF_REFERENCE)  &root;	/* To boostrap cloning process */

    RT_GC_PROTECT(source);	/* Protect source: allocation will occur */

#ifdef DEBUG
    xobjs = nomark(source);
    printf("Source has %x %d objects\n", source, xobjs);
#endif

    /* Set up an exception trap. If any exception occurs, control will be
     * transferred back here by the run-time to give us a chance to clean-up
     * our structures.
     */

    {
        RTXDRH;							/* Save stack contexts */
        EIF_EO_STORE_LOCK;				/* Because we perform a traversal that marks
										   objects, we need to be sure we are the
										   only one doing it. */
        is_locked = 1;

        excatch(&exenv);		/* Record pseudo-execution vector */
        if (setjmp(exenv)) {
            RTXSCH;						/* Restore stack contexts */
            map_reset(1);				/* Reset in emergency situation */
            /* If we locked the EO_STORE_MUTEX, then we need to unmark objects
             * and unlock it. */
            if (is_locked) {
                /* We are only concerned abount unmarking objects, so we do not perform any
                 * accounting. */
                CHECK ("Not accounting", traversal_context.accounting == 0);
                CHECK ("Not unmarking", traversal_context.is_unmarking == 0);
                /* First we mark again all objects. */
                traversal_context.is_unmarking = 0;
                traversal(&traversal_context, source);
                /* Then we unmark them. */
                traversal_context.is_unmarking = 1;
                traversal(&traversal_context, source);
                /* Now we can unlock our mutex. */
                EIF_EO_STORE_UNLOCK;
            }
            ereturn(MTC_NOARG);					/* And propagate the exception */
        }

        /* Now start the traversal of the source, allocating all the objects as
         * needed and stuffing them into a FIFO stack for later perusal by the
         * cloning process.
         */

        memset (&traversal_context, 0, sizeof(struct rt_traversal_context));
        traversal_context.accounting = TR_MAP;
        traversal(&traversal_context, source);		/* Object traversal, mark with EO_STORE */
        hash_malloc(&hclone, traversal_context.obj_nb);	/* Hash table allocation */
        map_start();					/* Restart at bottom of FIFO stack */

#ifdef DEBUG
        printf("Computed %x %d objects\n\n", source, traversal_context.obj_nb);
#endif

        /* Throughout the deep cloning process, we need to maintain the notion of
         * enclosing object for GC aging tests. The enclosing object is defined as
         * being the object to which the currently cloned tree will be attached.
         *
         * We need to initialize the cloning process by computing a valid reference
         * into the root variable. That will be the enclosing object, and of course
         * it cannot be void, ever, or something really really weird is happening.
         *
         * To get rid of code duplication, I am initially calling rdeepclone with
         * an enclosing object address set to anchor.boot. The anchor structure
         * represents a pseudo anchor object for the object hierarchy being cloned.
         */

        rdeepclone(source, (EIF_REFERENCE) &anchor.boot, 0);	/* Recursive clone */
        hash_free(&hclone);						/* Free hash table */
        map_reset(0);							/* And eif_free maping table */
        /* Release all the hector pointers asked for during the map table
         * construction (obj_nb exactly) */
        CHECK("Has objects", traversal_context.obj_nb > 0);
        eif_ostack_npop(&hec_stack, traversal_context.obj_nb);

#ifdef DEBUG
        xobjs= nomark(source);
        printf("Source now has %d objects\n", xobjs);
        xobjs = nomark(anchor.boot);
        printf("Result has %d objects\n", xobjs);
#endif

        RT_GC_WEAN(source);			/* Release GC protection */
        expop(&eif_stack);			/* Remove pseudo execution vector */
    }

    EIF_EO_STORE_UNLOCK;		/* Free marking mutex */
    is_locked = 0;

    return anchor.boot;			/* The cloned object tree */
}