Skip to content

Commit

Permalink
Get kart action
Browse files Browse the repository at this point in the history
  • Loading branch information
bpiwowar committed Oct 24, 2023
1 parent d111d46 commit f35ecdd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
name: Upload if release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
# if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/setup-python@v4
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG_PYSTK.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This file documents notable changes to PySTK2 across versions since its inception.

## Version 0.3.3

- feature: get the action of a given kart

## Version 0.3.2

- New kart information: skidding factor
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
author = 'Benjamin Piwowarski'

# The short X.Y version
version = '0.3.2'
version = '0.3.3'

# The full version, including alpha/beta/rc tags
release = version
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"

[project]
name = "PySuperTuxKart2"
version = "0.3.2"
version = "0.3.3"
description="Python bindings for SuperTuxKart"
readme = "README.md"
authors = [
Expand Down
1 change: 1 addition & 0 deletions pystk_cpp/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ PYBIND11_MODULE(pystk2, m) {
.def(py::init<const PySTKRaceConfig &>(),py::arg("config"))
.def("restart", &PySTKRace::restart,"Restart the current track. Use this function if the race config does not change, instead of creating a new SuperTuxKart object")
.def("start", &PySTKRace::start,"start the race")
.def("get_kart_action", &PySTKRace::getKartAction, "Get a kart control state")
.def("step", (bool (PySTKRace::*)(const std::vector<PySTKAction> &)) &PySTKRace::step, py::arg("action"), "Take a step with an action per agent")
.def("step", (bool (PySTKRace::*)(const PySTKAction &)) &PySTKRace::step, py::arg("action"), "Take a step with an action for agent 0")
.def("step", (bool (PySTKRace::*)()) &PySTKRace::step, "Take a step without changing the action")
Expand Down
11 changes: 11 additions & 0 deletions pystk_cpp/pystk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,17 @@ void PySTKRace::stop() {
// World::getWorld()->update();
}
}

PySTKAction PySTKRace::getKartAction(std::size_t kart_ix) {
PySTKAction action;

KartControl const & control = World::getWorld()->getPlayerKart(kart_ix)->getControls();
action.get(&control);

return action;
}


void PySTKRace::render(float dt) {
World *world = World::getWorld();
#ifndef SERVER_ONLY
Expand Down
1 change: 1 addition & 0 deletions pystk_cpp/pystk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,5 @@ class PySTKRace {
const std::vector<std::shared_ptr<PySTKRenderData> > & render_data() const { return render_data_; }
#endif // SERVER_ONLY
const PySTKRaceConfig & config() const { return config_; }
PySTKAction getKartAction(std::size_t);
};

0 comments on commit f35ecdd

Please sign in to comment.