这就是我今天所做的小地图,使用了python 来做。
就是告诉你如何你在长大的门口想去这三个地方(图书馆,足球场,综合楼)往哪里走。by typing “go”+ “方向” you’ll easily get your destination.
def showInstructions():
print('''
长春大学
========
Commands:
go [direction]
''')
def showStatus():
print('---------------------------')
print('您现在在 ' + currentPlace)
# print an item if there is one
print("---------------------------")
destination = {
'正门': {
'north': '图书馆',
'east' : '综合楼',
'west' : '足球场'
},
'图书馆': {
'south': '正门'
},
'综合楼': {
'west': '正门'
},
'足球场': {
'east': '正门'
},
}
currentPlace = '正门'
showInstructions()
while True:
showStatus()
move = ''
while move == '':
move = input('>')
move = move.lower().split()
if move[0] == 'go':
if move[1] in destination[currentPlace]:
currentPlace = destination[currentPlace][move[1]]
else:
print('您不能往那儿走!!!')