-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.py
32 lines (25 loc) · 822 Bytes
/
Cell.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
from random import *
import numpy as np
class Cell:
def __init__(self, value = [], context = 0):
self.value = value
self.context = context
def __str__(self):
return str(self.value)
def size(self):
return len(self.value)
def randomchoice(self):
return random.choice(self.value)
def bool(self):
lb = np.array([False] * self.context)
for i in self.value: lb[i] = True
return lb
def collapse(self, probability_list):
item_prob_list = []
for item in self.value:
item_prob_list.append(probability_list[item])
# chooses depending on weight
rand = choices(self.value, item_prob_list, k = 1)
self.value = [rand[0]]
def add_base_values(self, n):
self.value = list(range(n))