of indefinite loop structurewe don' know how many rallies it will take before one of the players gets to the loop just keeps going until the game is over along the waywe need to keep track of the score( )and we also need to know who is currently serving the scores will probably just be couple of int-valued accumulatorsbut how do we keep track of who' servingit' either player or player one approach is to use string variable that stores either "aor "bit' also an accumulator of sortsbut to update its value we just switch it from one value to the other that' enough analysis to put together rough algorithm let' try thisinitialize scores to set serving to "aloop while game is not oversimulate one serve of whichever player is serving update the status of the game return scores it' startat least clearly there' still some work to be done on this one we can quickly fill in the first couple of steps of the algorithm to get the following def simonegame(probaprobb)scorea scoreb serving "awhile the question at this point is exactly what the condition will be we need to keep looping as long as the game is not over we should be able to tell if the game is over by looking at the scores we discussed number of possibilities for this condition in the previous some of which were fairly complex let' hide the details in another functiongameoverthat looks at the scores and returns true if the game is overand false if it is not that gets us on to the rest of the loop for now figure shows the structure chart with our new function the code for simonegame now looks like thisdef simonegame(probaprobb)scorea scoreb serving "awhile not gameover(scoreascoreb)inside the loopwe need to do single serve rememberwe are going to compare random number to probability in order to determine if the server wins the point (random(probthe correct probability to use is determined by the value of serving we will need decision based on this value if is servingthen we need to use ' probabilityandbased on the result of the serveupdate either ' score or change the service to here is the code