Esempio n. 1
0
    def setUp(self):
        self.game = Game(3, 3, 3)

        self.cell1 = Cell(1, 3, 0)
        self.cell2 = Cell(2, 1, 0)
        self.cell3 = Cell(1, 1, 1)
        self.cell4 = Cell(2, 2, 0)
Esempio n. 2
0
    def setUp(self):

        self.cell1 = Cell(1, 1, 0)
        self.cell2 = Cell(1, 1, 1)

        self.line = Line([
            self.cell1,
            self.cell2
        ], 1)
 def setUp(self):
     self.player_one = Player("Gosho", 50, 2, 16)
     self.player_two = Player("Misho", 50, 2, 16)
     self.player_three = Player("Misho", 20, 2, 16)
     self.player_four = Player("Misho", 0, 2, 16)
     self.cards = [GoodCard(), BadCard(), TripCard()]
     self.field = [[{
         1: Cell(0, 0, self.cards)
     }, {
         2: Cell(0, 1, self.cards)
     }]]
     self.levels = {"SMALL": (1, 2), "MEDIUM": (2, 3), "LARGE": (3, 4)}
Esempio n. 4
0
def csv_convert_obj(path):
    _list = list()
    with open(path) as f:
        _csv = csv.reader(f, delimiter=';')
        if os.path.basename(path).lower().startswith('cell-'):
            for row in _csv:
                if list(row).__len__() == 5:
                    _list.append(Cell(row[1], row[2], row[3], row[4]))
        elif os.path.basename(path).lower().startswith('element-'):
            for row in _csv:
                if list(row).__len__() == 7:
                    _list.append(
                        Element(row[1], row[2], row[3], row[4], row[5],
                                row[6]))
        elif os.path.basename(path).lower().startswith('dimension-'):
            for row in _csv:
                if list(row).__len__() == 4:
                    _list.append(Dimension(row[1], row[2], row[3]))
        elif os.path.basename(path).lower().startswith('cube-'):
            for row in _csv:
                if list(row).__len__() == 5:
                    _list.append(Cube(row[1], row[2], row[3], row[4]))
        elif os.path.basename(path).lower().startswith('database-'):
            for row in _csv:
                if list(row).__len__() == 3:
                    _list.append(Database(row[1], row[2]))
    return _list
Esempio n. 5
0
def parse_dim(dim_file, num_cells):
    with open(dim_file) as dim:
        core = Core(numberify(dim.readline().split()))

        cells = []
        for i in range(num_cells):
            cell = Cell(i+1, floatify(dim.readline().split(",")))
            cells.append(cell)

        return core, cells
Esempio n. 6
0
    def test_can_add_a_cell_to_a_line(self):

        """
        Test can add a cell to a line and increment count for line cells
        """

        cells_count = len(self.line.cells)

        self.line.add(Cell(1, 1, 2))

        self.assertEqual(cells_count + 1, len(self.line.cells))
        self.assertEqual(self.line.cells_count, len(self.line.cells))
Esempio n. 7
0
    def create(self, request):
        cell = Cell(owner=request.user)
        form = CellCreateForm(request.user, request.POST, instance=cell)
        if not form.is_valid():
            raise APIBadRequest(form.errors)

        form.save()

        rev = form.instance.cellrevision_set.all()[0]
        rev.resource = form.cleaned_data['resource']
        rev.save()

        return form.instance
Esempio n. 8
0
def addMapWithCells(db, mapData, zonesRadius, cellList):
	map_ = Map(id=mapData[0], name=mapData[1], maxX=mapData[2], maxY=mapData[3])
	db.session.add(map_)
	db.session.flush()

	for i in range(0, len(cellList)):
		for j in range(0, len(cellList[0])):
			if cellList[i][j] == 0:
				continue

			r = 0 if (cellList[i][j] == -1 or cellList[i][j] == 0) else zonesRadius[cellList[i][j]]
			cell = Cell(map=mapData[0], value=cellList[i][j], radius=r, posX=j, posY=i)
			db.session.add(cell)
			db.session.flush()

	db.session.commit()

	print ('Added map {0}'.format(mapData[1]))
Esempio n. 9
0
def insert_row(calendar, current_user, date):
    row = CalendarRow(parent=calendar.key)
    row.put()

    cell_keys = []
    for i in range(len(calendar.column_names)):
        cell = Cell(parent=row.key)
        cell.put()
        cell_keys.append(cell.key)

    date_cell = DateCell(parent=row.key, date=date)
    date_cell.put()

    row.cell_keys = cell_keys
    row.date_cell = date_cell.key
    row.put()
    calendar.row_keys.append(row.key)
    calendar.put()
Esempio n. 10
0
    def test_can_return_matching_lines_for_cell(self):

        """
        Test can return a matching line for a cell
        """

        line = Line([
            self.cell1,
        ], 1)

        line2 = Line([
            self.cell3
        ], 1)

        self.game.lines = [line, line2]

        cell = Cell(1, 2, 1)

        matches = self.game.get_matching_lines_for_cell(cell)

        self.assertEqual(len(matches), 2)
Esempio n. 11
0
 def setUp(self):
     self.cell = Cell(1, 1, 1)
Esempio n. 12
0
type_list = ['Tumorous', 'Red', 'White']
nano_virus = Virus()

cell_objects = {}
distance_cells = []

tumorous_cells = []
red_cells = []
white_cells = []

count_1 = count_2 = count_3 = 0
i = 100

while i > 0:
    cell_objects[i] = Cell()
    rand_prop = numpy.random.choice(numpy.arange(1, 4), p=[0.05, 0.25, 0.70])
    cell_objects[i].set_type(type_list[rand_prop - 1])
    i = i - 1


def calculate_distance(cell1, cell2):
    distance = sqrt((cell1.get_x() - cell2.get_x())**2 +
                    (cell1.get_y() - cell2.get_y())**2 +
                    (cell1.get_z() - cell2.get_z())**2)
    return distance


def locate_cell_by_type(cell_objects):
    c = len(cell_objects)
    for cels in range(1, 101):
 def test_initial_values_Cell(self):
     cards = [BadCard(), GoodCard(), TripCard()]
     obj_1 = Cell(1, 2, cards)
     assert obj_1.row == 1
     assert obj_1.col == 2
     assert obj_1.cards == cards
 def test_no_value(self):
     with pytest.raises(Exception) as e_info:
         obj = Cell()