|
4 | 4 | "cell_type": "markdown",
|
5 | 5 | "metadata": {},
|
6 | 6 | "source": [
|
7 |
| - "<img src=\"../../../images/qiskit-heading.gif\" alt=\"Note: In order for images to show up in this jupyter notebook you need to select File => Trusted Notebook\" width=\"500 px\" align=\"left\">" |
| 7 | + "<img src=\"../../../../images/qiskit-heading.gif\" alt=\"Note: In order for images to show up in this jupyter notebook you need to select File => Trusted Notebook\" width=\"500 px\" align=\"left\">" |
8 | 8 | ]
|
9 | 9 | },
|
10 | 10 | {
|
|
24 | 24 | "metadata": {},
|
25 | 25 | "source": [
|
26 | 26 | "### Contributors\n",
|
27 |
| - "Mirko Amico" |
| 27 | + "Mirko Amico\n", |
| 28 | + "\n", |
| 29 | + "### Qiskit Package Versions" |
| 30 | + ] |
| 31 | + }, |
| 32 | + { |
| 33 | + "cell_type": "code", |
| 34 | + "execution_count": 1, |
| 35 | + "metadata": {}, |
| 36 | + "outputs": [ |
| 37 | + { |
| 38 | + "data": { |
| 39 | + "text/plain": [ |
| 40 | + "{'qiskit': '0.10.3',\n", |
| 41 | + " 'qiskit-terra': '0.8.1',\n", |
| 42 | + " 'qiskit-ignis': '0.1.1',\n", |
| 43 | + " 'qiskit-aer': '0.2.1',\n", |
| 44 | + " 'qiskit-ibmq-provider': '0.2.2',\n", |
| 45 | + " 'qiskit-aqua': '0.5.1'}" |
| 46 | + ] |
| 47 | + }, |
| 48 | + "execution_count": 1, |
| 49 | + "metadata": {}, |
| 50 | + "output_type": "execute_result" |
| 51 | + } |
| 52 | + ], |
| 53 | + "source": [ |
| 54 | + "import qiskit\n", |
| 55 | + "qiskit.__qiskit_version__" |
28 | 56 | ]
|
29 | 57 | },
|
30 | 58 | {
|
|
104 | 132 | },
|
105 | 133 | {
|
106 | 134 | "cell_type": "code",
|
107 |
| - "execution_count": 1, |
| 135 | + "execution_count": 2, |
108 | 136 | "metadata": {},
|
109 | 137 | "outputs": [],
|
110 | 138 | "source": [
|
|
113 | 141 | "import random as rand\n",
|
114 | 142 | "\n",
|
115 | 143 | "# importing Qiskit\n",
|
116 |
| - "from qiskit import Aer\n", |
| 144 | + "from qiskit import BasicAer\n", |
117 | 145 | "from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute"
|
118 | 146 | ]
|
119 | 147 | },
|
120 | 148 | {
|
121 | 149 | "cell_type": "code",
|
122 |
| - "execution_count": 2, |
| 150 | + "execution_count": 3, |
123 | 151 | "metadata": {},
|
124 | 152 | "outputs": [],
|
125 | 153 | "source": [
|
|
128 | 156 | },
|
129 | 157 | {
|
130 | 158 | "cell_type": "code",
|
131 |
| - "execution_count": 1, |
| 159 | + "execution_count": 4, |
132 | 160 | "metadata": {},
|
133 | 161 | "outputs": [
|
134 | 162 | {
|
|
152 | 180 | "<IPython.core.display.HTML object>"
|
153 | 181 | ]
|
154 | 182 | },
|
155 |
| - "execution_count": 1, |
| 183 | + "execution_count": 4, |
156 | 184 | "metadata": {},
|
157 | 185 | "output_type": "execute_result"
|
158 | 186 | }
|
|
196 | 224 | },
|
197 | 225 | {
|
198 | 226 | "cell_type": "code",
|
199 |
| - "execution_count": 3, |
| 227 | + "execution_count": 5, |
200 | 228 | "metadata": {},
|
201 | 229 | "outputs": [],
|
202 | 230 | "source": [
|
|
227 | 255 | },
|
228 | 256 | {
|
229 | 257 | "cell_type": "code",
|
230 |
| - "execution_count": 4, |
| 258 | + "execution_count": 6, |
231 | 259 | "metadata": {},
|
232 | 260 | "outputs": [
|
233 | 261 | {
|
234 | 262 | "name": "stdout",
|
235 | 263 | "output_type": "stream",
|
236 | 264 | "text": [
|
237 |
| - "select the classical strategy for Alice, input 1,2,3 or 4 to pick one of the strategies listed above 1\n", |
238 |
| - "select the classical strategy for Bob, input 1,2,3 or 4 to pick one of the strategies listed above 4\n" |
| 265 | + "select the classical strategy for Alice, input 1,2,3 or 4 to pick one of the strategies listed above 2\n", |
| 266 | + "select the classical strategy for Bob, input 1,2,3 or 4 to pick one of the strategies listed above 1\n" |
239 | 267 | ]
|
240 | 268 | }
|
241 | 269 | ],
|
|
249 | 277 | },
|
250 | 278 | {
|
251 | 279 | "cell_type": "code",
|
252 |
| - "execution_count": 5, |
| 280 | + "execution_count": 7, |
253 | 281 | "metadata": {},
|
254 | 282 | "outputs": [
|
255 | 283 | {
|
256 | 284 | "name": "stdout",
|
257 | 285 | "output_type": "stream",
|
258 | 286 | "text": [
|
259 |
| - "Alice and Bob won the game with probability: 77.0 %\n" |
| 287 | + "Alice and Bob won the game with probability: 76.0 %\n" |
260 | 288 | ]
|
261 | 289 | }
|
262 | 290 | ],
|
|
324 | 352 | },
|
325 | 353 | {
|
326 | 354 | "cell_type": "code",
|
327 |
| - "execution_count": 6, |
| 355 | + "execution_count": 8, |
328 | 356 | "metadata": {},
|
329 | 357 | "outputs": [],
|
330 | 358 | "source": [
|
|
373 | 401 | },
|
374 | 402 | {
|
375 | 403 | "cell_type": "code",
|
376 |
| - "execution_count": 7, |
| 404 | + "execution_count": 9, |
377 | 405 | "metadata": {},
|
378 | 406 | "outputs": [
|
379 | 407 | {
|
380 | 408 | "name": "stdout",
|
381 | 409 | "output_type": "stream",
|
382 | 410 | "text": [
|
383 |
| - "select the quantum strategy for Alice, input 1,2 or 3 to pick one of the strategies listed above: 3\n", |
384 |
| - "select the quantum strategy for Bob, input 1,2 or 3 to pick one of the strategies listed above: 3\n" |
| 411 | + "select the quantum strategy for Alice, input 1,2 or 3 to pick one of the strategies listed above: 2\n", |
| 412 | + "select the quantum strategy for Bob, input 1,2 or 3 to pick one of the strategies listed above: 1\n" |
385 | 413 | ]
|
386 | 414 | }
|
387 | 415 | ],
|
|
395 | 423 | },
|
396 | 424 | {
|
397 | 425 | "cell_type": "code",
|
398 |
| - "execution_count": 8, |
| 426 | + "execution_count": 10, |
399 | 427 | "metadata": {},
|
400 | 428 | "outputs": [
|
401 | 429 | {
|
402 | 430 | "name": "stdout",
|
403 | 431 | "output_type": "stream",
|
404 | 432 | "text": [
|
405 |
| - "Alice and Bob won the game with probability: 86.0 %\n" |
| 433 | + "Alice and Bob won the game with probability: 52.0 %\n" |
406 | 434 | ]
|
407 | 435 | }
|
408 | 436 | ],
|
409 | 437 | "source": [
|
410 | 438 | "# set parameters of the quantum run of the game \n",
|
411 | 439 | "shots = 1 # set how many times the circuit is run, accumulating statistics about the measurement outcomes \n",
|
412 |
| - "backend = Aer.get_backend('qasm_simulator') # set the machine where the quantum circuit is to be run \n", |
| 440 | + "backend = BasicAer.get_backend('qasm_simulator') # set the machine where the quantum circuit is to be run \n", |
413 | 441 | "\n",
|
414 | 442 | "#fixes the numbers of games to be played\n",
|
415 | 443 | "N=100\n",
|
|
508 | 536 | },
|
509 | 537 | {
|
510 | 538 | "cell_type": "code",
|
511 |
| - "execution_count": 9, |
| 539 | + "execution_count": 11, |
512 | 540 | "metadata": {},
|
513 | 541 | "outputs": [
|
514 | 542 | {
|
515 | 543 | "name": "stdout",
|
516 | 544 | "output_type": "stream",
|
517 | 545 | "text": [
|
518 |
| - "The quantum strategy gave Alice and Bob higher chances of winning\n" |
| 546 | + "The classical strategy gave Alice and Bob higher chances of winning\n" |
519 | 547 | ]
|
520 | 548 | }
|
521 | 549 | ],
|
|
0 commit comments