0
\$\begingroup\$

so I have some Python code to generate a random 10x10 grid in which a mine will be or won't be placed, I am having trouble trying to convert this list into a use-able set of coordinates. Any help would be appreciated


fieldx = 10
fieldy = 10
objecs = 20
    
Field = []
for i in range(fieldy):
  Field.append([])
  for j in range(fieldx):
    Field[i].append([0])



for i in range(objecs):
  x = random.randint(0,fieldx-1)
  y = random.randint(0,fieldy-1)
  if Field[y][x] == [0]:
    Field[y][x] = [1]
\$\endgroup\$
2
  • \$\begingroup\$ What do you find unusable about the coordinates you have? \$\endgroup\$ Commented Jun 8, 2024 at 10:17
  • \$\begingroup\$ I cant quite think of a way to turn the list created into a method of drawing items to the screen. what i want to happen is where the 1 in the list is, there should be an object created. otherwise it should be left blank \$\endgroup\$ Commented Jun 9, 2024 at 12:17

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.