python_1

本文介绍了一个简单的文本游戏——猎杀恶龙的Python实现。玩家需要在一个由20个洞穴组成的环境中寻找并捕获恶龙。游戏通过随机生成恶龙的位置及玩家的起始位置来增加趣味性。玩家每次行动后会得到关于恶龙位置的提示,直至找到恶龙。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

from random import  choice

cave_numbers = range(1, 21)
ww_location = choice(cave_numbers)
# print('ww_location',ww_location)
player_location = choice(cave_numbers)
# print('player_location',player_location)

while player_location == ww_location:
    player_location = choice(cave_numbers)
    
print 'welcome to hunt the ww'
print 'cave len', len(cave_numbers)
while True:
    print"player location", player_location
    if (player_location == ww_location-1 or player_location == ww_location+1):
        print "ww next player '"
    player_input = raw_input(">")
    if (not player_input.isdigit() or 
        int (player_input)  not in cave_numbers):
        print player_input, "is not a cave"
        
    else:
            player_location = int (player_input)
            if player_location == ww_location:
              print player_location,"you got ww"
              break

# the CMake variable PYTHON_INSTALL_DIR has the same value as the Python function catkin.builder.get_python_install_dir() set(PYTHON_VERSION "$ENV{ROS_PYTHON_VERSION}" CACHE STRING "Specify specific Python version to use ('major.minor' or 'major')") find_package(PythonInterp ${PYTHON_VERSION} REQUIRED) message(STATUS "Using PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") set(_PYTHON_PATH_VERSION_SUFFIX "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") set(enable_setuptools_deb_layout OFF) if(EXISTS "/etc/debian_version") set(enable_setuptools_deb_layout ON) endif() option(SETUPTOOLS_DEB_LAYOUT "Enable debian style python package layout" ${enable_setuptools_deb_layout}) if(SETUPTOOLS_DEB_LAYOUT) message(STATUS "Using Debian Python package layout") set(PYTHON_PACKAGES_DIR dist-packages) set(SETUPTOOLS_ARG_EXTRA "--install-layout=deb") # use major version only when installing 3.x with debian layout if("${PYTHON_VERSION_MAJOR}" STREQUAL "3") set(_PYTHON_PATH_VERSION_SUFFIX "${PYTHON_VERSION_MAJOR}") endif() else() message(STATUS "Using default Python package layout") set(PYTHON_PACKAGES_DIR site-packages) # setuptools is fussy about windows paths, make sure the install prefix is in native format file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" SETUPTOOLS_INSTALL_PREFIX) endif() if(NOT WIN32) set(PYTHON_INSTALL_DIR lib/python${_PYTHON_PATH_VERSION_SUFFIX}/${PYTHON_PACKAGES_DIR} CACHE INTERNAL "This needs to be in PYTHONPATH when 'setup.py install' is called. And it needs to match. But setuptools won't tell us where it will install things.") else() # Windows setuptools installs to lib/site-packages not lib/python2.7/site-packages set(PYTHON_INSTALL_DIR lib/${PYTHON_PACKAGES_DIR} CACHE INTERNAL "This needs to be in PYTHONPATH when 'setup.py install' is called. And it needs to match. But setuptools won't tell us where it will install things.") endif() 改那一句
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值