Example #1
0
    virtual void grid(GridBase<Cell, 3> *ret)
    {
        CoordBox<3> box = ret->boundingBox();
        Coord<3> offset =
            Coord<3>::diagonal(gridDimensions().x() * 5 / 128);
        int size = gridDimensions().x() * 50 / 128;


        for (int z = 0; z < size; ++z) {
            for (int y = 0; y < size; ++y) {
                for (int x = 0; x < size; ++x) {
                    Coord<3> c = offset + Coord<3>(x, y, z);
                    if (box.inBounds(c)) {
                        ret->set(c, Cell(0.99999999999));
                    }
                }
            }
        }
    }
Example #2
0
    virtual void grid(GridBase<BushFireCell, 2> *ret)
    {
        Random::seed(4711);
        CoordBox<2> box = ret->boundingBox();
        Grid<double> humidityGrid = createUnwarpedPlasmaField(gridDimensions(), 0.5);
        Grid<double> fuelGrid = createUnwarpedPlasmaField(gridDimensions(), 0.01);

        for (CoordBox<2>::Iterator i = box.begin(); i != box.end(); ++i) {
            ret->set(*i, BushFireCell(humidityGrid[*i], 1.0 + fuelGrid[*i]));
        }

        CoordBox<2> seatOfFire(Coord<2>(100, 100), Coord<2>(10, 10));

        for (CoordBox<2>::Iterator i = seatOfFire.begin(); i != seatOfFire.end(); ++i) {
            if (box.inBounds(*i)) {
                ret->set(*i, BushFireCell(0, 10.0, 200.0, BushFireCell::BURNING));
            }
        }
    }
Example #3
0
    virtual void grid(GridBase<ConwayCell, 2> *ret)
    {
        CoordBox<2> rect = ret->boundingBox();
        std::vector<Coord<2> > startCells;
        // start with a single glider...
        //          x
        //           x
        //         xxx
        startCells +=
            Coord<2>(11, 10),
            Coord<2>(12, 11),
            Coord<2>(10, 12), Coord<2>(11, 12), Coord<2>(12, 12);


        // ...add a Diehard pattern...
        //                x
        //          xx
        //           x   xxx
        startCells +=
            Coord<2>(55, 70), Coord<2>(56, 70), Coord<2>(56, 71),
            Coord<2>(60, 71), Coord<2>(61, 71), Coord<2>(62, 71),
            Coord<2>(61, 69);

        // ...and an Acorn pattern:
        //        x
        //          x
        //       xx  xxx
        startCells +=
            Coord<2>(111, 30),
            Coord<2>(113, 31),
            Coord<2>(110, 32), Coord<2>(111, 32),
            Coord<2>(113, 32), Coord<2>(114, 32), Coord<2>(115, 32);


        for (std::vector<Coord<2> >::iterator i = startCells.begin();
             i != startCells.end();
             ++i) {
            if (rect.inBounds(*i)) {
                ret->set(*i, ConwayCell(true));
            }
        }
    }
Example #4
0
    virtual void grid(GridBase<CircleCell, 2> *ret)
    {
        CoordBox<2> rect = ret->boundingBox();
        std::vector<std::pair<Coord<2>, CircleCell> > seeds(3);
        seeds[0] = std::make_pair(
            Coord<2>(1 * gridDimensions().x() / 4,
                     2 * gridDimensions().y() / 3),
            CircleCell(std::make_pair(0.5, 0.5), 0.2));
        seeds[0] = std::make_pair(
            Coord<2>(3 * gridDimensions().x() / 4,
                     2 * gridDimensions().y() / 3),
            CircleCell(std::make_pair(0.5, 0.5), 0.2));
        seeds[0] = std::make_pair(
            Coord<2>(1 * gridDimensions().x() / 2,
                     1 * gridDimensions().y() / 3),
            CircleCell(std::make_pair(0.5, 0.5), 0.4));

        for (std::vector<std::pair<Coord<2>, CircleCell> >::iterator i =
                 seeds.begin(); i != seeds.end(); ++i) {
            if (rect.inBounds(i->first)) {
                ret->set(i->first, i->second);
            }
        }
    }