-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhospital.py
38 lines (31 loc) · 1.01 KB
/
hospital.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
from config import *
class Hospital(object):
def __init__(self):
self.bed_num = BED_NUM # 床位
self.beds = np.empty(shape=(0, 3), dtype=int)
# 床位矩阵
bed_matrix_line = int(self.bed_num / 20) # 行
bed_matrix_column = int(self.bed_num / bed_matrix_line) # 列
for i in range(bed_matrix_column):
for j in range(bed_matrix_line):
bed = [[i, j, IDLE_STATU]]
self.beds = np.r_[self.beds, bed]
def get_bed(self):
# 空床位的行号
try:
bed_line = np.where(self.beds[:, 2] == 0)[0][0]
self.beds[bed_line, 2] = OCCUPY_STATUS # 占用
return self.beds[bed_line]
except:
return np.array([]) # 没有床位
def get_x(self):
return self.beds[:, 0]
def get_y(self):
return self.beds[:, 1]
def get_bed_status(self):
'''
获得床位状态
:return:
'''
return self.beds[:, 2]