Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Avatar's own view of the world #223

Merged
merged 27 commits into from
Sep 4, 2017
Merged

Avatar's own view of the world #223

merged 27 commits into from
Sep 4, 2017

Conversation

ramonfmir
Copy link
Contributor

Each avatar now holds an AvatarView instance. It calculates the cells to be created and the cells to be deleted after every move action according to the radius specified and the avatar location. This takes full advantage of the updates-based API (PR #219 - merged) by ensuring that there are no redundant objects in the scene, which will become important when we use the Unity project for the front-end since having a lightweight scene will improve both the loading time and the FPS. Also, this avatar view is a must if we want to have infinitely large maps.

… fix the out-of-bounds issue in the world map.
…no sense, since it is global for all the players...
…. This won't work with multiple users. Right now it would work, but the same score point might be tried to be added/deleted multiple times. The Unity client is prepared to handle this but we should think of a nicer fix.
@ramonfmir ramonfmir requested a review from danalex97 August 22, 2017 12:50
@ramonfmir ramonfmir self-assigned this Aug 22, 2017
@@ -2,7 +2,8 @@
import requests

from simulation.action import ACTIONS, MoveAction, WaitAction

from simulation.location import Location
from avatar_view import AvatarView
Copy link
Contributor

@danalex97 danalex97 Aug 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Avatar view should be imported absolutely.

@@ -19,7 +19,7 @@ def __ne__(self, other):
return not self == other

def __hash__(self):
return hash((self.x, self.y))
return hash(str(self.x) + ":" + str(self.y))
Copy link
Contributor

@danalex97 danalex97 Aug 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I think the old hashing function would be better.

danalex97
danalex97 previously approved these changes Aug 23, 2017
This was referenced Aug 28, 2017
from simulation.location import Location
from simulation.direction import EAST, WEST, NORTH, SOUTH
from simulation.avatar.avatar_view import AvatarView

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Cell(location)
else:
raise ValueError

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.NE_horizon += move_direction
self.NW_horizon += move_direction
self.SE_horizon += move_direction
self.SW_horizon += move_direction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line in the end please

# Deletion
for cell in avatar_view.cells_to_clear:
# There is an avatar.
if not cell.avatar is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, if cell.avatar is not None: :)

avatar_view.move(SOUTH, mock_world_map)
avatar_view.move(WEST, mock_world_map)
avatar_view.move(NORTH, mock_world_map)
self.assertEqual(avatar_view.cells_in_view, initial_cells_in_view)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new end line

@ramonfmir ramonfmir merged commit f6b319b into master Sep 4, 2017
ramonfmir added a commit that referenced this pull request Sep 4, 2017
@ramonfmir ramonfmir mentioned this pull request Sep 4, 2017
ramonfmir added a commit that referenced this pull request Sep 4, 2017
ramonfmir added a commit that referenced this pull request Sep 4, 2017
OlafSzmidt pushed a commit to OlafSzmidt/aimmo that referenced this pull request Oct 19, 2017
# The first commit's message is:
Squashed all changes

Otherwise multiple games will use the same port range and clash

Fixes ocadotechnology#209

# This is the 2nd commit message:

Implemented a basic connection library, that exposes different states. The idea is to have an expensible hierarchy of views.

# This is the 3rd commit message:

Putted the new library in place of the old type of connection. The purpose is to separate responsability and be able to provide a special connection with the front-end.

# This is the 4th commit message:

Started implementing a world state exposed for the unity front-end. We will test only the JSON format for the moment.

# This is the 5th commit message:

Finished implementing the UnityWorldState. Now the world state is exposed to the front-end correctly.

# This is the 6th commit message:

Fixed the initialization of the map. Now we only need to get rid of hardcoded connection between unity and backend.

# This is the 7th commit message:

Adding score location to the world state.

# This is the 8th commit message:

Fixed some player tests. Using WorldState instead of service.

# This is the 9th commit message:

Created a WorldUpdate class which stores all the parameters that need to be sent in every update.

# This is the 10th commit message:

Deleted previous world state update and started doing some changes in the file structure.

# This is the 11th commit message:

Added create and delete lists in the AvatarManager.

# This is the 12th commit message:

Removed confusion between world_map and world_state.

# This is the 13th commit message:

Basic idea translated.

# This is the 14th commit message:

Debugged avatars part of the new API.

# This is the 15th commit message:

Initialization requests added to avoid emitting to early, since that would make the whole crete/update events not work.

