I'm trying to parallelize a code in Python but I'm having some problems. This is the part of the code:
survivor = Survivor(32*2, 32*4)
if rank == 1:
a = 'audio/zombie_theme.ogg'
b = 'images/dungeon.jpg'
c = 'images/dead.jpg'
d = survivor.movement()
else:
a = None
b = None
c = None
d = None
a = comm.bcast(a, root=1)
b = comm.bcast(b, root=1)
c = comm.bcast(c, root=1)
d = comm.bcast(d, root=1)
if rank == 0:
pygame.mixer.music.load(a)
pygame.mixer.music.play(-1)
pygame.display.set_caption('Zombie Game')
screen = pygame.display.set_mode((display_width,display_height))
Tile.pre_init(screen)
clock = pygame.time.Clock()
dungeon = pygame.image.load(b)
keepPlaying = True
while keepPlaying:
screen.blit(dungeon, (0,0))
Zombie.spawn(total_frames, FPS)
Zombie.update(screen, survivor)
d
When I call d in the last line, shouldn't it call survivor.movement() defined in process 1? When I run the game, my main character does not move, as it's supposed to do. But, when I remove d from everywhere and put survivor.movement() in the last line, it works as expected. Could anybody help me?