def initStateFrom(self, particleId, particleState, newBest):
<EOL>if newBest:<EOL><INDENT>(bestResult, bestPosition) = self._resultsDB.getParticleBest(particleId)<EOL><DEDENT>else:<EOL><INDENT>bestResult = bestPosition = None<EOL><DEDENT>varStates = particleState['<STR_LIT>']<EOL>for varName in varStates.keys():<EOL><INDENT>varState = copy.deepcopy(varStates[varName])<EOL>if newBest:<EOL><INDENT>varState['<STR_LIT>'] = bestResult<EOL><DEDENT>if bestPosition is not None:<EOL><INDENT>varState['<STR_LIT>'] = bestPosition[varName]<EOL><DEDENT>self.permuteVars[varName].setState(varState)<EOL><DEDENT>
Init all of our variable positions, velocities, and optionally the best
        result and best position from the given particle.

        If newBest is true, we get the best result and position for this new
        generation from the resultsDB, This is used when evoloving a particle
        because the bestResult and position as stored in was the best AT THE TIME
        THAT PARTICLE STARTED TO RUN and does not include the best since that
        particle completed.