Skip to content

Guesstimation of total pawns by id() #134

@cooljoseph1

Description

@cooljoseph1

One can estimate the number of total pawns on its team by using the id() function.

import random

a = []

def turn():
    global a
    a = [random.random() for i in range(999)]

    log(str(id(a[-1])))
    
    board_size = get_board_size()
    team = get_team()
    opp_team = Team.WHITE if team == Team.BLACK else team.BLACK
    robottype = get_type()

    if robottype == RobotType.OVERLORD:
        if team == Team.WHITE:
            index = 0
        else:
            index = board_size - 1

        for i in range(board_size):
            if not check_space(index, i):
                spawn(index, i)
                break

    else:
        pass

What's happening is that 999 new objects are created each time the turn function is run. This causes the id's to increase over time, and so by comparing the id's from last turn to the most recent turn, the robot can estimate the number of robots on its team.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions