Add console info about decisions
This commit is contained in:
parent
213e6ce076
commit
89bef876b4
@ -3,18 +3,21 @@ from multiprocessing import freeze_support
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from numpy import random
|
from numpy import random
|
||||||
|
|
||||||
|
# decision tree create
|
||||||
|
|
||||||
|
###############
|
||||||
|
|
||||||
class DecisionTrees:
|
class DecisionTrees:
|
||||||
|
|
||||||
def return_predict(self):
|
def return_predict(self):
|
||||||
# Header looks like:
|
|
||||||
# header = ['Size(bigger_more_difficult)', 'Year(older_more_difficult)', 'Protection_from_defuse',
|
|
||||||
# 'Meters_under_the_ground', 'Random_detonation_chance', 'Detonation_power_in_m',
|
|
||||||
# 'Decision']
|
|
||||||
|
|
||||||
# read data
|
# read data
|
||||||
df = pd.read_csv("D:\\1 Python projects\Saper\data\db.txt")
|
df = pd.read_csv("D:\\1 Python projects\Saper\data\db.txt")
|
||||||
|
|
||||||
|
# Header of df looks like:
|
||||||
|
header = ['Size(bigger_more_difficult)', 'Year(older_more_difficult)', 'Protection_from_defuse',
|
||||||
|
'Meters_under_the_ground', 'Random_detonation_chance', 'Detonation_power_in_m',
|
||||||
|
'Decision']
|
||||||
|
|
||||||
# print data
|
# print data
|
||||||
# print(df.head())
|
# print(df.head())
|
||||||
|
|
||||||
@ -26,6 +29,7 @@ class DecisionTrees:
|
|||||||
# print predict
|
# print predict
|
||||||
# print(chef.predict(model, [1, 2022, 0, 0, 0, 10]))
|
# print(chef.predict(model, [1, 2022, 0, 0, 0, 10]))
|
||||||
|
|
||||||
|
# random generate characteristics for mine
|
||||||
size = random.randint(1, 10)
|
size = random.randint(1, 10)
|
||||||
year = random.randint(1941, 2022)
|
year = random.randint(1941, 2022)
|
||||||
protection = 0
|
protection = 0
|
||||||
@ -40,5 +44,12 @@ class DecisionTrees:
|
|||||||
|
|
||||||
mine_characteristics = [size, year, protection, m_under_the_ground, detonation_chance, detonation_power_in_m]
|
mine_characteristics = [size, year, protection, m_under_the_ground, detonation_chance, detonation_power_in_m]
|
||||||
|
|
||||||
print(mine_characteristics)
|
# print data about mine
|
||||||
|
print("Mine characteristics : ")
|
||||||
|
cnt = 0
|
||||||
|
for i in mine_characteristics:
|
||||||
|
print(header[cnt], " = ", i)
|
||||||
|
cnt += 1
|
||||||
|
|
||||||
|
# return prediction
|
||||||
return chef.predict(model, mine_characteristics)
|
return chef.predict(model, mine_characteristics)
|
||||||
|
@ -397,7 +397,7 @@ class Minesweeper:
|
|||||||
tree = decisionTrees.DecisionTrees()
|
tree = decisionTrees.DecisionTrees()
|
||||||
|
|
||||||
decision = tree.return_predict()
|
decision = tree.return_predict()
|
||||||
print(decision)
|
print("Decision : ", decision)
|
||||||
|
|
||||||
self.current_map.mines.remove(mine)
|
self.current_map.mines.remove(mine)
|
||||||
pygame.mixer.Channel(3).set_volume(0.7)
|
pygame.mixer.Channel(3).set_volume(0.7)
|
||||||
|
4
main.py
4
main.py
@ -4,6 +4,8 @@ import os
|
|||||||
|
|
||||||
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
||||||
import pygame
|
import pygame
|
||||||
|
from chefboost import Chefboost as chef
|
||||||
|
import pandas as pd
|
||||||
# system - klasy związane z pygame
|
# system - klasy związane z pygame
|
||||||
# minesweeper - klasy związane z samym saperem
|
# minesweeper - klasy związane z samym saperem
|
||||||
# ai - klasa wykonująca ruchy sapera
|
# ai - klasa wykonująca ruchy sapera
|
||||||
@ -25,6 +27,8 @@ pygame.font.init()
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
|
||||||
if MUSIC:
|
if MUSIC:
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
pygame.mixer.Channel(0).play(pygame.mixer.Sound("assets/music.ogg"), -1)
|
pygame.mixer.Channel(0).play(pygame.mixer.Sound("assets/music.ogg"), -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user