Package barsuift.simLife.universe

Examples of barsuift.simLife.universe.MockUniverse


    public void testCanCreateOneNewLeaf() {
        BasicTreeBranchPart part;
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setEnergy(new BigDecimal(89));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertFalse(part.canCreateOneNewLeaf());

        partState.setEnergy(new BigDecimal(150));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertTrue(part.canCreateOneNewLeaf());

        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>();
        leaveStates.add(new TreeLeafState());
        leaveStates.add(new TreeLeafState());
        leaveStates.add(new TreeLeafState());
        partState.setLeaveStates(leaveStates);
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertTrue(part.canCreateOneNewLeaf());

        leaveStates.add(new TreeLeafState());
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertFalse(part.canCreateOneNewLeaf());
    }
View Full Code Here


    public void testShouldCreateOneNewLeaf() {
        BasicTreeBranchPart part;
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setEnergy(new BigDecimal(89));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertFalse(part.shouldCreateOneNewLeaf());

        // 90 = 90 + (0% * 90)
        // so we should have 0% odd to create a new leaf
        partState.setEnergy(new BigDecimal(90));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        int sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldCreateOneNewLeaf();
            sum += (result ? 1 : 0);
        }
        assertEquals(0, sum);


        // 153 = 90 + (70% * 90)
        // so we should have 70% odd to create a new leaf
        partState.setEnergy(new BigDecimal(153));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldCreateOneNewLeaf();
            sum += (result ? 1 : 0);
        }
        assertTrue(sum > 650);
        assertTrue(sum < 750);

        // 180 = 90 + (100% * 90)
        // so we should have 100% odd to create a new leaf
        partState.setEnergy(new BigDecimal(180));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldCreateOneNewLeaf();
            sum += (result ? 1 : 0);
        }
        assertEquals(1000, sum);

        // 250 > 90 + (100% * 90)
        // so we should have 100% odd to create a new leaf
        partState.setEnergy(new BigDecimal(250));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldCreateOneNewLeaf();
            sum += (result ? 1 : 0);
        }
View Full Code Here

    public void testCanIncreaseOneLeafSize() {
        BasicTreeBranchPart part;
        TreeBranchPartState partState = CoreDataCreatorForTests.createSpecificTreeBranchPartState();
        partState.setEnergy(new BigDecimal(19));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertFalse(part.canIncreaseOneLeafSize());

        partState.setEnergy(new BigDecimal(20));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertTrue(part.canIncreaseOneLeafSize());

        // set all the leaves at their maximum size, so that they can not be increased anymore
        for (TreeLeafState leafState : partState.getLeaveStates()) {
            TreeLeaf3DState leaf3dState = leafState.getLeaf3DState();
            Point3dState initialEndPoint1 = leaf3dState.getInitialEndPoint1();
            leaf3dState.setEndPoint1(new Point3dState(initialEndPoint1.getX() * 10, initialEndPoint1.getY() * 10,
                    initialEndPoint1.getZ() * 10));
            Point3dState initialEndPoint2 = leaf3dState.getInitialEndPoint2();
            leaf3dState.setEndPoint2(new Point3dState(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10,
                    initialEndPoint2.getZ() * 10));
        }
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertFalse(part.canIncreaseOneLeafSize());

        // reset the end point 1 of leaf 1, so that it can be increased again
        partState.getLeaveStates().get(0).getLeaf3DState().setEndPoint1(
                partState.getLeaveStates().get(0).getLeaf3DState().getInitialEndPoint1());
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertTrue(part.canIncreaseOneLeafSize());
    }
View Full Code Here

    public void testShouldIncreaseOneLeafSize() {
        BasicTreeBranchPart part;
        TreeBranchPartState partState = CoreDataCreatorForTests.createSpecificTreeBranchPartState();
        partState.setEnergy(new BigDecimal(19));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertFalse(part.shouldIncreaseOneLeafSize());

        // 20 = 20 + (0% * 80)
        // so we should have 0% odd to create a new leaf
        partState.setEnergy(new BigDecimal(20));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        int sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldIncreaseOneLeafSize();
            sum += (result ? 1 : 0);
        }
        assertEquals(0, sum);


        // 76 = 20 + (70% * 80)
        // so we should have 70% odd to create a new leaf
        partState.setEnergy(new BigDecimal(76));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldIncreaseOneLeafSize();
            sum += (result ? 1 : 0);
        }
        assertTrue(sum > 650);
        assertTrue(sum < 750);

        // 100 = 20 + (100% * 80)
        // so we should have 100% odd to create a new leaf
        partState.setEnergy(new BigDecimal(100));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldIncreaseOneLeafSize();
            sum += (result ? 1 : 0);
        }
        assertEquals(1000, sum);

        // 250 > 20 + (100% * 80)
        // so we should have 100% odd to create a new leaf
        partState.setEnergy(new BigDecimal(250));
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        sum = 0;
        for (int i = 0; i < 1000; i++) {
            boolean result = part.shouldIncreaseOneLeafSize();
            sum += (result ? 1 : 0);
        }
View Full Code Here

            leaf3dState.setEndPoint2(new Point3dState(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10,
                    initialEndPoint2.getZ() * 10));
        }
        // set the first leaf end point to (0,0,0) so that it can be increased
        firstLeafState.getLeaf3DState().setEndPoint1(new Point3dState());
        BasicTreeBranchPart part = new BasicTreeBranchPart(new MockUniverse(), branchPartState);

        part.increaseOneLeafSize();


        PointTestHelper.assertPointEquals(firstInitialEndPoint1, part.getLeaves().get(0).getTreeLeaf3D().getState()
View Full Code Here

        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        leaveStates.add(leaf3);
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        BasicTreeBranchPart part = new BasicTreeBranchPart(new MockUniverse(), partState);
        // area1 = 2
        // area2 = 4
        // area3 = 6
        // sum (area) = 12
        // diffArea1 = 12 - 2 = 10
View Full Code Here

        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        leaveStates.add(leaf3);
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        BasicTreeBranchPart part = new BasicTreeBranchPart(new MockUniverse(), partState);
        // area1 = 2 (not taken into account, because leaf is already at its maximum size)
        // area2 = 4
        // area3 = 6
        // sum (area) = 10
        // diffArea2 = 10 - 4 = 6
View Full Code Here

        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        leaveStates.add(leaf3);
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        BasicTreeBranchPart part = new BasicTreeBranchPart(new MockUniverse(), partState);
        // area1 = 2 (not taken into account, because leaf is already at its maximum size)
        // area2 = 4 (not taken into account, because leaf is already at its maximum size)
        // area3 = 6
        // sum (area) = 6
        // diffArea3 = 6 - 6 = 0
View Full Code Here

        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        leaveStates.add(leaf3);
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        BasicTreeBranchPart part = new BasicTreeBranchPart(new MockUniverse(), partState);
        // area1 = 0
        // area2 = 4
        // area3 = 6
        // sum (area) = 10
        // diffArea1 = 10 - 0 = 10
View Full Code Here

        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>(2);
        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        BasicTreeBranchPart part = new BasicTreeBranchPart(new MockUniverse(), partState);
        // area1 = 0
        // area2 = 4
        // sum (area) = 4
        // diffArea1 = 4 - 0 = 4
        // diffArea2 = 4 - 4 = 0
View Full Code Here

TOP

Related Classes of barsuift.simLife.universe.MockUniverse

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.