Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0b3a695
start moving everything round for multiprocess architecture
nvaytet Oct 25, 2023
a7e5029
update main
nvaytet Oct 25, 2023
2efc55c
update main
nvaytet Oct 25, 2023
46003cf
update tracers in engine
nvaytet Oct 25, 2023
82b50bc
update tracers from engine
nvaytet Oct 25, 2023
2a200a0
update
nvaytet Oct 25, 2023
6fb894c
start adding players
nvaytet Oct 25, 2023
fc53443
fix map
nvaytet Nov 21, 2023
83bed01
better randomize tracer positions
nvaytet Feb 6, 2024
8e43487
refactor using dict of buffers
nvaytet Feb 6, 2024
3fdc6a1
add players on globe
nvaytet Feb 6, 2024
d88adfa
spawn graphics
nvaytet Feb 12, 2024
a4fb1f3
add player tracks
nvaytet Feb 12, 2024
435cae3
add player bots, but there is bug in tracks
nvaytet Feb 12, 2024
4295f21
better exit, fix tracks and connect widgets
nvaytet Feb 12, 2024
9e2fad8
update
nvaytet Feb 12, 2024
26a3bdc
fix flickering tracer points
nvaytet Mar 8, 2024
126e926
add players on scoreboard
nvaytet Mar 9, 2024
8e8b799
update
nvaytet Mar 9, 2024
e71612e
updtae
nvaytet Mar 12, 2024
6634582
update again
nvaytet Mar 12, 2024
5c1d8e7
still something funny with shutting down
nvaytet Mar 12, 2024
d090d4b
fix shutdown mechanism
nvaytet Mar 18, 2024
9d724d9
cleanup
nvaytet Mar 18, 2024
5e4a835
weather forecast and cleanup
nvaytet Mar 19, 2024
c70f736
flake8
nvaytet Mar 19, 2024
c31e9a1
new high contrast texture
nvaytet Jun 5, 2024
df121d0
use better scores
nvaytet Jun 5, 2024
fba3ef9
change map and weather to callable
nvaytet Jun 7, 2024
604a353
fix tracers not updating when boats on other processes are still running
nvaytet Jun 7, 2024
ce0acd8
add end round button
nvaytet Jun 7, 2024
50a60ee
fix scores
nvaytet Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
# See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
max-line-length = 88
extend-ignore = "E203"
extend-ignore = E203
30 changes: 30 additions & 0 deletions run/play.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-License-Identifier: BSD-3-Clause
import vendeeglobe as vg
from template_bot import Bot2

nbots = 200

# ais = np.random.choice([Bot, Bot2], nbots)
ais = [Bot2] * nbots

# players = {
# "Alice": Bot,
# "Bob": Bot2,
# "Charlie": Bot,
# "David": Bot2,
# "Eve": Bot,
# "Frank": Bot2,
# }


start = None
# start = vg.Location(longitude=-68.004373, latitude=18.180470)

bots = []
for i, ai in enumerate(ais):
bots.append(ai())
bots[-1].team = f"Team-{i}"

# start = bots[-1].course[-3]

vg.play(bots=bots, start=start, seed=None, ncores=10, high_contrast=False)
46 changes: 30 additions & 16 deletions run/template_bot.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# SPDX-License-Identifier: BSD-3-Clause

# flake8: noqa F401

from collections.abc import Callable
import numpy as np

from vendeeglobe import (
Checkpoint,
Heading,
Instructions,
Location,
MapProxy,
Vector,
WeatherForecast,
# MapProxy,
# WeatherForecast,
config,
)
from vendeeglobe.utils import distance_on_surface

# This is your team name
CREATOR = "TeamName"

def add_spread(course, spread=0.2):
for ch in course[:-1]:
ch.latitude += np.random.uniform(-spread, spread)
ch.longitude += np.random.uniform(-spread, spread)


