From d1701f1ac3b7fbe4fcb888e6bf1012de216e5a75 Mon Sep 17 00:00:00 2001 From: night0721 Date: Tue, 22 Oct 2024 01:30:49 +0100 Subject: [PATCH] Update Makefile --- Makefile | 17 +++++--------- dijkstra_choice.py | 38 +++++++++++++++++++++++++++++++ test.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ vtrcc | Bin 0 -> 18176 bytes 4 files changed, 98 insertions(+), 12 deletions(-) create mode 100644 dijkstra_choice.py create mode 100644 test.c create mode 100755 vtrcc diff --git a/Makefile b/Makefile index f9856d5..36a9b96 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,18 @@ .POSIX: .SUFFIXES: -CC = cc VERSION = 1.0 TARGET = vtr -MANPAGE = $(TARGET).1 PREFIX ?= /usr/local BINDIR = $(PREFIX)/bin -MANDIR = $(PREFIX)/share/man/man1 -# Flags -CFLAGS = -O3 -march=native -mtune=native -pipe -s -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -Iinclude +CFLAGS = -O3 -march=native -mtune=native -pipe -s -std=c99 -pedantic -Wall SRC = src/*.c +INCLUDE = include $(TARGET): $(SRC) - $(CC) $(SRC) -o $@ $(CFLAGS) $(LDFLAGS) + $(CC) $(SRC) -o $@ $(CFLAGS) -I$(INCLUDE) $(LDFLAGS) dist: mkdir -p $(TARGET)-$(VERSION) @@ -26,18 +23,14 @@ dist: install: $(TARGET) mkdir -p $(DESTDIR)$(BINDIR) - mkdir -p $(DESTDIR)$(MANDIR) cp -p $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET) chmod 755 $(DESTDIR)$(BINDIR)/$(TARGET) - cp -p $(MANPAGE) $(DESTDIR)$(MANDIR)/$(MANPAGE) - chmod 644 $(DESTDIR)$(MANDIR)/$(MANPAGE) uninstall: - $(RM) $(DESTDIR)$(BINDIR)/$(TARGET) - $(RM) $(DESTDIR)$(MANDIR)/$(MANPAGE) + rm $(DESTDIR)$(BINDIR)/$(TARGET) clean: - $(RM) $(TARGET) + rm $(TARGET) all: $(TARGET) diff --git a/dijkstra_choice.py b/dijkstra_choice.py new file mode 100644 index 0000000..72f8b79 --- /dev/null +++ b/dijkstra_choice.py @@ -0,0 +1,38 @@ +import heapq +from collections import defaultdict + +def list_paths_dijkstra(graph, start, target): + distances = defaultdict(lambda: float('inf')) + paths = defaultdict(list) + distances[start] = 0 + paths[start] = [[start]] + pq = [(0, start)] + + while pq: + curr_dist, node = heapq.heappop(pq) + + if curr_dist > distances[node]: + continue + + for neighbor, weight in graph[node]: + new_dist = curr_dist + weight + if new_dist < distances[neighbor]: + distances[neighbor] = new_dist + paths[neighbor] = [path + [neighbor] for path in paths[node]] + heapq.heappush(pq, (new_dist, neighbor)) + elif new_dist == distances[neighbor]: + paths[neighbor].extend([path + [neighbor] for path in paths[node]]) + + return paths[target] + +# Example usage: +graph = { + 'A': [('B', 1), ('C', 1)], + 'B': [('D', 1)], + 'C': [('D', 1)], + 'D': [] +} +start = 'A' +target = 'D' +print(list_paths_dijkstra(graph, start, target)) # Output: All shortest paths from 'A' to 'D' + diff --git a/test.c b/test.c new file mode 100644 index 0000000..751d5a8 --- /dev/null +++ b/test.c @@ -0,0 +1,55 @@ +#include + +typedef struct player_t { + int hp; + int attack; + int defense; + int range; + coordinate *pos; +} player_t; + +typedef struct coordinate { + int x; + int y; + int z; +} coordinate; +/* + * Create a player_t instance + */ +player_t * +player_init() +{ + player_t *player = malloc(sizeof(player)); + if (player == NULL) { + perror("malloc"); + exit(EXIT_FAILURE); + } + player->hp = 100; + player->attack = 10; + player->defense = 10; + player->range = 5; + player->coordinate = malloc(sizeof(coordinate)); + if (player->coordinate == NULL) { + perror("malloc"); + exit(EXIT_FAILURE); + } + return player; +} + +int +check_enemy_in_range(player_t *player) +{ + for (int x = 0; x < player->range; x++) { + for (int y = 0; y < player->range; y++) { + for (int z = 0; z < player->range; z++) { + if () + } + } + } +} +int +main() +{ + player_t *test_char = player_init(); + +} diff --git a/vtrcc b/vtrcc new file mode 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