json added

This commit is contained in:
barmal4 2021-05-18 19:34:52 +02:00
parent e022043240
commit f6541cf652
12 changed files with 32 additions and 172 deletions

View File

@ -10,7 +10,7 @@ UP = 'UP'
DOWN = 'DOWN'
LEFT = 'LEFT'
RIGHT = 'RIGHT'
DEFUSE = 'DEFUSE'
DEFUSE = 'defuse'
MOVE = 'MOVE'
DECOY = 'Decoy'
@ -28,4 +28,6 @@ NO = "no"
NONE = "none"
IMMEDIATE = "immediate"
MEDIUM = 'medium'
POLIGON = 'poligon'
DETONATE = 'detonate'

View File

@ -1,165 +1 @@
{
"defusable": {
"no": {
"bomb_type": {
"Atomic Bomb": {
"detonation_area": {
"large": "poligon",
"small": "detonate"
}
},
"Chemical Bomb": {
"detonation_duration": {
"immediate": {
"detonation_area": {
"large": "poligon",
"small": {
"size": {
"large": "detonate",
"medium": "detonate",
"small": "poligon"
}
}
}
},
"long": {
"size": {
"large": {
"detonation_area": {
"large": "poligon",
"small": "detonate"
}
},
"medium": "poligon",
"small": "poligon"
}
},
"none": "poligon",
"short": "detonate"
}
},
"Claymore": {
"detonation_area": {
"large": {
"detonation_duration": {
"immediate": {
"size": {
"large": "detonate",
"medium": "poligon",
"small": "poligon"
}
},
"long": "poligon",
"none": "poligon",
"short": "poligon"
}
},
"small": {
"size": {
"large": {
"detonation_duration": {
"immediate": "poligon",
"long": "poligon",
"none": "detonate",
"short": "detonate"
}
},
"medium": {
"detonation_duration": {
"immediate": "detonate",
"long": "poligon",
"none": "poligon",
"short": "poligon"
}
},
"small": "detonate"
}
}
}
},
"Decoy": "poligon",
"Land Mine": {
"detonation_duration": {
"immediate": "detonate",
"long": {
"size": {
"large": "poligon",
"medium": "detonate",
"small": "detonate"
}
},
"none": "poligon",
"short": "poligon"
}
}
}
},
"yes": {
"bomb_type": {
"Atomic Bomb": {
"detonation_area": {
"large": "defuse",
"small": "detonate"
}
},
"Chemical Bomb": "defuse",
"Claymore": {
"detonation_duration": {
"immediate": {
"detonation_area": {
"large": {
"size": {
"large": "poligon",
"medium": "defuse",
"small": "poligon"
}
},
"small": {
"size": {
"large": "detonate",
"medium": "poligon",
"small": "detonate"
}
}
}
},
"long": {
"size": {
"large": {
"detonation_area": {
"large": "detonate",
"small": "defuse"
}
},
"medium": "defuse",
"small": "defuse"
}
},
"none": "defuse",
"short": {
"size": {
"large": "defuse",
"medium": {
"detonation_area": {
"large": "poligon",
"small": "detonate"
}
},
"small": "defuse"
}
}
}
},
"Decoy": "poligon",
"Land Mine": {
"detonation_duration": {
"immediate": "defuse",
"long": "defuse",
"none": "poligon",
"short": "defuse"
}
}
}
}
}
}
{"defusable": {"no": {"bomb_type": {"Atomic Bomb": {"detonation_area": {"large": "poligon", "small": "detonate"}}, "Chemical Bomb": {"detonation_duration": {"immediate": {"detonation_area": {"large": "poligon", "small": {"size": {"large": "detonate", "medium": "detonate", "small": "poligon"}}}}, "long": {"size": {"large": {"detonation_area": {"large": "poligon", "small": "detonate"}}, "medium": "poligon", "small": "poligon"}}, "none": "poligon", "short": "detonate"}}, "Claymore": {"detonation_area": {"large": {"detonation_duration": {"immediate": {"size": {"large": "detonate", "medium": "poligon", "small": "poligon"}}, "long": "poligon", "none": "poligon", "short": "poligon"}}, "small": {"size": {"large": {"detonation_duration": {"immediate": "poligon", "long": "poligon", "none": "detonate", "short": "detonate"}}, "medium": {"detonation_duration": {"immediate": "detonate", "long": "poligon", "none": "poligon", "short": "poligon"}}, "small": "detonate"}}}}, "Decoy": "poligon", "Land Mine": {"detonation_duration": {"immediate": "detonate", "long": {"size": {"large": "poligon", "medium": "detonate", "small": "detonate"}}, "none": "poligon", "short": "poligon"}}}}, "yes": {"bomb_type": {"Atomic Bomb": {"detonation_area": {"large": "defuse", "small": "detonate"}}, "Chemical Bomb": "defuse", "Claymore": {"detonation_duration": {"immediate": {"detonation_area": {"large": {"size": {"large": "poligon", "medium": "defuse", "small": "poligon"}}, "small": {"size": {"large": "detonate", "medium": "poligon", "small": "detonate"}}}}, "long": {"size": {"large": {"detonation_area": {"large": "detonate", "small": "defuse"}}, "medium": "defuse", "small": "defuse"}}, "none": "defuse", "short": {"size": {"large": "defuse", "medium": {"detonation_area": {"large": "poligon", "small": "detonate"}}, "small": "defuse"}}}}, "Decoy": "poligon", "Land Mine": {"detonation_duration": {"immediate": "defuse", "long": "defuse", "none": "poligon", "short": "defuse"}}}}}}