# This is the 16th commit message:

Cleaned up Unity builds that ended up in the project by mistake during cherry-picking.

# This is the 17th commit message:

Fixed circular imports between the map_generator and world_map.

# This is the 18th commit message:

Removed old tests as now the service works diffrently. This is a very versatile class, thus testing can be hardly kept to date.

# This is the 19th commit message:

Fixed test problems and broken imports. Replaced [:] with deepcopy.

# This is the 20th commit message:

Fix for worker manager port initialization. The portiterator was initialized before the port was initialized.

# This is the 21st commit message:

First steps in bringing RaphaelJS to the new backend API.

# This is the 22nd commit message:

Create / Delete / Update players using the new update-based API.

# This is the 23rd commit message:

Added obstacles and score points to the view with the new API.

# This is the 24th commit message:

Blank map appearing on the screen. Now we need to handle updates.

# This is the 25th commit message:

Was missing client-ready call. Now updates are received but there;s still some mismatch in the format.

# This is the 26th commit message:

Players drawn.

# This is the 27th commit message:

Players updating.

# This is the 28th commit message:

Healht points and obstacles appearing as well. Almost there.

# This is the 29th commit message:

Score points and pickups added as well.

# This is the 30th commit message:

Last adjustment. RaphaelJS is back.

# This is the 31st commit message:

Timestampling the RaphaelJS javascript files so they get reloaded each time.

# This is the 32nd commit message:

Fixed minior version incompatibility between the front-end and back-end. Fixed merge conflict remained in .js files.

# This is the 33rd commit message:

Changed based on pull request comments.

# This is the 34th commit message:

fix: Add nginx index page for GCP healthcheck

# This is the 35th commit message:

fix: Build aimmo-reverse-proxy container during minikube

# This is the 36th commit message:

Consolidate manifests

# This is the 37th commit message:

feat: Use aimmo-reverse-proxy locally

# This is the 38th commit message:

Update README.md

Specified Python 2.7 is required and how to specify a Python interpreter for virtualenvwrapper
# This is the 39th commit message:

Implemented a basic structure for the level generatio engine. The connection API is not very clear, thus we will work on parsers at the beginning.

# This is the 40th commit message:

Added a map parser. Now the map is formatted in a matrix that should be transformed according to a model.

# This is the 41st commit message:

Added some sample parsers. This should be able to process transform methods as long as transform methods are correct.

# This is the 42nd commit message:

Implemented more logic to the parsers. Now the jsons work as they should, but the transforms don't seem to be initialised properly.

# This is the 43rd commit message:

Connected the parsers and transforms. Now the transforms are not filtered correctly.

# This is the 44th commit message:

Moved responsabilities arround and made a level new format level generator. We shall now put an adaptor to the old classes so we support the new level generation.

# This is the 45th commit message:

Separate the map generator in multiple classes, now we have classes for level generators. Those take a json format level and build it from there.

# This is the 46th commit message:

Level generation basics keep working for the moment. The map is not working.

# This is the 47th commit message:

Minimal workable map generation. We need to think about the cooridinates and size of the map.

# This is the 48th commit message:

Added obstacles to the map generator. Needs documentation. Like... a lot.

# This is the 49th commit message:

Fixed circular imports and used deepcopy instead of slicing as slicing needs implementation in classes.

# This is the 50th commit message:

Begin testing level generation. Only the txt parsing has been tested and the setup for the tests has been made.

# This is the 51st commit message:

Added some more tests for json and string parsers. Now we need to test the whole level generation.

# This is the 52nd commit message:

Fixed some tests that would not run and added a more complex json parser test.

# This is the 53rd commit message:

Finished testing parsers. We need to test the new level generation API, but it all seems to work fine.

# This is the 54th commit message:

Registered the pickups to the level generator and in the world state. We shall make a better way of implementing new features as there is some boilerplate code.

# This is the 55th commit message:

Added tests for obstacle decoder.

# This is the 56th commit message:

Changed the aimm-game/tests to the pre-refactoring version of empty map generation.

# This is the 57th commit message:

Written tests for the rest of the decoders.

# This is the 58th commit message:

Implemented a mockery for level generation testing. The map dimension size and coordinate translation has to be fixed.

# This is the 59th commit message:

Fixed broken import. Test service was importing a module that is not present on this branch.

# This is the 60th commit message:

Changed the tests so they use the new API.

# This is the 61st commit message:

Learning to write tests. Trying to write some basic integration tests and then use some already written mock implementations for the back-end.

