Replacing
ds1 = pygame.display.set_mode((500,500))
with
ds1 = pygame.display.set_mode([500, 500])
(removing the inner parentheses with brackets) should at least get your window to appear.
And changing the pygame.display.update to pygame.display.flip() allows your program to execute properly, or at least it does when testing on my end. Here is what the modified code I got to run looks like in full:
import pygame
pygame.init()
ds1 = pygame.display.set_mode([500, 500])
pygame.display.set_caption("Cosmopolitan Mini Game")
re1x = 100
re1y = 150
re2x = 300
re2y = 300
re1 = 10
re2 = 30
bl = (0, 0, 0)
rmain = True
def winf():
ds1.fill((255, 255, 255))
pygame.draw.rect(ds1, (255, 5, 5), (re1x, re1y, 20, 20))
pygame.draw.rect(ds1, (5, 5, 255), (re2x, re2y, 30, 30))
# Flip the display
pygame.display.flip()
while rmain:
pygame.time.delay(200)
if re2x < re1x - 10:
re2x = re2x + re2
winf()
elif re2x > re1x + 10:
winf()
re2x = re2x - re2
elif re2y < re1y - 10:
re2y = re2y + re2
elif re2y > re1y + 10:
re2y = re2y - re2
else:
rmain = False
for event in pygame.event.get():
if event.type == pygame.QUIT:
rmain = False
km1 = pygame.key.get_pressed()
if km1[pygame.K_LEFT]:
re1x += re1
if km1[pygame.K_RIGHT]:
re1x -= re1
if km1[pygame.K_UP]:
re1y -= re1
if km1[pygame.K_DOWN]:
re1y += re1
winf()
pygame.quit()