Package com.wakaleo.gameoflife.domain

Examples of com.wakaleo.gameoflife.domain.Universe


    private Random randomGenerator = new Random();

    @RequestMapping("/new")
    public ModelAndView newGame() {
        ModelAndView mav = new ModelAndView("game/edit");
        Universe universe = new Universe();
        mav.addObject("universe", universe);
        thinkABit(250);
        return mav;
    }
View Full Code Here


    @RequestMapping("/start")
    public ModelAndView firstGeneration(@RequestParam("rows") final int rows,
                                        @RequestParam("columns") final int columns,
                                        final HttpServletRequest request) {

        Universe universe = universeInstanciatedFromClickedCells(rows, columns, request);
        thinkABit(200);

        return showGridScreen(universe);
    }
View Full Code Here

    @RequestMapping("/next")
    public ModelAndView nextGeneration(@RequestParam("rows") final int rows,
                                       @RequestParam("columns") final int columns,
                                       final HttpServletRequest request) {

        Universe universe = universeInstanciatedFromClickedCells(rows, columns,
                request);
        universe.createNextGeneration();

        thinkABit(250);

        return showGridScreen(universe);
    }
View Full Code Here

            e.printStackTrace();
        }
    }

    private Universe universeInstanciatedByDimensions(final int rows, final int columns) {
        Universe universe = new Universe(rows, columns);
        for (int row = 0; row < rows; row++) {
            for (int column = 0; column < columns; column++) {
                universe.setDeadCellAt(row, column);
            }
        }
        return universe;
    }
View Full Code Here

    }

    private Universe universeInstanciatedFromClickedCells(final int rows,
                                                          final int columns,
                                                          final HttpServletRequest request) {
        Universe universe = universeInstanciatedByDimensions(rows, columns);
        for (int row = 0; row < rows; row++) {
            for (int column = 0; column < columns; column++) {
                if (cellWasClickedAt(row, column, request)) {
                    universe.setLiveCellAt(row, column);
                }
            }
        }
        return universe;
    }
View Full Code Here

        String expectedNextGrid = "..." + NEW_LINE +
                "..." + NEW_LINE +
                "..." + NEW_LINE + "";

        Universe theUniverse = new Universe(seededWith(initialGrid));
        theUniverse.createNextGeneration();

        String nextGrid = theUniverse.getGrid();
        assertThat(nextGrid, is(expectedNextGrid));
    }
View Full Code Here

        String expectedNextGrid = "..." + NEW_LINE +
                "..." + NEW_LINE +
                "..." + NEW_LINE + "";

        Universe theUniverse = new Universe(seededWith(initialGrid));
        theUniverse.createNextGeneration();

        String nextGrid = theUniverse.getGrid();
        assertThat(nextGrid, is(expectedNextGrid));
    }
View Full Code Here

        String expectedNextGrid = "**." + NEW_LINE +
                "**." + NEW_LINE +
                "..." + NEW_LINE + "";

        Universe theUniverse = new Universe(seededWith(initialGrid));
        theUniverse.createNextGeneration();

        String nextGrid = theUniverse.getGrid();
        assertThat(nextGrid, is(expectedNextGrid));
    }
View Full Code Here

        String expectedNextGrid = ".*." + NEW_LINE +
                ".*." + NEW_LINE +
                ".*." + NEW_LINE + "";

        Universe theUniverse = new Universe(seededWith(initialGrid));
        theUniverse.createNextGeneration();

        String nextGrid = theUniverse.getGrid();
        assertThat(nextGrid, is(expectedNextGrid));
    }
View Full Code Here

        String expectedNextGrid = "..." + NEW_LINE +
                "..." + NEW_LINE +
                "..." + NEW_LINE + "";

        Universe theUniverse = new Universe(seededWith(initialGrid));
        theUniverse.createNextGeneration();

        String nextGrid = theUniverse.getGrid();
        assertThat(nextGrid, is(expectedNextGrid));
    }
View Full Code Here

TOP

Related Classes of com.wakaleo.gameoflife.domain.Universe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.