# This is the 62nd commit message:

Configured the classes so that mocks can be used from the integration testing package. We basically contruct a module over the whole project and also add the path to the parent folder from the tests folder so we can reuse the alredy written mocks.

# This is the 63rd commit message:

Added a simple server file as an utility. Mocking seems harder in the current context, thus we will use an actual localhost server as the Django server.

# This is the 64th commit message:

Added a sample test to see if games get requeste. A better workflow has to be developed as we do not use mocking but rather implement a whole simple replacement server.

# This is the 65th commit message:

Implemented a more stable integration test. We shall now transform the localhost Django testing replacement into a proxy.

# This is the 66th commit message:

The message received by socket is redirect to mock objects, thus allowing complex test interactions.

# This is the 67th commit message:

Implemented a more complex workflow so that the testing library and the mock server is a more extensible.

# This is the 68th commit message:

Added a way of running tests with kubernates. This architecture should be supported to run on a real end-to-end integration test.

# This is the 69th commit message:

Added multiple tests and grouped the runners. A better documentation is needed and the pickle configurations should dissapear.

# This is the 70th commit message:

Maked a proper mock configuration for the GameCreatorRequestMock and GameRequestMock. Now the server seems to work correctly. We need to make a seam in order to test more complex behaviour.

# This is the 71st commit message:

Changed setup.py to have a custom test suite for the integration tests. Running tests in parallel would also be a good idea.(see integration-tests/setup.py)

# This is the 72nd commit message:

Other changes to setup.py. See commit 8e6d.

# This is the 73rd commit message:

Fixed setup.py so that the CI build works. Separated kubernates and non-kubernates tests.

# This is the 74th commit message:

Fixed failing tests in djnago and bad application pathing. Now all the tests should pass.

# This is the 75th commit message:

Documented the mock server class and its usage. Also made the run of the backend test non-verbose.

# This is the 76th commit message:

Documented the backend testing and added it to the test suite. Now we shall make a full integration test using curl to hit resources of the front-end.

# This is the 77th commit message:

Adding an integration tests that works with the django server. We use a client to send messages to the server.

# This is the 78th commit message:

Added a test for login and getting resources for level 1. We now need to use socket.io to communicate with the server.

# This is the 79th commit message:

Working on integration tests. Now we are listening to workers. We only need to add the socket.io connection to verify stuff.

# This is the 80th commit message:

Trying a socket io connection for the integration testing. This is not properly made.

# This is the 81st commit message:

Finished a first version of the integration test suite. This should be run with minikube/kubeadm afterwards.

# This is the 82nd commit message:

Removed bad import inside test_end_to_end.

# This is the 83rd commit message:

Trying to use the integration test in the travis CI.

# This is the 84th commit message:

Trying to run minikube with the travis vendor driver rather than installing virtualbox.

# This is the 85th commit message:

Revert "Trying to use the integration test in the travis CI."

This reverts commit deccb43.

# This is the 86th commit message:

Removed temorarily the tests that use minikube. Now all the tests should work.

# This is the 87th commit message:

Written a library that kills properly a tree of processes. Now the integration tests with localhost work and are extensible.

# This is the 88th commit message:

Import problem for stacktrace print. Logging was not imported.

# This is the 89th commit message:

Further import problems. Traceback was not imported.

# This is the 90th commit message:

Trying to fix the testing in the CI. We now poll the same resource many times.

# This is the 91st commit message:

Pool callbacks not working, small bug in __pool_callback function @ test_end_to_end.

# This is the 92nd commit message:

There is a problem with finding the game resource for the first level. The tests will be skipped for the moment as they work locally, but not on CI. Levels must be added to database when deploying.

# This is the 93rd commit message:

Reactivating the backend integration test. (it was commented out by mistake)

# This is the 94th commit message:

Exposed the flask application endpoints with plain GET requests. This can be used by testing and may be used to support different clients.

# This is the 95th commit message:

Implemeted checks for the avatar movement. The avatar should move at most one square at one time.

# This is the 96th commit message:

Finished the simulation implementation for the snapshot processor. The end to end test should work at least locally.

# This is the 97th commit message:

Modified tests to fit with the version on master.

# This is the 98th commit message:

Changed the localhost and hardcoded parameters to the actual ip. Corrected spart of the test_end_to_end. The problem is pickle/json format.

# This is the 99th commit message:

Got rid of the cPickle and adapted aimmo/service to the current world state version.

# This is the 100th commit message:

