Allow bot names 1-9 instead of 1-3
This commit is contained in:
1 parent
fb28fefc8a
commit
1dd02f887c
9 files changed
+75
-48
No files matched your search
+6
-4
@@ -1,6 +1,5 @@
|
||||
import importlib
|
||||
import collections
|
||||
import re
|
||||
from math import floor, ceil, sqrt
|
||||
|
||||
from mosfet.info import blocks
|
||||
@@ -26,12 +25,15 @@ def phyp(p1, p2):
|
||||
|
||||
|
||||
def bot_name_family(name):
|
||||
"""Return a bot username with all digits removed, case-insensitively."""
|
||||
return re.sub(r'\d', '', str(name)).casefold()
|
||||
"""Return the group name for a bot ending in one digit from 1 to 9."""
|
||||
name = str(name or '').casefold()
|
||||
if len(name) > 1 and name[-1] in '123456789':
|
||||
return name[:-1]
|
||||
return name
|
||||
|
||||
|
||||
def find_nearby_bots(global_state, position, distance):
|
||||
"""Find nearby online bots sharing this bot's digits-stripped name."""
|
||||
"""Find nearby online bots sharing this bot's numbered name family."""
|
||||
own_name = str(global_state.get('name', '') or '')
|
||||
family = bot_name_family(own_name)
|
||||
if not family:
|
||||
|
||||
+6
-30
@@ -125,11 +125,7 @@ class World:
|
||||
def find_throw_signs(self, center, bot_name, distance=105):
|
||||
"""Find nearby signs directing this bot to throw an item at them."""
|
||||
bot_name = str(bot_name).casefold()
|
||||
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
||||
bot_name[-1] in '123' else None)
|
||||
addresses = {bot_name}
|
||||
if group_name:
|
||||
addresses.add(group_name)
|
||||
addresses = {bot_name, utils.bot_name_family(bot_name)}
|
||||
|
||||
result = []
|
||||
for sign in self.find_signs(center, distance):
|
||||
@@ -163,11 +159,7 @@ class World:
|
||||
def find_sand_origins(self, center, bot_name, distance=200):
|
||||
"""Find signs addressed to this bot that designate a sand origin."""
|
||||
bot_name = str(bot_name).casefold()
|
||||
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
||||
bot_name[-1] in '123' else None)
|
||||
addresses = {bot_name}
|
||||
if group_name:
|
||||
addresses.add(group_name)
|
||||
addresses = {bot_name, utils.bot_name_family(bot_name)}
|
||||
|
||||
result = []
|
||||
for sign in self.find_signs(center, distance):
|
||||
@@ -188,11 +180,7 @@ class World:
|
||||
def find_safety_signs(self, center, bot_name, distance=80):
|
||||
"""Find nearby signs addressed to this bot that mark safe refuges."""
|
||||
bot_name = str(bot_name).casefold()
|
||||
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
||||
bot_name[-1] in '123' else None)
|
||||
addresses = {bot_name}
|
||||
if group_name:
|
||||
addresses.add(group_name)
|
||||
addresses = {bot_name, utils.bot_name_family(bot_name)}
|
||||
|
||||
result = []
|
||||
for sign in self.find_signs(center, distance):
|
||||
@@ -360,11 +348,7 @@ class World:
|
||||
def find_cache_chests(self, center, bot_name, distance=105):
|
||||
"""Find bot/group-addressed general cache chests from signs."""
|
||||
bot_name = str(bot_name).casefold()
|
||||
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
||||
bot_name[-1] in '123' else None)
|
||||
addresses = {bot_name}
|
||||
if group_name:
|
||||
addresses.add(group_name)
|
||||
addresses = {bot_name, utils.bot_name_family(bot_name)}
|
||||
|
||||
grouped = {}
|
||||
for sign in self.find_signs(center, distance):
|
||||
@@ -392,11 +376,7 @@ class World:
|
||||
def find_supply_chests(self, center, bot_name, distance=80):
|
||||
"""Find chests whose sign is addressed to this bot's supplies."""
|
||||
bot_name = str(bot_name).casefold()
|
||||
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
||||
bot_name[-1] in '123' else None)
|
||||
addresses = {bot_name}
|
||||
if group_name:
|
||||
addresses.add(group_name)
|
||||
addresses = {bot_name, utils.bot_name_family(bot_name)}
|
||||
|
||||
grouped = {}
|
||||
sign_offsets = (
|
||||
@@ -442,11 +422,7 @@ class World:
|
||||
def sign_policies(self, bot_name, distance=None):
|
||||
"""Parse sign policies addressed to this bot or its numbered group."""
|
||||
bot_name = str(bot_name).casefold()
|
||||
group_name = (bot_name[:-1] if len(bot_name) > 1 and
|
||||
bot_name[-1] in '123' else None)
|
||||
addresses = {bot_name}
|
||||
if group_name:
|
||||
addresses.add(group_name)
|
||||
addresses = {bot_name, utils.bot_name_family(bot_name)}
|
||||
|
||||
center = utils.pint(self.g.pos)
|
||||
policies = []
|
||||
|
||||
Reference in new issue
Block a user