python摇骰子游戏

import random
def roll_dice (numbers = 3,points = None):
    print("<<<<<ROLL THE DICE!>>>>>")
    if points is None:
        points =[]
    while numbers > 0:
        points = random.randrange(1,7)
        points.append(points)
        numbers = numbers -1
    return points
 def roll_result(total):
     is_big = 11 <= total <= 18
    is_small = 3 <= total <= 10
    if is_big:
        return 'big'
    elif is_small:
        return 'small'
 def start_geme():
    print('<<<<<GAME STARTS!>>>>> ')
    choices = ['big','small']
    your_choice = input('big or small')
    if your_choice in choices:
        points =roll_dice()
        total = sum(points)
        youwin = your_choice == roll_result( total )
        if youwin:
            print('the points is',points,'you win!')
        else:
            print('the points is', points, 'you lose!')
    else:
        print('invalid word')
        start_geme()
start_geme()
 

大哥说这个在游戏开发中,就是自动免除了编译的那一块,直接通过C++调用对应的PYTHON脚本。而不用重新编译。

我说那是不是就是AI人工智能方面,自动学习就是自己会写对应的PYTHON脚本了?(还真有可能!)

猜你喜欢

转载自blog.csdn.net/jasonhongcn/article/details/85339002