Write a python code of this problem
- Problem Statement
Assume that there are two teams and they are team attacker and team defender. Therefore, at a state of the game one agent in each team is left alive respectively. Here, the defender is given a lifeline called HP which will be assigned randomly. Furthermore, the attacker agent will try to give maximum negative HP to the defender agent to decrease his(d) chances of survival in the game. On the other hand, the defender agent will try to protect himself by receiving the lowest negative HP possible from the attacker agent. Furthermore, the attacker can have a choice from a number of bullets from his gun and the optimal moves will cost a certain maximum negative HP (chosen from randomly assigned values within the range of minimum and maximum negative HP). Here, are the following things you need to do using Alpha-Beta Pruning
- Sample Input 1:
- Enter your student id:
17301106 |
- Minimum and Maximum value for the range of negative HP:
1 30 |
Note: Here, the second input is a space separated single line input string.
- Sample Input 1 Explanation:
Ex. 1 (17301106) (Use 1st digit of your bracu student id) |
# Number of turns for the attacker agent [Assume that both of them will get equal number of chances] |
Ex. 60 (17301106) (Use last 2 digits of your bracu student id in reverse) |
# Initial lifeline (HP) for the defender at initial state of the game |
Ex. 3 (17301106) (Use semester code-3rd digit of your bracu student id) |
# Number of bullets from which the final choice has to be made by the attacker. |
Ex. 1 (1 30) |
# Minimum value for the range of negative HP values |
Ex. 30 (1 30) |
# Maximum value for the range of negative HP values |
- Sample Output 1:
- Depth and Branches ratio is 2:3
- Terminal States (leaf node values) are 19,22,9,2,26,16,16,27,16.
- Left life(HP) of the defender after maximum damage caused by the attacker is 44
- After Alpha-Beta Pruning Leaf Node Comparisons 7
- Sample Output 1 Explanation:
(Application of Alpha-Beta Pruning Algorithm)
MAX - Level 0 Attacker’s Turn / Initial Start MAX utility/Best Choice
MIN - Level 1 Defender’s Turn 3 branches
Leaf Nodes - Level 2 Terminal state 3^2=9 Leaf Nodes(Random States)
[19, 22, 9, 2, 26, 16, 16, 27, 16]
(Left lifeline/HP)
Left Life = (60 - 16) = 44
So, Left life(HP) of the defender after maximum damage caused by the attacker is 44
Hint:
- Apply Alpha-Beta Pruning algorithm for sample output line 3 and line 4
- Formula: Left life HP=Initial life HP-MAX negative HP
Note:
Terminal nodes are randomly generated values within the given range of negative HP (sample output line 2).
- Sample Input 2:
- Enter your student id:
20201003 |
- Minimum and Maximum value for the range of negative HP:
5 20 |
- Sample Output 2:
- Depth and Branches ratio is 4:2
- Terminal States(Leaf Nodes) are 18,13,5,12,10,5,13,7,17,8,6,8,5,11,13,18.
- Left life(HP) of the defender after maximum damage caused by the attacker is 22
- After Alpha-Beta Pruning Leaf Node Comparisons 13
Step by stepSolved in 3 steps
- Each Othello piece has a black side and a white side. Here is how Othello is played.A piece is considered to be caught when it is encircled by its rivals on both the left and right sides, or both the top and bottom, and when its colour is reversed. You must capture at least one throughout your turn. any of your adversary's pieces. When neither player has any further move options, the game is over. The player who has the most pieces is declared the winner. Put Othello's object-oriented design into practice.arrow_forwardRod cutting problem: A cutting factory buys long steel rods and then and cuts them into shorter rods, which it then sells. Each cut is free. The selling price is based on the length of the cut. The factory want to determine the best cuts in order to maximize its revenue. Below, the price that the factory can make for each length of rod is given. Determine the maximum revenue, rn, obtainable by cutting up the rod and selling the pieces using bottom-up dynamic-programming approach. Length, I 1 2 3 4 5 6 7 Price, pi 2 4 5 6 9 10 12 r5 = ?arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY