0

I have a class instance:

self.robots = ROBOT()

And I want to run my code such that I will have the following arguments passed into it:

bestBrains[overallChampionIndex],-8,0
bestBrains[overallChampionIndex],-4,-4
bestBrains[overallChampionIndex],-4,4

In successive iterations.

So the first iteration will be: self.robots = ROBOT(bestBrains[overallChampionIndex],-8,0)

The second iteration will be: self.robots = ROBOT(bestBrains[overallChampionIndex],-4,-4)

The third iteration will be: self.robots = ROBOT(bestBrains[overallChampionIndex],-4,4)

I tried the following:

        self.position = [
            (bestBrains[overallChampionIndex],-8,0),
            (bestBrains[overallChampionIndex],-4,-4),
            (bestBrains[overallChampionIndex],-4,4),
            (bestBrains[overallChampionIndex],0,-8),
            (bestBrains[overallChampionIndex],0,0),
            (bestBrains[overallChampionIndex],0,8),
            (bestBrains[overallChampionIndex],4,-4),
            (bestBrains[overallChampionIndex],4,0),
            (bestBrains[overallChampionIndex],4,4),
            (bestBrains[overallChampionIndex],8,0) 
        ]
        self.robots = ROBOT(self.position[positionIndex])

          self.robots[self.position[i]]

ROBOT takes in 3 arguments, and my attempt resulted in only the first argument being satisfied.

1 Answers1

1

as suggested in the comment you can use the asterisk operator this way:

self.robots[*self.position[i]]

or simply by accessing the elements of your tuple this way:

self.robots[self.position[i][0], self.position[i][1],  self.position[i][2]]
sos
  • 305
  • 1
  • 9