Corrected the level 1 test as it did not work with empty database.

# This is the 101st commit message:

Slightly changed the level 1 test. Also removed erronous error catching.

# This is the 102nd commit message:

We added a call to players/api/code/1 as for now we need to do that for the worker to get initial code.

# This is the 103rd commit message:

Changed check_player_added as it had wrong signature.

# This is the 104th commit message:

Changed the setup.cfg file for coverage reports.

# This is the 105th commit message:

Modified .cfg file again.

# This is the 106th commit message:

Commented the integration test services. Modified settings.py to work with nginx again.

# This is the 107th commit message:

Removed redundant code from aimmo-game/service.py.

# This is the 108th commit message:

Removed imports that are no longer needed.

# This is the 109th commit message:

Modified prints in integration tests with logger calls. Other minor style changes.

# This is the 110th commit message:

Added avatar's view.

# This is the 111th commit message:

Avatar view works, objects exist only if they are around you. Need to fix the out-of-bounds issue in the world map.

# This is the 112th commit message:

world_state doesn't try to create/delete cells that are out of the world map bounds.

# This is the 113th commit message:

Avatars custom view incorporates other avatars. Still sending the updates of every avatar in AvatarManager.

# This is the 114th commit message:

Only sending updates of players in scene.

# This is the 115th commit message:

Wider 'wipe-out' area.

# This is the 116th commit message:

Minor changes. Having a list of avatars in scene in world state made no sense, since it is global for all the players...

# This is the 117th commit message:

Attribute error fixed in world state.

# This is the 118th commit message:

Fixed imports in avatar_view and service.py.

# This is the 119th commit message:

Introduced cells_in_view.

# This is the 120th commit message:

Avoid errors with tests that don't initialise the location.

# This is the 121st commit message:

Score locations now behave correctly. Cells also keep track of whether they should be added to the scene or not.

# This is the 122nd commit message:

Removed setting the create/delete cell attribute to none when created. This won't work with multiple users. Right now it would work, but the same score point might be tried to be added/deleted multiple times. The Unity client is prepared to handle this but we should think of a nicer fix.

# This is the 123rd commit message:

Avatars always inside the view. Hurray!

# This is the 124th commit message:

Player colour is sent now as well.

# This is the 125th commit message:

Docummented avatar_view.

# This is the 126th commit message:

Started writing tests for avatarview.

# This is the 127th commit message:

Full test suite for avatar_view.

# This is the 128th commit message:

Removed redundant tests.

# This is the 129th commit message:

Fixed InifniteMap tests. All tests ran successfully.

# This is the 130th commit message:

Fixed world map min/max size calculations.

# This is the 131st commit message:

No ready_to_update boolean neessary anymore.

# This is the 132nd commit message:

Avatar view imported absolutely.

# This is the 133rd commit message:

Changed hash function in location.

# This is the 134th commit message:

Using xrange instead of range in avatar view.

# This is the 135th commit message:

Added blank lines according to the PEP8 style guidelines.

# This is the 136th commit message:

End of lines added and using 'is not' instead of 'not is'

# This is the 137th commit message:

Fixed the merge confilicts resulted from mergeing at the same time: ocadotechnology#222 and ocadotechnology#223.

# This is the 138th commit message:

Tests written for turn manager, fog of war, locaiton and workermanager.

(cherry picked from commit ded992f)

More tests for worker manager.

(cherry picked from commit f4441b3)

Turn Manager fully tested. Initial fog of war tests.

(cherry picked from commit edfe2ae)

PEP8 fixes + spelling mistakes

Further fixes for the pull request.

(cherry picked from commit bf92d07)

"Manager" typo changed.

# This is the 139th commit message:

README.md contact link fix

# This is the 140th commit message:

Refactoring and PEP8 fixes.

# This is the 141st commit message:

Extra test written to get coverage up a little

TODO comments removed.

# This is the 142nd commit message:

Unnecessary comments removed.

# This is the 143rd commit message:

Some initial tests written for files that didn't exist yet.

# This is the 144th commit message:

Pickups changed to suit level1 minimum product

test_pickup_decoder written for the new class.

Changes made as requested in PR.

holdingTote no longer used. Implemented Counter

Obsolete pickup file removed.

# This is the 145th commit message:

Effects removed.

(cherry picked from commit ecf4ed8)

# This is the 146th commit message:

Cell moved to standalone package.
@mrniket mrniket deleted the avatar_view branch November 3, 2017 15:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants