This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="chrome=1" /> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.callbacks import ModelCheckpoint | |
from keras.models import Sequential | |
from keras.layers import Dense, Activation, Flatten | |
from sklearn.model_selection import train_test_split | |
from sklearn.ensemble import RandomForestRegressor | |
from sklearn.metrics import mean_absolute_error | |
from matplotlib import pyplot as plt | |
import seaborn as sb | |
import matplotlib.pyplot as plt | |
import pandas as pd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_data(): | |
#get train data | |
train_data_path ='train.csv' | |
train = pd.read_csv(train_data_path) | |
#get test data | |
test_data_path ='test.csv' | |
test = pd.read_csv(test_data_path) | |
return train , test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Field: | |
def __init__(self, height=10, width=5): | |
self.width = width | |
self.height = height | |
self.body = np.zeros(shape=(self.height, self.width)) | |
def update_field(self,walls, player): | |
try: | |
# Clear the field: | |
self.body = np.zeros(shape=(self.height, self.width)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Wall: | |
def __init__(self, height = 5, width=100, hole_width = 20, | |
y = 0, speed = 1, field = None): | |
self.height = height | |
self.width = width | |
self.hole_width = hole_width | |
self.y = y | |
self.speed = speed | |
self.field = field | |
self.body_unit = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player: | |
def __init__(self, height = 5, max_width = 10 , width=2, | |
x = 0, y = 0, speed = 2): | |
self.height = height | |
self.max_width = max_width | |
self.width = width | |
self.x = x | |
self.y = y | |
self.speed = speed | |
self.body_unit = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attribute | Type | Description | |
---|---|---|---|
height | int | player's height | |
max_width | int | player's maximum width (must be less than field.width) | |
width | int | player's width (must be less than or equal to max_width and begger than 0) | |
x | int | player's x coordinate in the field | |
y | int | player's y coordinate in the field | |
speed | int | player's speed (how many horizontal units it moves per step) | |
body_unit | int ; float | the number used to represent the player in the array representation (in field.body) | |
body | np.array | the player's body | |
stamina | int ; float | player's energy (stamina) (when a player's energy hits zero the player dies) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attribute | Type | Description | |
---|---|---|---|
height | int | the wall's height | |
width | int | the wall's width ( the same value as the field's width) | |
hole_width | int | the hole's width (max value of hole_width should be field.width or wall.width) | |
y | int | the vertical coordinate of the wall (y axis) (max value of y should be field.height) | |
speed | int | speed of the wall (raw/step) | |
field | Field | the field that contains the wall | |
body_unit | int ; float | the number used to represent the wall in the array representation (in field.body) | |
body | np.array | the wall's body | |
out_of_range | bool | A flag used to delete the wall when it moves out of the field range. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Environment: | |
P_HEIGHT = 2 # Height of the player | |
F_HEIGHT = 20 # Height of the field | |
W_HEIGHT = 2 # Height of the walls | |
WIDTH = 10 # Width of the field and the walls | |
MIN_H_WIDTH = 2 # Minimum width of the holes | |
MAX_H_WIDTH = 6 # Maximum width of the holes | |
MIN_P_WIDTH = 2 # Minimum Width of the player | |
MAX_P_WIDTH = 6 # Maximum Width of the player | |
HEIGHT_MUL = 30 # Height Multiplier (used to draw np.array as blocks in pygame ) |
OlderNewer