<article style="font-size: 16px;">
<p>python石头剪刀布游戏</p>
<div>
<section>
<div>
<div>
<p>In this article, I will be showing you step by step how to make a full python rock-paper-scissor game easily. I won’t be using any hard ways so even beginners can understand how it works.</p>
<p> 在本文中,我将逐步向您展示如何轻松制作完整的python石头剪刀布游戏。 我不会使用任何困难的方法,因此即使是初学者也可以理解它的工作原理。 </p>
<h1> 下面是程序的外观: <span style="font-weight: bold;">(</span>Here’s how the program will look at end:<span style="font-weight: bold;">)</span></h1>
<p>To check out the full code in advance:</p>
<p> 要提前查看完整代码,请执行以下操作: </p>
<p><a href="https://github.com/ShubhamTiwary914/Python_Works/blob/master/Projects/P11%20RockPaperScissors.py" rel="noopener noreferrer" target="_blank">Here the link the the code</a></p>
<p> <a href="https://github.com/ShubhamTiwary914/Python_Works/blob/master/Projects/P11%20RockPaperScissors.py" rel="noopener noreferrer" target="_blank">这里的链接代码</a> </p>
<figure style="display:block;text-align:center;">
<div>
<div>
<div>
<div style="text-align: center;">
<img alt="Image for post" height="433" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-45c9ed6638b1da5c44d41e6f3b0278ef.png" style="outline: none;" width="433">
</div>
</div>
</div>
</div>
</figure>
<h1> 让我们开始吧! <span style="font-weight: bold;">(</span>Lets get Started!<span style="font-weight: bold;">)</span></h1>
</div>
</div>
</section>
<section>
<div>
<div>
<p>So let’s import all the things that we will need. And that will be:</p>
<p> 因此,让我们导入我们需要的所有东西。 那将是: </p>
<h1> 步骤1:导入所有必要的文件 <span style="font-weight: bold;">(</span>Step 1: Import all necessary files<span style="font-weight: bold;">)</span></h1>
<ul><li>Randint from random module<p class="nodelete"></p> 来自随机模块的Randint </li><li>Sleep from time module<p class="nodelete"></p> 从时间模块Hibernate </li></ul>
<figure style="display:block;text-align:center;">
<div>
<div>
<div>
<div>
<div style="text-align: center;">
<img alt="Image for post" height="144" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-50a65779e6cade401f673861e12a0841.png" style="outline: none;" width="1080">
</div>
</div>
</div>
</div>
</div>
</figure>
<p>You will know later what each of this will be used for later on.</p>
<p> 稍后您将知道这些功能将用于以后的工作。 </p>
</div>
</div>
</section>
<section>
<div>
<div>
<h1> 步骤2:建立游戏变数 <span style="font-weight: bold;">(</span>Step 2: Create game variables<span style="font-weight: bold;">)</span></h1>
<p>So first, we must give the player a choice of what to choose from Paper, Rock or Scissor.</p>
<p> 因此,首先,我们必须让玩家选择“纸”,“石头”或“剪刀”。 </p>
<p>For that let’s make a list called choices to store that for easier access to game variables.</p>
<p> 为此,让我们创建一个名为choices的列表以存储该列表,以便更轻松地访问游戏变量。 </p>
<p>Also two more variables which will hold the value of who will win the game</p>
<p> 还有两个变量将保留谁将赢得比赛的价值 </p>
<h2> 这三个变量是最重要的,将作为游戏的结果持有者 <span style="font-weight: bold;">(</span>These three variables are the most important and will act as the result holder of the game<span style="font-weight: bold;">)</span></h2>
<figure style="display:block;text-align:center;">
<div>
<div>
<div>
<div>
<div style="text-align: center;">
<img alt="Image for post" height="355" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-1f2371505b151f66bea4ac79de7b4800.png" style="outline: none;" width="1079">
</div>
</div>
</div>
</div>
</div>
</figure>
</div>
</div>
</section>
<section>
<div>
<div>
<h1> 步骤3:设定输入/控制 <span style="font-weight: bold;">(</span>Step 3: Set Your inputs/controls<span style="font-weight: bold;">)</span></h1>
<h2> 在本教程中,我们将用户称为p1,将对手称为p2。 <span style="font-weight: bold;">(</span>Let’s call user as p1 and opponent as p2 through out the tutorial.<span style="font-weight: bold;">)</span></h2>
<p>So the user(p1) will be able to select what to choose from list choices and the opponent(p2)’s choice will be random. I.e why we had imported randint from random module earlier.</p>
<p> 因此,用户(p1)将能够从列表选项中选择要选择的内容,而对手(p2)的选择将是随机的。 即为什么我们早些时候从random模块中导入了randint。 </p>
<h2> 因此,让我们将所有这些放到一个循环 |
|