惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
B
Blog RSS Feed
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
D
Docker
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
C
Check Point Blog
The Cloudflare Blog
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
量子位
The GitHub Blog
The GitHub Blog
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
T
The Blog of Author Tim Ferriss
博客园 - 【当耐特】
Vercel News
Vercel News
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
博客园 - 司徒正美

博客园 - PC167

caiquan0 sheeeeee loggggg ctrl const loginnnnn pauto Shenmi llllll controller ctypes helper python test 1 Index was outside the bounds of the array. (Microsoft.SqlServer.Smo) contains 方法 mysql connector 和 sqlserver ado.net 的区别 javascript slice javascript bind 转,SelectNodes + XPath jsgen 搭建 【转】基于第一个PhoneGap(cordova)的应用详解 回车和换行 html中空格转义字符 输出乘法表 sql server 相似度对比 sql server 2008 r2 报错 razor 拼接字符串 转,CV和resume的区别 b/s开发者的困境 sql 下,float和numeric
ato
PC167 · 2026-04-29 · via 博客园 - PC167
import time
from utils import win32_native as mykb
from utils.state import global_state
import utils.constants as pop_consts
import pyautogui

#scan codes
SC_UP    = 0x48
SC_LEFT  = 0x4B
SC_RIGHT = 0x4D
SC_DOWN  = 0x50

SC_F5 = 0x3F 
SC_CTRL=0x1D
SC_SPACE=0x39
SC_ESC=0x01
SC_ENTER=0x1C
SC_SHIFT=0x2A

def is_run_stopped():              
    pop_px = pyautogui.pixel(*pop_consts.MAP_CAR_BOARD_POS)       
    return pop_px != pop_consts.MAP_CAR_BOARD_COLOR

def wait_until_rush_finish():

    for rrr in range(50):
        time.sleep(1)
        pix = pyautogui.pixel(*pop_consts.MAP_PODIUM_POS)    
        if pix==pop_consts.MAP_PODIUM_COLOR:
            print('podium show up, checking race result')
            pix2 = pyautogui.pixel(*pop_consts.MAP_RANKING_POS)    
            if pix2==pop_consts.MAP_RANKING_COLOR:
                print('rush finished with ranking, return true')
                return True
            else:
                print('rush finished without ranking, return false')
                return False
 
    return False

def run9_blind():
    
    mykb.press(SC_F5)
    time.sleep(10)
    print('start running, hold up')
    global_state.check_run_task()
    time.sleep(5)
    mykb.hold(SC_UP) #hold up
    time.sleep(2)

    # --- PHASE 1: THE SPIRAL (0 to 85) ---
    print('Entering spiral...')
    for i in range(86): 
        mykb.hold(SC_RIGHT)
        time.sleep(0.5)#turn right for 0.5s
        mykb.release(SC_RIGHT)
        time.sleep(0.4)#run straight for 0.4s

    # --- PHASE 2: THE STRAIGHTAWAY (86 to 91) ---
    # (These slight right taps might be correcting for drift)
    print('Entering straightaway...')
    for i in range(6): 
        mykb.hold(SC_RIGHT)
        time.sleep(0.3)#turn right for 0.3s
        mykb.release(SC_RIGHT)
        time.sleep(1.5)#run straight for 1.5s
        if is_run_stopped():
            print('rush finished, break the straightaway loop at step:', i)
            break;

    print('route finished, turning stopped')
    #time.sleep(10)#581,702=62,70,84
    for i in range(30):
        if is_run_stopped():
            print('rush finished, release up')
            break
        time.sleep(1)

    mykb.release(SC_UP)#drive end
    print('drive end, release up, checking result')

    return wait_until_rush_finish()




def isHit9RoadSign(duration):

    start_time = time.monotonic()
    while time.monotonic() - start_time < duration:
        color = mykb.get_pixel(535, 70)
        if color == (255, 0, 0): # Red color
            return True
        time.sleep(0.05)  # Check every 50ms

    return False

def run9_eye():
    
    mykb.press(SC_F5)
    time.sleep(15)
    print('start running, hold up')
    mykb.hold(SC_UP) #hold up
    time.sleep(2)

    # --- PHASE 1: THE SPIRAL (0 to 85) ---
    print('Entering spiral...')

    for i in range(80): 
        mykb.hold(SC_RIGHT)
        time.sleep(0.5)#turn right for 0.5s
        mykb.release(SC_RIGHT)
        time.sleep(0.4)#run straight for 0.4s

    # --- PHASE 2: CHECK COLOR AND DECIDE WHETHER TO BREAK THE SPIRAL ---
    for i in range(10): 
        mykb.hold(SC_RIGHT)
        isHitColor = isHit9RoadSign(0.5)#check if hit the color while turning for 0.5s
        mykb.release(SC_RIGHT)

        if(isHitColor):
            print('hit color, break the spiral, entering straightaway...')
            break

        isHitColor = isHit9RoadSign(0.4)

        if(isHitColor):
            print('hit color, break the spiral, entering straightaway...')
            break
        

    # --- PHASE 3: THE STRAIGHTAWAY (86 to 91) ---
    # (These slight right taps might be correcting for drift)
    print('Entering straightaway...')
    for i in range(6): 
        mykb.hold(SC_RIGHT)
        time.sleep(0.3)#turn right for 0.3s
        mykb.release(SC_RIGHT)
        time.sleep(1.5)#run straight for 1.5s

    print('route finished, stop turning, waiting 10 seconds')
    time.sleep(10)
    mykb.release(SC_UP)#drive end
    print('drive end, release up, checking result')
  




def isRunFinished():
    # Check if th color at (100, 200) is red, which indicates the run has finished
    color = mykb.get_color(100, 200)
    return color == 789516 # RGB(12, 12, 12) in decimal


def isApproachingLeftWall():
    # Check if the color at (50, 300) is a specific shade of gray, which indicates approaching left wall
    color = mykb.get_color(50, 300)
    return color == 789516 # RGB(12, 12, 12) in decimal

def isApproachingRightWall():
    # Check if the color at (200, 300) is a specific shade of gray, which indicates approaching right wall
    color = mykb.get_color(200, 300)
    return color == 789516 # RGB(12, 12, 12) in decimal


def runLvZhou_blind():

    mykb.press(SC_F5)
    time.sleep(15)
    print('start running, hold up')
    mykb.hold(SC_UP) #hold up
    time.sleep(2)

    print('Entering route...')

    for i in range(150): 
        mykb.press(SC_CTRL)      
        mykb.press(SC_SPACE)
        time.sleep(1)#attack every 1s

    print('route finished, stop turning, waiting 10 seconds')
    time.sleep(10)
    mykb.release(SC_UP)#drive end
    print('drive end, release up, checking result');



def runLvZhou_eye():

    mykb.press(SC_F5)
    time.sleep(15)
    print('start running, hold up')
    mykb.hold(SC_UP) #hold up
    time.sleep(2)

    print('Entering route...')

    turn_start_time = time.monotonic() - 2 # Initialize to allow immediate turning

    for i in range(150): 
        if i>100 and isRunFinished():
            print('run finished, break the loop')
            mykb.release(SC_UP)#drive end
            break

        if isApproachingLeftWall():
            print('approaching left wall, turn right, only turn 1 time inside a second, in case of over turning')

            if time.monotonic() - turn_start_time > 1: # Only turn if more than 1 second has passed since last turn
                mykb.hold(SC_RIGHT)
                time.sleep(0.3)
                mykb.release(SC_RIGHT)
                turn_start_time = time.monotonic() # Update last turn time
                
        elif isApproachingRightWall():
            print('approaching right wall, turn left, only turn 1 time inside a second, in case of over turning')

            if time.monotonic() - turn_start_time > 1: # Only turn if more than 1 second has passed since last turn
                mykb.hold(SC_LEFT)
                time.sleep(0.3)
                mykb.release(SC_LEFT)
                turn_start_time = time.monotonic() # Update last turn time

        mykb.press(SC_CTRL)      
        mykb.press(SC_SPACE)
        time.sleep(0.5)#attack every 1s

    print('route finished, stop turning, waiting 10 seconds')

    print('drive end, release up, checking result');


if __name__ == "__main__":
    time.sleep(5) # Time to switch to the game window
    runLvZhou_blind()