File: tiles.py

package info (click to toggle)
prjtrellis 1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 83,000 kB
  • sloc: cpp: 20,813; python: 16,246; sh: 375; makefile: 262; asm: 80; ansic: 58
file content (18 lines) | stat: -rw-r--r-- 500 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import re
import pytrellis


def pos_from_name(tile, chip_size, row_bias, col_bias):
    """
    Extract the tile position as a (row, column) tuple from its name
    """
    size = pytrellis.make_IntPair(chip_size[0],chip_size[1])
    pos = pytrellis.get_row_col_pair_from_chipsize(tile, size, row_bias, col_bias)
    return int(pos.first), int(pos.second)


def type_from_fullname(tile):
    """
    Extract the type from a full tile name (in name:type) format
    """
    return tile.split(":")[1]