-
Notifications
You must be signed in to change notification settings - Fork 0
/
ARK_creatures.py
153 lines (135 loc) · 4.43 KB
/
ARK_creatures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 26 19:12:56 2021
@author: Henrik
"""
#print('Hello World')
# Best_Creature('Pter')
# Best_Creature('Arg')
# run_backup()
# backup('ARK_dinos')
# backup('ARK_tools_taming')
import numpy as np
import matplotlib.pyplot as plt
import datetime
read_path = "./"
backup_path = "./ARK_backup/"
filename_creature = "ARK_dinos.txt"
filename_tool = "ARK_tools_taming.txt"
supercreatures = {}
# Finds the creatures from ARK_dinos
def Creatures_of_species(Creaturename):
with open(read_path + filename_creature,'r') as csvfile:
# Find the section of "creaturename"
for line in csvfile:
row = line.strip()
if Creaturename == row:
#print(row)
break
# Add all entries of that creature to creaturelist
creaturelist = {}
for line in csvfile:
row = line.strip().split(' ')
if row == ['']:
#print('ok')
break
else:
#print(row)
for i in range(1,len(row)):
if row[i] in ['NaN', 'Null']:
row[i] = 0#np.nan
else:
row[i] = float(row[i])
creaturelist[row[0]] = np.array(row[1:len(row)])
return creaturelist
# Plotting a stat against different creatures
def PlotCreatureStat(stat='Health',creature='Doed'):
creaturelist = Creatures_of_species(creature)
if stat == 'Health':
n=0
elif stat == 'Stamina':
n=1
elif stat == 'Oksygen':
n=2
elif stat == 'Food':
n=3
elif stat == 'Weight':
n=4
elif stat == 'Melee':
n=5
else:
print('stat not defined...\nAvailable stats: Health, Stamina, Oksygen, Food, Weight, Melee')
return 1
if len(creaturelist) == 0:
print('No creatures in list')
else:
y_list = []
x_list = []
for key in creaturelist:
y_list.append(key)
x_list.append(creaturelist[key][n])
print("Best",stat,"was",max(x_list))
supercreature = [key for key in creaturelist if creaturelist[key][n] == max(x_list)]
supercreatures[stat] = supercreature
print(supercreature,"had this",stat)
plt.bar(range(len(y_list)), x_list, align='center')
plt.xticks(range(len(y_list)), y_list, size='small')
plt.title(creature+' '+stat)
plt.show()
return max(x_list)
# Finds the best creatures to breed
def Best_Creature(Creaturename='Megather',Stat=('Health','Stamina','Oksygen','Food','Weight','Melee')):
BestStats = []
for stat in Stat:
BestStats.append(PlotCreatureStat(stat, Creaturename))
print("\nThe best",Creaturename,"will have the stats:")
print(BestStats)
print('\nFull overview:')
for element in supercreatures:
print(element,': \t',supercreatures[element])
return 0
# Creaturelist = Creatures_of_species(Creaturename)
# best_creatures = {}
# for creature in Creaturelist:
# for element in creature:
# print('ok')
def read_txt():
with open(read_path + filename_creature,'r') as csvfile:
for line in csvfile:
row = line.strip()
print(row)
def backup(file):
if file == 'ARK_dinos':
with open(read_path + filename_creature,'r') as csvfile:
Text = []
for line in csvfile:
Text.append(line)
Folder = backup_path+str(datetime.date.today())+'_'+filename_creature
with open(Folder,'w') as backup_file:
for line in Text:
backup_file.write(line)
return 0
elif file == 'ARK_tools_taming':
with open(read_path + filename_tool,'r') as csvfile:
Text = []
for line in csvfile:
Text.append(line)
Folder = backup_path+str(datetime.date.today())+'_'+filename_tool
with open(Folder,'w') as backup_file:
for line in Text:
backup_file.write(line)
return 0
else:
print('File not recognzed')
return 1
def run_backup(l=['ARK_dinos','ARK_tools_taming']):
for item in l:
backup(item)
print("Backup complete!")
return 0
if __name__ == '__main__':
#read_txt()
#print(Creatures_of_species('Doed'))
#PlotCreatureStat(creature='Doed')
Best_Creature()
run_backup()