Update Makefile

This commit is contained in:
Night Kaly 2024-10-22 01:30:49 +01:00
parent 2e2991c72e
commit d1701f1ac3
Signed by: night0721
GPG key ID: 957D67B8DB7A119B
4 changed files with 98 additions and 12 deletions

View file

@ -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)

38
dijkstra_choice.py Normal file
View file

@ -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'

55
test.c Normal file
View file

@ -0,0 +1,55 @@
#include <stdio.h>
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();
}

BIN
vtrcc Executable file

Binary file not shown.