added hash function and hash enums
This commit is contained in:
parent
7fe9e0958c
commit
096d506553
@ -2,9 +2,9 @@ import pygame
|
|||||||
|
|
||||||
import project_constants as const
|
import project_constants as const
|
||||||
|
|
||||||
from mine_models.standard_mine import StandardMine
|
from mines.mine_models.standard_mine import StandardMine
|
||||||
from mine_models.chained_mine import ChainedMine
|
from mines.mine_models.chained_mine import ChainedMine
|
||||||
from mine_models.time_mine import TimeMine
|
from mines.mine_models.time_mine import TimeMine
|
||||||
|
|
||||||
|
|
||||||
# ================================= #
|
# ================================= #
|
||||||
|
@ -7,9 +7,9 @@ import project_constants as const
|
|||||||
from tile import Tile
|
from tile import Tile
|
||||||
|
|
||||||
# import mine models
|
# import mine models
|
||||||
from mine_models.standard_mine import StandardMine
|
from mines.mine_models.standard_mine import StandardMine
|
||||||
from mine_models.time_mine import TimeMine
|
from mines.mine_models.time_mine import TimeMine
|
||||||
from mine_models.chained_mine import ChainedMine
|
from mines.mine_models.chained_mine import ChainedMine
|
||||||
|
|
||||||
|
|
||||||
class JsonGenerator:
|
class JsonGenerator:
|
||||||
|
4
main.py
4
main.py
@ -5,13 +5,11 @@ import random
|
|||||||
# other files of this project
|
# other files of this project
|
||||||
import project_constants as const
|
import project_constants as const
|
||||||
import minefield as mf
|
import minefield as mf
|
||||||
from mine_models.time_mine import TimeMine
|
from mines.mine_models.time_mine import TimeMine
|
||||||
|
|
||||||
import searching_algorithms.a_star as a_star
|
import searching_algorithms.a_star as a_star
|
||||||
|
|
||||||
from display_assets import blit_graphics
|
from display_assets import blit_graphics
|
||||||
from project_constants import HIGHLIGHT, INPUT_ROW, INPUT_COLUMN, RANDOM_BUTTON, OK_BUTTON
|
|
||||||
from ui.ui_components_list import UiComponentsList
|
|
||||||
|
|
||||||
|
|
||||||
def _get_next_agent_position(action, agent):
|
def _get_next_agent_position(action, agent):
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import agent as ag
|
import agent as ag
|
||||||
import project_constants as const
|
import project_constants as const
|
||||||
import tile as tl
|
import tile as tl
|
||||||
from mine_models.time_mine import TimeMine
|
from mines.mine_models.time_mine import TimeMine
|
||||||
import json_generator as jg
|
import json_generator as jg
|
||||||
|
|
||||||
|
|
||||||
|
92
mines/hash_function.py
Normal file
92
mines/hash_function.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class Wire(Enum):
|
||||||
|
BLUE = 1
|
||||||
|
GREEN = 2
|
||||||
|
RED = 3
|
||||||
|
|
||||||
|
|
||||||
|
class TypeHash(Enum):
|
||||||
|
TIME = 90
|
||||||
|
CHAINED = 12
|
||||||
|
STANDARD = 0
|
||||||
|
|
||||||
|
|
||||||
|
class DangerClassHash(Enum):
|
||||||
|
BIG_BANG = 64
|
||||||
|
WEAPON_OF_MASS_DESTRUCTION = 32
|
||||||
|
RADIOACTIVE = 16
|
||||||
|
CASUAL_DEVASTATOR = 8
|
||||||
|
CHERRY_BOMB = 0
|
||||||
|
|
||||||
|
|
||||||
|
class SeriesHash(Enum):
|
||||||
|
TCH_2990TONER = 65
|
||||||
|
TCH_2990INKJET = 64
|
||||||
|
TVY_2400H = 55
|
||||||
|
SWX_5000 = 53
|
||||||
|
SWX_4000 = 50
|
||||||
|
WORKFORCE_3200 = 43
|
||||||
|
FX_500 = 40
|
||||||
|
TVY_2400 = 23
|
||||||
|
|
||||||
|
|
||||||
|
class IndicatorHash(Enum):
|
||||||
|
RED = 10
|
||||||
|
YELLOW = 8
|
||||||
|
BLUE = 5
|
||||||
|
GREEN = 2
|
||||||
|
WHITE = 0
|
||||||
|
|
||||||
|
|
||||||
|
class SpecificityHash(Enum):
|
||||||
|
ANTI_AIRCRAFT = 55
|
||||||
|
ANTI_PERSONNEL = 43
|
||||||
|
DEPTH_MINE = 37
|
||||||
|
ANTI_TANK = 26
|
||||||
|
PROXIMITY_MINE = 18
|
||||||
|
PRESSURE_MINE = 9
|
||||||
|
FRAGMENTATION_MINE = 0
|
||||||
|
|
||||||
|
|
||||||
|
# ASSUMING ALL ENUMS' MEMBERS ARE IN DESCENDING ORDER
|
||||||
|
MAX_VALUE = list(TypeHash)[0].value \
|
||||||
|
+ list(DangerClassHash)[0].value \
|
||||||
|
+ list(SeriesHash)[0].value \
|
||||||
|
+ list(IndicatorHash)[0].value \
|
||||||
|
+ list(SpecificityHash)[0].value
|
||||||
|
|
||||||
|
|
||||||
|
def _get_wire_color(hash_sum):
|
||||||
|
if hash_sum < 0.4 * MAX_VALUE:
|
||||||
|
return Wire.BLUE
|
||||||
|
elif 0.4 * MAX_VALUE < hash_sum <= 0.6 * MAX_VALUE:
|
||||||
|
return Wire.GREEN
|
||||||
|
else:
|
||||||
|
return Wire.RED
|
||||||
|
|
||||||
|
|
||||||
|
# STRING ARGUMENTS
|
||||||
|
def get_correct_wire_str(mine_type: str, danger_cls: str, series: str, indicator: str, specificity: str):
|
||||||
|
|
||||||
|
type_hash = TypeHash[mine_type.upper()].value
|
||||||
|
danger_cls_hash = DangerClassHash[danger_cls.upper()].value
|
||||||
|
series_hash = SeriesHash[series.upper()].value
|
||||||
|
indicator_hash = IndicatorHash[indicator.upper()].value
|
||||||
|
specificity_hash = SpecificityHash[specificity.upper()].value
|
||||||
|
|
||||||
|
hash_sum = type_hash + danger_cls_hash + series_hash + indicator_hash + specificity_hash
|
||||||
|
return _get_wire_color(hash_sum)
|
||||||
|
|
||||||
|
|
||||||
|
# ENUM ARGUMENTS
|
||||||
|
def get_correct_wire_enums(
|
||||||
|
mine_type: TypeHash,
|
||||||
|
danger_cls: DangerClassHash,
|
||||||
|
series: SeriesHash,
|
||||||
|
indicator: IndicatorHash,
|
||||||
|
specificity: SpecificityHash):
|
||||||
|
|
||||||
|
hash_sum = mine_type.value + danger_cls.value + series.value + indicator.value + specificity.value
|
||||||
|
return _get_wire_color(hash_sum)
|
Loading…
Reference in New Issue
Block a user