CIS 554 Forth Assignment
Fall 2013, David Matuszek

Write a text-only version of the Lunar Lander game in Forth

Here is a Python version of the game. This version uses floating-point numbers, but you can approximate it using integers.

``````
altitude = 1000.0
velocity = 100.0  # Was: 0.0
fuel = 250.0      # Was: 1000.0

while True:
print "Altitude: ", altitude
print "Velocity: ", velocity
print "Fuel: ", fuel
fuel_to_burn = raw_input("How much Fuel would you like to burn? Specify in liters: ")
if fuel_to_burn == "":
fuel_to_burn = 0
fuel_to_burn = int(fuel_to_burn)
if fuel_to_burn > fuel:
fuel_to_burn = fuel
velocity += 1.6
velocity -= fuel_to_burn/2
altitude -= velocity
fuel -= fuel_to_burn
if altitude <= 0:
if velocity <= 10:
print "You have landed safely\n"
else:
print "You have crashed!\n"
impact_size = .1 * velocity
print "Your crater of impact is of size: ", impact_size
play_again = ""
play_again = raw_input("Would you like to play again? (Y for Yes, N for No): ")
if play_again == "Y" or play_again == "y":
altitude = 1000.0
velocity = 100.0  # Was: 0.0
fuel = 250.0      # Was: 1000.0
Submit your ` ``lander.fth `file to Canvas by 6am next Wednesday, October 30.