Update Makefile
This commit is contained in:
parent
2e2991c72e
commit
d1701f1ac3
4 changed files with 98 additions and 12 deletions
17
Makefile
17
Makefile
|
@ -1,21 +1,18 @@
|
||||||
.POSIX:
|
.POSIX:
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|
||||||
CC = cc
|
|
||||||
VERSION = 1.0
|
VERSION = 1.0
|
||||||
TARGET = vtr
|
TARGET = vtr
|
||||||
MANPAGE = $(TARGET).1
|
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
MANDIR = $(PREFIX)/share/man/man1
|
|
||||||
|
|
||||||
# Flags
|
CFLAGS = -O3 -march=native -mtune=native -pipe -s -std=c99 -pedantic -Wall
|
||||||
CFLAGS = -O3 -march=native -mtune=native -pipe -s -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -Iinclude
|
|
||||||
|
|
||||||
SRC = src/*.c
|
SRC = src/*.c
|
||||||
|
INCLUDE = include
|
||||||
|
|
||||||
$(TARGET): $(SRC)
|
$(TARGET): $(SRC)
|
||||||
$(CC) $(SRC) -o $@ $(CFLAGS) $(LDFLAGS)
|
$(CC) $(SRC) -o $@ $(CFLAGS) -I$(INCLUDE) $(LDFLAGS)
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
mkdir -p $(TARGET)-$(VERSION)
|
mkdir -p $(TARGET)-$(VERSION)
|
||||||
|
@ -26,18 +23,14 @@ dist:
|
||||||
|
|
||||||
install: $(TARGET)
|
install: $(TARGET)
|
||||||
mkdir -p $(DESTDIR)$(BINDIR)
|
mkdir -p $(DESTDIR)$(BINDIR)
|
||||||
mkdir -p $(DESTDIR)$(MANDIR)
|
|
||||||
cp -p $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
|
cp -p $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
|
||||||
chmod 755 $(DESTDIR)$(BINDIR)/$(TARGET)
|
chmod 755 $(DESTDIR)$(BINDIR)/$(TARGET)
|
||||||
cp -p $(MANPAGE) $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
|
||||||
chmod 644 $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
$(RM) $(DESTDIR)$(BINDIR)/$(TARGET)
|
rm $(DESTDIR)$(BINDIR)/$(TARGET)
|
||||||
$(RM) $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(TARGET)
|
rm $(TARGET)
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
|
|
38
dijkstra_choice.py
Normal file
38
dijkstra_choice.py
Normal 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
55
test.c
Normal 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
BIN
vtrcc
Executable file
Binary file not shown.
Loading…
Reference in a new issue