Skip to main content

tcship

python package for tcship race.

INSTALL

pip install tcship

SAMPLE

default with display

from tcShip import tc_ship,config
import random

def step_model(env, observation):
    ship = observation["body"][0]
    t1 = observation["target"][0]
    t2 = observation["target"][1]
    stone = observation['stone']

    # 曼哈顿距离
    d1 = abs(t1[0] - ship[0]) + abs(t1[1] - ship[1])
    d2 = abs(t2[0] - ship[0]) + abs(t2[1] - ship[1])
    if d1 > d2:
        i = 1
    else:
        i = 0
    # 最近星球坐标
    target = observation["target"][i]

    if ship[0] > target[0]:
        next_step = "left"
        next_ship = [ship[0] - 1, ship[1]]
    elif ship[0] < target[0]:
        next_step = "right"
        next_ship = [ship[0] + 1, ship[1]]
    else:
        next_step = "down"
        next_ship = [ship[0], ship[1] + 1]
    # 思考下什么时候向上或者向下?
    # elif ship[1] > target[1]:
    #     next_step =  "up"
    #     next_ship = [ship[0], ship[1] - 1]

    #检查下下一步会不会撞上陨石
    if next_ship not in stone:
        return next_step
    #仿照检测陨石,如何实现增加检测边界横坐标和纵坐标都不能 < 0或 > 16 ?#and ?>=0 and ?<= 16
    else:
        safe_action = ["right","left","up","down"]
        safe_action.remove(next_step)
        #思考是否有更好的方向选择替代随机选择?让飞船更快走到行星,以及此时随机选择出来的方向就一定安全么?
        #比如同时可以选的方向为"up"和"down",如果行星在飞船上方,那我们优先选择"up"。
        return random.choice(safe_action)
        ##思考下飞船方向能不能直接回头?如何避免?
        # global last_action
        # if last_action == "left" and action == "right":

def main():
    env = tc_ship()
    observation = env.reset()
    rew = 0
    for _ in range(100):
        action = step_model(env, observation)
        print(action)
        observation, reward, done, info = env.step(action)
        rew += reward
        env.sleep(0.5)

        if done:
            print("rew :  " + str(rew))
            break

main()

config no display

from tcShip import tc_ship, config
import random

config.WORKSPACE = "tianchi" #"local"则展示可视化动画
#正式版代码模版 
def step_model(env, observation):
    action_space = env.action_space
    action = random.choice(action_space)
    return action

def main():
    env = tc_ship()
    observation = env.reset()
    rew = 0
    for _ in range(100):
        action = step_model(env, observation)
        print(action)
        observation, reward, done, info = env.step(action)
        rew += reward
        env.sleep(0.5)

        if done:
            print("rew :  " + str(rew))
            break

main()

Metadata

Release files for tcShip 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tcShip 0.0.1
File Size Uploaded Provenance
tcShip-0.0.1.tar.gz 6.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tcShip 0.0.1
File Interpreter ABI Platform
tcShip-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / tcShip-0.0.1.tar.gz

Download URL tcShip-0.0.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
08d9456da847dccb3f439cdac0254b579b2f1c50422530ad421ee4b6af865024
BLAKE2b-256 checksum
How to use checksums
f9ccfa88b43b82dd026b2114e8809d53006195e54fa6597f2a1a869ba52c6328
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Release files / tcShip-0.0.1-py3-none-any.whl

Download URL tcShip-0.0.1-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0e4f2fc3a47919ec615d50b3edcda173b6500de0053f1b955e615bb1617d072
BLAKE2b-256 checksum
How to use checksums
99550938b04f5c07c332de2c0c4c84bdd6f1330ca4eb7e31d0e71d5806e31723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Security for tcShip 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page