I'm trying to create a decision tree as a simulation of an idea I have for Halo 5 Forge's built-in scripting system. This decision tree simulation is being written in python before I apply the concept in Halo 5 Forge. Basically, the decision tree is supposed to simulate weapon and vehicle randomization every 30 seconds based on the previous selection 30 seconds ago.
The idea is that both teams' bases share a turn-based decision tree where one base chooses a weapon or vehicle and the other base responds by choosing a counter at random based on a set of weapons and vehicles that are able to counter it. So every 30 seconds a base gets a turn to choose which item it wants to deploy for the team.
For example: If the base chooses a ghost, 30 seconds later the other teams' base may choose a Railgun or a Warthog in response. 30 seconds later the initial team's base chooses a Hydra Launcher, a SAW or a Scorpion if a Railgun was chosen or they can choose a Rocket Launcher, Spartan Laser, Plasma Pistol or Scorpion if a Warthog was chosen.
And both team's bases would essentially be playing a broader version of Rock, Paper, Scissors against each other until the game ends but the idea is that this would progress in a more-or-less linear fashion in order to balance strategy with randomization.
Here is the following code in Python:
import random as r
iterations = 30
seed = r.randrange(1, 5)
def itemChosen(value):
global seed
global iterations
while iterations > 0:
match value:
case 1:
itemName = "Mongoose"
##print(itemName)
seed = r.sample([10, 11, 12], 1)
value = seed
case 2:
itemName = "Ghost"
##print(itemName)
seed = r.sample([10, 11, 12], 1)
value = seed
case 3:
itemName = "Light Rifle"
##print(itemName)
seed = r.sample([6, 7, 22], 1)
value = seed
case 4:
itemName = "Carbine"
#print(itemName)
seed = r.sample([6, 7, 22], 1)
value = seed
case 5:
itemName = "Rocket Launcher"
#print(itemName)
seed = r.sample([19, 29, 8, 6, 7, 15], 1)
value = seed
case 6:
itemName = "Sniper Rifle"
#print(itemName)
seed = r.sample([7, 8, 10, 20, 23], 1)
value = seed
case 7:
itemName = "Beam Rifle"
#print(itemName)
seed = r.sample([6, 8, 10, 20, 23], 1)
value = seed
case 8:
itemName = "Binary Rifle"
#print(itemName)
seed = r.sample([6, 7, 10, 20, 23], 1)
value = seed
case 9:
itemName = "Spartan Laser"
#print(itemName)
seed = r.sample([6, 7, 8, 10, 20, 23, 29, 13, 19], 1)
value = seed
case 10:
itemName = "Railgun"
#print(itemName)
seed = r.sample([11, 13, 18, 19, 22, 23, 24, 26], 1)
value = seed
case 11:
itemName = "Hydra Launcher"
#print(itemName)
seed = r.sample([10, 3, 4, 14, 15, 22, 29, 24], 1)
value = seed
print(itemName)
print(value)
iterations -= 1
itemChosen(seed) #The method is called here.
So the issue I am running here is that when the method is called the seed is randomized only once and it keeps printing the same value and name of the item until iterations reaches 0
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Light Rifle
[6]
Process finished with exit code 0
I'm not sure where the problem lies. Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire