Skip to content

Список клеток, на которые дамка может ходить #21

Description

@Former
def NextPointsDamka(a_PointStart, a_Board):
    result = []
    #a_PointStart.x
    #a_PointStart.y
    #a_Board.GetWidht()
    #a_Board.GetHeight()
    item = a_Board.GetItem(a_PointStart)
    item.userID # Номер игрока
    if item.iType != BoardItemType.biDamka:
        return []
    # Ничего, шашка, дамка
    
    steps = [Point(1,1), Point(-1,-1), Point(1,-1), Point(-1,1)]
    for s in steps: # Перебираем разные направления
        p = a_PointStart
        
        #p1 = a_PointStart + s;
        #p2 = a_PointStart + s + s;
        
        step_count = 0
        while True:
            if p выйдет за границы доски:
                break
            cur_item = a_Board.GetItem(p)
            if step_count > 0 and cur_item.iType == biNone:
                result += [p]
            p += s
            step_count += 1

    return result

def TestNextPointsDamka():
     b = Board(8, 8)
     r = [GameRule(...), GameRule(...)]
     b.SetItem(....)
     assert NextPointsDamka(Point(1,1)) == [Point(1,1), Point(2,1)]

Сделать функцию, которая работает только с дамками по стандартным правилам

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions