examples
Co-authored-by: Sebastian Piotrowski <sebpio@st.amu.edu.pl> Co-authored-by: Ladislaus3III <Ladislaus3III@users.noreply.github.com> Co-authored-by: Marcin Matoga <marmat35@st.amu.edu.pl>
This commit is contained in:
parent
55d542fa0e
commit
74788bbc94
70
generate_examples.py
Normal file
70
generate_examples.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#author: Kuba Henyk
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
class ExampleGenerator():
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def generate():
|
||||||
|
list = [[]]
|
||||||
|
|
||||||
|
for i in range(1000):
|
||||||
|
while True:
|
||||||
|
c = [random.randrange(0, 21), random.randrange(5, 41), random.randrange(1, 61), random.randrange(0, 11), random.randrange(0, 2), random.randrange(0, 2), random.randrange(0, 2), random.randrange(0, 2)]
|
||||||
|
if c in list:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
list.append(c)
|
||||||
|
|
||||||
|
f = open("dane.txt", "w")
|
||||||
|
|
||||||
|
for i in range(len(list)):
|
||||||
|
if i != 0:
|
||||||
|
#glebokosc
|
||||||
|
if list[i][0] <= 19:
|
||||||
|
#rozmiar
|
||||||
|
if list[i][1] <= 39:
|
||||||
|
#masa
|
||||||
|
if list[i][2] <= 58:
|
||||||
|
#moc
|
||||||
|
if list[i][3] <= 9:
|
||||||
|
#szkodliwosc
|
||||||
|
if list[i][4] == 1:
|
||||||
|
#zabawka
|
||||||
|
if list[i][5] == 1:
|
||||||
|
#stan
|
||||||
|
if list[i][6] == 1:
|
||||||
|
#teledysk
|
||||||
|
if list[i][7] == 1:
|
||||||
|
list[i].append(2)
|
||||||
|
else:
|
||||||
|
list[i].append(5)
|
||||||
|
else:
|
||||||
|
list[i].append(4)
|
||||||
|
else:
|
||||||
|
list[i].append(3)
|
||||||
|
else:
|
||||||
|
list[i].append(1)
|
||||||
|
else:
|
||||||
|
list[i].append(1)
|
||||||
|
else:
|
||||||
|
list[i].append(1)
|
||||||
|
else:
|
||||||
|
list[i].append(1)
|
||||||
|
else:
|
||||||
|
list[i].append(1)
|
||||||
|
|
||||||
|
for i in range(len(list)):
|
||||||
|
if i == 0:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
for j in range(len(list[i])):
|
||||||
|
f.write(str(list[i][j]) + ' ')
|
||||||
|
f.write("\n")
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
20
main.py
20
main.py
@ -2,12 +2,19 @@ import pygame as pg
|
|||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
from matplotlib import pyplot
|
||||||
|
from sklearn import datasets
|
||||||
|
from sklearn.tree import DecisionTreeClassifier
|
||||||
|
from sklearn import tree
|
||||||
|
|
||||||
from maze import *
|
from maze import *
|
||||||
from grid import *
|
from grid import *
|
||||||
from settings import *
|
from settings import *
|
||||||
from sprites import *
|
from sprites import *
|
||||||
from graphsearch import *
|
from graphsearch import *
|
||||||
from astar2 import *
|
from astar2 import *
|
||||||
|
from generate_examples import *
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
@ -115,6 +122,19 @@ class Game:
|
|||||||
self.graph_move(player_moves)
|
self.graph_move(player_moves)
|
||||||
self.wentyl_bezpieczenstwa = 1
|
self.wentyl_bezpieczenstwa = 1
|
||||||
# Test.run()
|
# Test.run()
|
||||||
|
if event.key == pg.K_F5:
|
||||||
|
ExampleGenerator.generate()
|
||||||
|
if event.key == pg.K_F6:
|
||||||
|
X = [[6,15,31,5,0,0,1,0],[6,36,5,8,1,1,1,0],
|
||||||
|
[13,40,29,3,0,0,0,0], [15,25,23,7,0,0,1,1],
|
||||||
|
[17,34,5,5,1,1,0,1], [3,9,28,8,0,0,1,0],
|
||||||
|
[18,38,43,6,1,1,1,1], [3,8,53,4,1,1,1,1],
|
||||||
|
[9,40,47,1,1,0,1,1],[11,23,31,5,0,0,1,1]]
|
||||||
|
Y = [1,5,1,1,4,1,2,2,1,1]
|
||||||
|
clf = tree.DecisionTreeClassifier()
|
||||||
|
clf = clf.fit(X,Y)
|
||||||
|
tree.plot_tree(clf)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
15
poklad/test.txt
Normal file
15
poklad/test.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
if głebokość <= 5 [1, 20] - dalej, else oflagować
|
||||||
|
rozmiar <= 20 [5, 40] - dalej, else oflagować
|
||||||
|
masa <= 30 [1, 60] - dalej, else oflagować
|
||||||
|
moc <= 5 kiloton [0, 10] - dalej, else oflagować
|
||||||
|
czy jest szkodliwy: nie/tak [0,1] - dalej, else oflagować
|
||||||
|
czy jest zabawką : nie/tak [0,1] - dalej, else sprzedać na allegro
|
||||||
|
czy jest w dobrym stanie: nie/tak [0,1] - zdetonować, czarny rynek
|
||||||
|
czy jest teledyskiem: nie/tak [0,1] - zdetonować, obejrzeć
|
||||||
|
|
||||||
|
|
||||||
|
głebokość | rozmiar | masa | moc | czy jest szkodliwy | czy jest zabawką | czy jest w dobrym stanie | czy jest teledyskiem
|
||||||
|
|
||||||
|
4 5 10 3kt nie nie tak nie
|
||||||
|
|
||||||
|
^sprzedać na czarnym rynku
|
Loading…
Reference in New Issue
Block a user