View File

@ -1,5 +1,5 @@
import pygame
from Constants import ROWS, COLS, UP, LEFT, DOWN, RIGHT
from Constants import ROWS, COLS, UP, LEFT, DOWN, RIGHT, DETONATE, DEFUSE, POLIGON
class Agent(object):
@ -28,7 +28,12 @@ class Agent(object):
def getOrientation(self):
return self.orientation
def changeImage(self, imageType):
if imageType == DETONATE:
self.image = pygame.image.load('Engine/' + DETONATE + '.png')
if imageType == DEFUSE:
self.image = pygame.image.load('Engine/' + DEFUSE + '.png')
self.image = pygame.image.load('Engine/agent.png')
# def ifNotOnEdge(self, destination):

View File

@ -109,8 +109,6 @@ class BfsPathFinder:
def checkGoal(self, current):
if current.state.getPoint() in self.board.bombMap:
bomb = self.board.getBomb(current.state.getPoint())
self.dTree.key(self.dTree.tree, bomb)
self.goal = Node(current,DEFUSE)
return True
return False

View File

@ -1,7 +1,7 @@
import random
import pygame
from Constants import SQUARE_SIZE, GREEN, RIGHT, LEFT, UP, DOWN, COLS, ROWS, DECOY, ATOMIC_BOMB, CHEMICAL_BOMB, MOVE, CLAYMORE, LAND_MINE
from Constants import SQUARE_SIZE, GREEN, RIGHT, LEFT, UP, DOWN, COLS, ROWS, DECOY, ATOMIC_BOMB, CHEMICAL_BOMB, MOVE, CLAYMORE, LAND_MINE, DEFUSE, DETONATE, POLIGON
from Engine.Board import Board
from Engine.Agent import Agent
from Engine.BombFactory import BombFactory
@ -13,6 +13,8 @@ from Engine.PathFinder import PathFinder
from Engine.Mud import Mud
from Engine.DecisionTree import DecisionTree
class Game:
def __init__(self, win):
self._init(win)
@ -29,7 +31,6 @@ class Game:
self.dTree = DecisionTree(False)
def update(self):
self.defuseBomb()
self.board.drawSquares(self.win)
self.board.drawBombs()
self.board.drawStones()
@ -108,6 +109,7 @@ class Game:
return BombFactory.create(LAND_MINE)
def findBomb(self):
self.agent.changeImage("default")
# return BfsPathFinder(self.board).findBomb(State(self.agent.getOrientation(),Point(self.agent.getPoint().getX(),self.agent.getPoint().getY())))
return PathFinder(self.board,self.dTree).findBomb(State(self.agent.getOrientation(),Point(self.agent.getPoint().getX(),self.agent.getPoint().getY())))
@ -163,6 +165,23 @@ class Game:
self.agent.point.y += 1
else:
self.agent.point.y -= 1
elif action == DEFUSE:
self.defuseAction()
elif action == DETONATE:
self.detonateAction()
elif action == POLIGON:
self.poligionAction()
def defuseAction(self):
self.agent.changeImage(DEFUSE)
self.defuseBomb()
def detonateAction(self):
self.agent.changeImage(DETONATE)
def poligionAction(self):
self.defuseBomb()

BIN
Engine/defuse.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
Engine/detonate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.