예제 #1
0
import pygame

from game.Game import Game
from graphs.Node import Node
from search import a_star

pathGame = Game(10)
pathGame.choosingStart = False


def draw(game):
    game.gameDisplay.fill((255, 255, 255))

    rowN = 0
    if game.graph.adjacency is not None:
        for row in range(0, len(game.graph.adjacency)):
            for col in range(rowN, len(game.graph.adjacency[row])):
                if game.graph.adjacency[row, col] == 1:
                    color = (0, 0, 0)
                    if game.graph.nodes[row].isSolution and game.graph.nodes[
                            col].isSolution:
                        color = (82, 239, 43)

                    pygame.draw.line(game.gameDisplay, color,
                                     game.graph.nodes[row].pos,
                                     game.graph.nodes[col].pos, 3)

            rowN += 1

    for node in game.graph.nodes:
        pygame.draw.circle(game.gameDisplay, node.color, node.pos,