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 100755 index 0000000..9995365 Binary files /dev/null and b/vtrcc differ