class Bot:
Expand All @@ -26,7 +27,7 @@ class Bot:
"""

def __init__(self):
self.team = CREATOR # Mandatory attribute
self.team = "TeamName" # Mandatory attribute
self.avatar = 1 # Optional attribute
self.course = [
Checkpoint(longitude=-45.5481686, latitude=39.0722068, radius=200),
Expand Down Expand Up @@ -56,8 +57,10 @@ def __init__(self):
radius=5,
),
]
# for ch in self.course[:9]:
# ch.reached = True
for ch in self.course[:-3]:
ch.reached = True

# add_spread(self.course)

def run(
self,
Expand All @@ -68,8 +71,8 @@ def run(
heading: float,
speed: float,
vector: np.ndarray,
forecast: WeatherForecast,
map: MapProxy,
forecast: Callable,
world_map: Callable,
):
"""
This is the method that will be called at every time step to get the
Expand All @@ -96,6 +99,10 @@ def run(
map:
The map of the world: 1 for sea, 0 for land.
"""
current_position_forecast = forecast(
latitudes=latitude, longitudes=longitude, times=0
)
current_position_terrain = world_map(latitudes=latitude, longitudes=longitude)
instructions = Instructions()
for ch in self.course:
dist = distance_on_surface(
Expand Down Expand Up @@ -126,7 +133,7 @@ class Bot2:
"""

def __init__(self):
self.team = CREATOR # Mandatory attribute
self.team = "TeamName" # Mandatory attribute
self.avatar = 2 # Optional attribute
self.course = [
Checkpoint(latitude=43.797109, longitude=-11.264905, radius=50),
Expand All @@ -139,6 +146,7 @@ def __init__(self):
Checkpoint(latitude=-15.668984, longitude=77.674694, radius=1190.0),
Checkpoint(latitude=-39.438937, longitude=19.836265, radius=50.0),
Checkpoint(latitude=14.881699, longitude=-21.024326, radius=50.0),
Checkpoint(latitude=43, longitude=-19, radius=5),
Checkpoint(latitude=44.076538, longitude=-18.292936, radius=50.0),
Checkpoint(
latitude=config.start.latitude,
Expand All @@ -147,9 +155,11 @@ def __init__(self):
),
]

# for ch in self.course[:6]:
# for ch in self.course[:-3]:
# ch.reached = True

add_spread(self.course, 1.0)

def run(
self,
t: float,
Expand All @@ -159,9 +169,13 @@ def run(
heading: float,
speed: float,
vector: np.ndarray,
forecast: WeatherForecast,
map: MapProxy,
forecast: Callable,
world_map: Callable,
):
current_position_forecast = forecast(
latitudes=latitude, longitudes=longitude, times=0
)
current_position_terrain = world_map(latitudes=latitude, longitudes=longitude)
loc = None
for ch in self.course:
dist = distance_on_surface(
Expand Down
18 changes: 0 additions & 18 deletions run/test.py

This file was deleted.

2 changes: 1 addition & 1 deletion run/tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
module = importlib.import_module(f"{repo}")
bots.append(module.Bot())

vg.play(bots=bots, test=False)
vg.play(bots=bots, safe=True, ncores=8)
9 changes: 4 additions & 5 deletions src/vendeeglobe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
from .config import config
from .core import Checkpoint, Heading, Instructions, Location, Vector
from .engine import Engine
from .map import MapProxy
from .weather import WeatherForecast
from .main import play


def play(*args, **kwargs):
eng = Engine(*args, **kwargs)
eng.run()
# def play(*args, **kwargs):
# eng = Engine(*args, **kwargs)
# eng.run()
4 changes: 4 additions & 0 deletions src/vendeeglobe/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Config:
map_radius: float = 6371.0
resourcedir: Path = Path(__file__).parent / "resources"
ntracers: int = 5000
number_of_new_tracers = 2
tracer_lifetime: int = 50
start: Checkpoint = Checkpoint(longitude=-1.81, latitude=46.494275, radius=5.0)
checkpoints: Tuple[Checkpoint, Checkpoint] = (
Expand All @@ -27,6 +28,9 @@ class Config:
avatar_size = [64, 64]
score_step = 100_000
max_name_length = 15
max_track_length = 1000
fps = 30
time_limit: float = 8 * 60 # in seconds


config = Config()
Expand Down
4 changes: 1 addition & 3 deletions src/vendeeglobe/core.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

from dataclasses import dataclass
from typing import Optional, Tuple

import numpy as np
from typing import Optional


@dataclass
Expand Down
Loading