FGFGD

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

import numpy as np

import matplotlib.pyplot as plt

def createHeatMap(n, centers, radii):


# Create an empty matrix of size n x n
matrix = np.zeros((n, n))

# Define a function to calculate the distance between two points

# Fill the matrix with the heatmap values


for center, radius in zip(centers, radii):
for i in range(n):
for j in range(n):
dist = distance(center, (i, j))
if radius > 0 and dist <= radius:
matrix[i, j] = max(matrix[i, j], 1 - dist / radius)
elif radius == 0 and (i, j) == center:
matrix[i, j] = 1
# Display the heatmap
plt.imshow(matrix, cmap='hot', interpolation='nearest')
plt.colorbar()
plt.show(createHeatMap)

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle

def crtaj(n, coordinates, radii):


# Create an n x n matrix with all black pixels
grid = np.zeros((n, n), dtype=int)

# Mark pixels corresponding to coordinates with bright spots


for coord, radius in zip(coordinates, radii):
x, y = coord
if 0 <= x < n and 0 <= y < n:
grid[x, y] = 255 # Set pixel to white

# Create a figure and axis


fig, ax = plt.subplots()

# Display the matrix


ax.imshow(grid, cmap='gray', origin='upper')

# Draw circles around bright spots


for coord, radius in zip(coordinates, radii):
x, y = coord
if 0 <= x < n and 0 <= y < n:
circle = Circle((y, x), radius, color='pink', fill=False)
ax.add_patch(circle)

# Set axis limits


ax.set_xlim(0, n)
ax.set_ylim(n, 0)

# Show the plot


plt.show()
T=100
civilizacije = []
rad=[]
i=0
p=0.2
p1=0.05

def pomeranje(x, y):

x1 = np.random.randint (-1,2)
x2 = x + x1
y1 = np.random.randint (-1,2)
y2 = y + y1
if x2<0:
x2=0
if x2>100:
x2=100
if y2<0:
y2=0
if y2>100:
y2=100
return x2,y2

def distance(p1, p2):


return np.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)

def met(x):
if r1+r2>distance(x1,x2):
return True
else:
return False

for i in range(0,T) :

if(np.random.rand() < p) :
temp=(np.random.randint(0,100),np.random.randint(0,100))
print(temp)
if temp not in civilizacije :
civilizacije.append(temp)
rad.append(0)
for j in range (0, len(civilizacije)):

if(np.random.rand() < p1) :


rad [j]+=1

macka = pomeranje(civilizacije[j][0], civilizacije[j][1])

civilizacije[j]= macka

if collision_times:
max_time = max(collision_times)
min_time = min(collision_times)
print(f"Maximum collision time: {max_time}")
print(f"Minimum collision time: {min_time}")
else:
print("No collisions occurred.")

crtaj(100, civilizacije, rad)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy