示例#1
0
    def testInitEarth(self) :
        myEarth = earth.earth()

        myEarth.initField(3, 2)

        # Check field was created randomly with manpower (damn!)
        logging.basicConfig()
        log = logging.getLogger("LOG")
        log.warning(myEarth.field)

        self.assertEqual(
            [ len(myEarth.field[0]), len(myEarth.field) ],
            [3, 2]
        )
示例#2
0
    def testGetAroundLifeCount(self) :
        # ★ ○ ×
        # × ○ ×
        # × ○ ★
        #
        # ★...test target, ○...living cell, ×...dead cell
        # expects -> 2, 2

        field = [
            [False, True,  False],
            [False, True,  False],
            [False, True,  False]
        ]
        myEarth = earth.earth(1, 1, field)

        self.assertEqual(
            [myEarth.getAroundLifeCount(0, 0), myEarth.getAroundLifeCount(2, 2)],
            [2, 2]
        )
示例#3
0
    def testLivingCellsNextTurn(self) :
        # If 2 or 3 living cells exist around living cell, the cell survive.
        # Otherwise, dead.
        #
        # [before]
        # ○ × ○
        # × ○ ○
        # × ○ ×
        #
        # [after]
        # × × ○
        # ○ × ○
        # × ○ ○

        field = [
            [True,  False, True],
            [False, True,  True],
            [False, True,  False]
        ]

        nextTurnField = [
            [False, False, True],
            [True,  False, True],
            [False, True,  True]
        ]

        myEarth = earth.earth(1, 1, field)
        myEarth.nextTurn()

        self.assertEqual(
            myEarth.step,
            2
        )
        self.assertEqual(
            myEarth.field,
            nextTurnField
        )
示例#4
0
    def testDeadCellsNextTurn(self) :
        # If 3 living cells exist around dead cell, birth living cell.
        # Otherwise, dead.
        #
        # [before]
        # × × ○
        # ○ × ○
        # × ○ ×
        #
        # [after]
        # × ○ ×
        # × × ○
        # × ○ ×

        field = [
            [False, False, True],
            [True,  False, True],
            [False, True,  False]
        ]

        nextTurnField = [
            [False, True,  False],
            [False, False, True],
            [False, True,  False]
        ]

        myEarth = earth.earth(1, 1, field)
        myEarth.nextTurn()

        self.assertEqual(
            myEarth.step,
            2
        )
        self.assertEqual(
            myEarth.field,
            nextTurnField
        )
示例#5
0
文件: spacey.py 项目: j2le/spacey
# Initialize the game engine
pygame.init()

# scenario
#scenario = "leo"
scenario = "launch"

# Set the height and width of the screen
screen = pygame.display.set_mode(game_constants.size)

#Loop until the user clicks the close button.
game = game(pygame, scenario)

# initialize earth
earth = earth()

# initialize vehicle state
vehicle = vehicle(scenario)

# initialize display
display = display(scenario, game)

# initialize truth
sim = sim()

# initialize flight computer
flight_computer = flight_computer()

# begin the loop for the game
while game.done == False:
示例#6
0
 def testSaveCurrent(self) :
     myEarth = earth.earth(1, 1, [[True, False], [False, True]])
     self.dao.saveCurrent
while True:
    try:

        def print_result():
            print('\nAnswer is: ')
            print(result)
            print('\n')

        import earth
        earth.earth()
        print("Hello")
        print("Choose an option to begin, or type 'quit' to exit\n")
        print("'calc' - Calculator")
        print("     - Basic Scientific Calculator\n")
        print("'pythag' - Pythagorean Thoerem")
        print("     - Right Triangle Hyoptenuse Calculator\n")
        print "'hang' - Hangman"
        print "     - Hangman Game with Random words\n"
        user_input = raw_input("Which option would you like to choose?: ")
        if user_input == "calc":
            while True:
                import calcimg
                ops = ['*', '+', '-', '/', '^']
                print("\nWelcome to the Calculator")
                calcimg.img()
                print("\n Enter a number, an operator, and another number")
                print(
                    "For python 2.7, you will require quotes around the operator"
                )
                print("Or enter 'quit' to exit")
                print(" '*' , '+' , '-' , '/' , '^' ")