Skip to content

Commit

Permalink
Merge remote-tracking branch 'araya/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
martinpoliak-goodai committed Nov 15, 2022
2 parents 5e5b3c5 + 512e356 commit aa6d781
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ The user study is planned to run from the duration of November 2022.
## Development
This project requires Python 3. The `PCGSEPy` library (including its requirements) can be installed by running `pip install -e .`. To use PyTorch in the library (required for some research experiments, but not the apps), first set the `use_torch` flag in `configs.ini`.

We recommend creating a conda environment for the application. Make sure to install [orca](https://github.com/plotly/orca) via `conda install -c plotly plotly-orca` in case the spaceship download hangs (spinner on the top right remains visible for over 30 seconds to a minute).

### Building the apps
The apps can be built using the provided `.py` files placed in the `user-study` folder. The executable files will be created in the `user-study\dist` folder.

Expand Down Expand Up @@ -95,4 +97,4 @@ Starting from an initial population of vessels, you can select a spaceship to "e
> [Gallotta, R., Arulkumaran, K., & Soros, L. B. (2022). Surrogate Infeasible Fitness Acquirement FI-2Pop for Procedural Content Generation. In _IEEE Conference on Games_.](https://ieeexplore.ieee.org/document/9893592)
> [Gallotta, R., Arulkumaran, K., & Soros, L. B. (2022). Preference-Learning Emitters for Mixed-Initiative Quality-Diversity Algorithms. _arXiv preprint arXiv:2210.13839._]( https://arxiv.org/abs/2210.13839)
> [Gallotta, R., Arulkumaran, K., & Soros, L. B. (2022). Preference-Learning Emitters for Mixed-Initiative Quality-Diversity Algorithms. _arXiv preprint arXiv:2210.13839_.]( https://arxiv.org/abs/2210.13839)
3 changes: 3 additions & 0 deletions pcgsepy/guis/main_webapp/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,8 +1515,11 @@ def write_archive(bytes_io):
logging.getLogger('webapp').debug(msg=f'[{__name__}.write_archive] Started function, writing zip file...')
content_fig = go.Figure(data=curr_content['data'],
layout=curr_content['layout'])
logging.getLogger('webapp').debug(msg=f'[{__name__}.write_archive] Created thumbnail from plot...')
content_fig.update_layout(scene_camera=curr_camera.get('scene.camera', None))
logging.getLogger('webapp').debug(msg=f'[{__name__}.write_archive] Updated thumbnail camera...')
thumbnail_img = content_fig.to_image(format="png")
logging.getLogger('webapp').debug(msg=f'[{__name__}.write_archive] Converted to image...')
zf.writestr('thumb.png', thumbnail_img)
logging.getLogger('webapp').debug(msg=f'[{__name__}.write_archive] Loaded and saved thumbnail.')
elite = get_elite(mapelites=app_settings.current_mapelites,
Expand Down
3 changes: 3 additions & 0 deletions pcgsepy/mapelites/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ def _prepare_cs_content(self,
threadsafe_hullbuilder.add_external_hull(structure=cs.content)
# set the color
cs.content.set_color(color=cs.base_color)
# rotate according to tileset orientation
# TODO: this is hardcoded, but should be read from a config file
cs.content.rotate(along=1, k=3)
return cs

def _set_behavior_descriptors(self,
Expand Down
33 changes: 33 additions & 0 deletions pcgsepy/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ def sanify(self) -> None:
self._blocks = updated_blocks
self._scaled_arr = None
self._arr = None
self._air_gridmask = None

def update(self, origin: Vec,
orientation_forward: Vec,
Expand All @@ -445,7 +446,39 @@ def update(self, origin: Vec,
self.orientation_up = orientation_up
# update all blocks accordingly
self.sanify()

def rotate(self,
along: int,
k: int) -> None:
"""Rotate the structure along an axis _k_ times ccw.
Args:
along (int): The axis to rotate along (0, 1, 2).
k (int): How many times to rotate for in the ccw direction.
"""
rotated_blocks = {}
along = along % 3
k = k % 4
if k > 0:
for idx, block in self._blocks.items():
x, y, z = idx
if along == 0:
if k == 1: p1 = Vec(x=x, y=-z, z=-y)
elif k == 2: p1 = Vec(x=x, y=-y, z=z)
elif k == 3: p1 = Vec(x=x, y=-z, z=y)
elif along == 1:
if k == 1: p1 = Vec(x=z, y=y, z=x)
elif k == 2: p1 = Vec(x=-x, y=y, z=-z)
elif k == 3: p1 = Vec(x=-z, y=y, z=-x)
elif along == 2:
if k == 1: p1 = Vec(x=y, y=-x, z=z)
elif k == 2: p1 = Vec(x=-x, y=-y, z=z)
elif k == 3: p1 = Vec(x=-y, y=x, z=z)
rot_idx = p1.as_tuple()
rotated_blocks[rot_idx] = block
self._blocks = rotated_blocks
self.sanify()

def get_all_blocks(self,
to_place: bool = True,
scaled: bool = False) -> List[Block]:
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
"dash-bootstrap-components >= 1.2.1",
"dash-core-components >= 2.0.0",
"dash-html-components >= 2.0.0",
"kaleido >= 0.2.1",
"kaleido == 0.0.1",
"matplotlib >= 3.5.1",
"numpy >= 1.22.3",
"pandas >= 1.4.2",
"plotly == 5.5.0",
# "plotly-orca == 1.3.1",
"pyinstaller >= 5.2",
"psutil == 5.9.0",
"scipy >= 1.8.0",
"simplejson >= 3.17.6",
"sklearn >= 0.0",
Expand Down

0 comments on commit aa6d781

Please sign in to comment.