Add console info about decisions

This commit is contained in:
egotd 2022-05-19 11:45:35 +02:00
parent 213e6ce076
commit 89bef876b4
3 changed files with 22 additions and 7 deletions

View File

@ -3,18 +3,21 @@ from multiprocessing import freeze_support
import pandas as pd
from numpy import random
# decision tree create
###############
class DecisionTrees:
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
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(df.head())
@ -26,6 +29,7 @@ class DecisionTrees:
# print predict
# print(chef.predict(model, [1, 2022, 0, 0, 0, 10]))
# random generate characteristics for mine
size = random.randint(1, 10)
year = random.randint(1941, 2022)
protection = 0
@ -40,5 +44,12 @@ class DecisionTrees:
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)

View File

@ -397,7 +397,7 @@ class Minesweeper:
tree = decisionTrees.DecisionTrees()
decision = tree.return_predict()
print(decision)
print("Decision : ", decision)
self.current_map.mines.remove(mine)
pygame.mixer.Channel(3).set_volume(0.7)

View File

@ -4,6 +4,8 @@ import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import pygame
from chefboost import Chefboost as chef
import pandas as pd
# system - klasy związane z pygame
# minesweeper - klasy związane z samym saperem
# ai - klasa wykonująca ruchy sapera
@ -25,6 +27,8 @@ pygame.font.init()
def main():
if MUSIC:
pygame.mixer.init()
pygame.mixer.Channel(0).play(pygame.mixer.Sound("assets/music.ogg"), -1)