index int64 | repo_name string | branch_name string | path string | content string | import_graph string |
|---|---|---|---|---|---|
52,256 | kicon/armstrong.dev | refs/heads/master | /armstrong/dev/tests/utils/base.py | from django.test import TestCase as DjangoTestCase
import fudge
from django.db import models
# Backport override_settings from Django 1.4
try:
from django.test.utils import override_settings
except ImportError:
from .backports import override_settings
class ArmstrongTestCase(DjangoTestCase):
def setUp(self):
fudge.clear_expectations()
fudge.clear_calls()
if not hasattr(DjangoTestCase, 'settings'):
# backported from Django 1.4
def settings(self, **kwargs):
"""
A context manager that temporarily sets a setting and reverts
back to the original value when exiting the context.
.. seealso: https://github.com/django/django/blob/0d670682952fae585ce5c5ec5dc335bd61d66bb2/django/test/testcases.py#L349-354
"""
return override_settings(**kwargs)
def assertRelatedTo(self, model, field_name, related_model, many=False):
if many is False:
through = models.ForeignKey
else:
through = models.ManyToManyField
# sanity check
self.assertModelHasField(model, field_name, through)
field = model._meta.get_field_by_name(field_name)[0]
self.assertEqual(field.rel.to, related_model)
def assertModelHasField(self, model, field_name, field_class=None):
msg = "%s does not have a field named %s" % (model.__class__.__name__,
field_name)
self.assertTrue(hasattr(model, field_name), msg=msg)
field = model._meta.get_field_by_name(field_name)[0]
if field_class is not None:
msg = "%s.%s is not a %s" % (model.__class__.__name__, field_name,
field_class.__class__.__name__)
self.assertTrue(isinstance(field, field_class), msg=msg)
def assertInContext(self, var_name, other, template_or_context):
# TODO: support passing in a straight "context" (i.e., dict)
context = template_or_context.context_data
self.assertTrue(var_name in context,
msg="`%s` not in provided context" % var_name)
self.assertEqual(context[var_name], other)
def assertNone(self, obj, **kwargs):
self.assertTrue(obj is None, **kwargs)
def assertIsA(self, obj, cls, **kwargs):
self.assertTrue(isinstance(obj, cls), **kwargs)
def assertDoesNotHave(self, obj, attr, **kwargs):
self.assertFalse(hasattr(obj, attr), **kwargs)
| {"/armstrong/dev/tests/utils/__init__.py": ["/armstrong/dev/tests/utils/base.py"], "/armstrong/dev/virtualdjango/test_runner.py": ["/armstrong/dev/virtualdjango/base.py"], "/armstrong/dev/tests/utils/users.py": ["/armstrong/dev/tests/utils/base.py"]} |
52,257 | kicon/armstrong.dev | refs/heads/master | /armstrong/dev/tasks/__init__.py |
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from contextlib import contextmanager
try:
import coverage as coverage
except ImportError:
coverage = False
import os
from os.path import basename, dirname
import sys
from functools import wraps
import unittest
import json
from fabric.api import *
from fabric.colors import red
from fabric.decorators import task
from armstrong.dev.virtualdjango.test_runner import run_tests as run_django_tests
from armstrong.dev.virtualdjango.base import VirtualDjango
from django.core.exceptions import ImproperlyConfigured
if not "fabfile" in sys.modules:
sys.stderr.write("This expects to have a 'fabfile' module\n")
sys.stderr.write(-1)
fabfile = sys.modules["fabfile"]
FABRIC_TASK_MODULE = True
__all__ = ["clean", "command", "create_migration", "docs", "pep8", "test",
"reinstall", "runserver", "shell", "spec", "syncdb", ]
def pip_install(func):
@wraps(func)
def inner(*args, **kwargs):
if getattr(fabfile, "pip_install_first", True):
with settings(warn_only=True):
if not os.environ.get("SKIP_INSTALL", False):
local("pip uninstall -y %s" % get_full_name(), capture=False)
local("pip install .", capture=False)
func(*args, **kwargs)
return inner
@contextmanager
def html_coverage_report(directory="./coverage"):
# This relies on this being run from within a directory named the same as
# the repository on GitHub. It's fragile, but for our purposes, it works.
run_coverage = coverage
if run_coverage and os.environ.get("SKIP_COVERAGE", False):
run_coverage = False
if run_coverage:
local('rm -rf ' + directory)
package = __import__('site')
base_path = dirname(package.__file__) + '/site-packages/' + get_full_name().replace('.', '/')
print "Coverage is covering: " + base_path
cov = coverage.coverage(branch=True,
source=(base_path,),
omit=('*/migrations/*',))
cov.start()
yield
if run_coverage:
cov.stop()
cov.html_report(directory=directory)
else:
print "Install coverage.py to measure test coverage"
@task
def clean():
"""Find and remove all .pyc and .pyo files"""
local('find . -name "*.py[co]" -exec rm {} \;')
@task
def create_migration(name, initial=False, auto=True):
"""Create a South migration for app"""
command((("schemamigration", fabfile.main_app, name), {
"initial": bool(int(initial)),
"auto": bool(int(auto)),
}))
@task
def command(*cmds):
"""Run and arbitrary set of Django commands"""
runner = VirtualDjango()
runner.run(fabfile.settings)
for cmd in cmds:
if type(cmd) is tuple:
args, kwargs = cmd
else:
args = (cmd, )
kwargs = {}
runner.call_command(*args, **kwargs)
@task
def pep8():
"""Run pep8 on all .py files in ./armstrong"""
local('find ./armstrong -name "*.py" | xargs pep8 --repeat', capture=False)
@task
@pip_install
def test():
"""Run tests against `tested_apps`"""
from types import FunctionType
if hasattr(fabfile, 'settings') and type(fabfile.settings) is not FunctionType:
with html_coverage_report():
run_django_tests(fabfile.settings, *fabfile.tested_apps)
return
else:
test_module = "%s.tests" % get_full_name()
try:
__import__(test_module)
tests = sys.modules[test_module]
except ImportError:
tests = False
pass
if tests:
test_suite = getattr(tests, "suite", False)
if test_suite:
with html_coverage_report():
unittest.TextTestRunner().run(test_suite)
return
raise ImproperlyConfigured(
"Unable to find tests to run. Please see armstrong.dev README."
)
@task
def runserver():
"""Create a Django development server"""
command("runserver")
@task
def shell():
"""Launch shell with same settings as test and runserver"""
command("shell")
@task
def syncdb():
"""Call syncdb and migrate on project"""
command("syncdb", "migrate")
@task
def docs():
"""Generate the Sphinx docs for this project"""
local("cd docs && make html")
@task
@pip_install
def spec(verbosity=4):
"""Run harvest to run all of the Lettuce specs"""
defaults = {"DATABASES": {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
},
}}
get_full_name()
defaults.update(fabfile.settings)
v = VirtualDjango()
v.run(defaults)
v.call_command("syncdb", interactive=False)
v.call_command("migrate")
v.call_command("harvest", apps=fabfile.full_name,
verbosity=verbosity)
def get_full_name():
if not hasattr(fabfile, "full_name"):
try:
package_string = local("cat ./package.json", capture=True)
package_obj = json.loads(package_string)
fabfile.full_name = package_obj['name']
return fabfile.full_name
except:
sys.stderr.write("\n".join([
red("No `full_name` variable detected in your fabfile!"),
red("Please set `full_name` to the app's full module"),
red("Additionally, we couldn't read name from package.json"),
""
]))
sys.stderr.flush()
sys.exit(1)
return fabfile.full_name
@task
def reinstall():
"""Install the current component"""
local("pip uninstall -y `basename \\`pwd\\``; pip install .")
| {"/armstrong/dev/tests/utils/__init__.py": ["/armstrong/dev/tests/utils/base.py"], "/armstrong/dev/virtualdjango/test_runner.py": ["/armstrong/dev/virtualdjango/base.py"], "/armstrong/dev/tests/utils/users.py": ["/armstrong/dev/tests/utils/base.py"]} |
52,258 | kicon/armstrong.dev | refs/heads/master | /armstrong/dev/tests/utils/concrete.py | from django.db import connection
from django.core.management.color import no_style
import random
def create_concrete_table(func=None, model=None):
style = no_style()
seen_models = connection.introspection.installed_models(
connection.introspection.table_names())
def actual_create(model):
sql, _references = connection.creation.sql_create_model(model, style,
seen_models)
cursor = connection.cursor()
for statement in sql:
cursor.execute(statement)
if func:
def inner(self, *args, **kwargs):
func(self, *args, **kwargs)
actual_create(self.model)
return inner
elif model:
actual_create(model)
def destroy_concrete_table(func=None, model=None):
style = no_style()
# Assume that there are no references to destroy, these are supposed to be
# simple models
references = {}
def actual_destroy(model):
sql = connection.creation.sql_destroy_model(model, references, style)
cursor = connection.cursor()
for statement in sql:
cursor.execute(statement)
if func:
def inner(self, *args, **kwargs):
func(self, *args, **kwargs)
actual_destroy(self.model)
return inner
elif model:
actual_destroy(model)
# TODO: pull into a common dev package so all armstrong code can use it
def concrete(klass):
attrs = {'__module__': concrete.__module__, }
while True:
num = random.randint(1, 10000)
if num not in concrete.already_used:
break
return type("Concrete%s%d" % (klass.__name__, num), (klass, ), attrs)
concrete.already_used = []
| {"/armstrong/dev/tests/utils/__init__.py": ["/armstrong/dev/tests/utils/base.py"], "/armstrong/dev/virtualdjango/test_runner.py": ["/armstrong/dev/virtualdjango/base.py"], "/armstrong/dev/tests/utils/users.py": ["/armstrong/dev/tests/utils/base.py"]} |
52,259 | kicon/armstrong.dev | refs/heads/master | /armstrong/dev/virtualdjango/base.py | import django
import os, sys
DEFAULT_SETTINGS = {
'DATABASE_ENGINE': 'sqlite3',
'DATABASES': {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase'
}
},
}
class VirtualDjango(object):
def __init__(self,
caller=sys.modules['__main__'],
default_settings=DEFAULT_SETTINGS):
self.caller = caller
self.default_settings = default_settings
def configure_settings(self, customizations, reset=True):
# Django expects a `DATABASE_ENGINE` value
custom_settings = self.default_settings
custom_settings.update(customizations)
settings = self.settings
if reset:
self.reset_settings(settings)
settings.configure(**custom_settings)
def reset_settings(self, settings):
if django.VERSION[:2] == (1, 3):
settings._wrapped = None
return
# This is the way to reset settings going forward
from django.utils.functional import empty
settings._wrapped = empty
@property
def settings(self):
from django.conf import settings
return settings
@property
def call_command(self):
from django.core.management import call_command
return call_command
def run(self, my_settings):
if hasattr(self.caller, 'setUp'):
self.caller.setUp()
self.configure_settings(my_settings)
return self.call_command
| {"/armstrong/dev/tests/utils/__init__.py": ["/armstrong/dev/tests/utils/base.py"], "/armstrong/dev/virtualdjango/test_runner.py": ["/armstrong/dev/virtualdjango/base.py"], "/armstrong/dev/tests/utils/users.py": ["/armstrong/dev/tests/utils/base.py"]} |
52,260 | kicon/armstrong.dev | refs/heads/master | /armstrong/dev/virtualdjango/test_runner.py | from armstrong.dev.virtualdjango.base import VirtualDjango
class VirtualDjangoTestRunner(VirtualDjango):
def run(self, my_settings, *apps_to_test):
super(VirtualDjangoTestRunner, self).run(my_settings)
self.call_command('test', *apps_to_test)
def __call__(self, *args, **kwargs):
self.run(*args, **kwargs)
run_tests = VirtualDjangoTestRunner()
| {"/armstrong/dev/tests/utils/__init__.py": ["/armstrong/dev/tests/utils/base.py"], "/armstrong/dev/virtualdjango/test_runner.py": ["/armstrong/dev/virtualdjango/base.py"], "/armstrong/dev/tests/utils/users.py": ["/armstrong/dev/tests/utils/base.py"]} |
52,261 | kicon/armstrong.dev | refs/heads/master | /armstrong/dev/tests/utils/users.py | from armstrong.dev.tests.utils.base import ArmstrongTestCase
from django.contrib.auth.models import User
import random
def generate_random_user():
r = random.randint(10000, 20000)
return User.objects.create(username="random-user-%d" % r,
first_name="Some", last_name="Random User %d" % r)
def generate_random_staff_users(n=2):
orig_users = generate_random_users(n)
users = User.objects.filter(pk__in=[a.id for a in orig_users])
users.update(is_staff=True)
return [a for a in users]
class generate_random_staff_usersTestCase(ArmstrongTestCase):
def test_returns_2_users_by_default(self):
self.assertEqual(len(generate_random_staff_users()), 2)
def test_returns_n_users(self):
r = random.randint(1, 5)
self.assertEqual(len(generate_random_staff_users(r)), r)
def test_all_users_are_staff(self):
users = generate_random_staff_users()
for user in users:
self.assertTrue(user.is_staff)
def generate_random_users(n=2):
return [generate_random_user() for i in range(n)] | {"/armstrong/dev/tests/utils/__init__.py": ["/armstrong/dev/tests/utils/base.py"], "/armstrong/dev/virtualdjango/test_runner.py": ["/armstrong/dev/virtualdjango/base.py"], "/armstrong/dev/tests/utils/users.py": ["/armstrong/dev/tests/utils/base.py"]} |
52,266 | CourtJesterG/mirror-catfacts-python | refs/heads/master | /push/handler.py | # Copyright (C) 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Poll handlers."""
__author__ = 'alainv@google.com (Alain Vongsouvanh)'
import datetime
import logging
import webapp2
import httplib2
from apiclient.http import BatchHttpRequest
from oauth2client.appengine import StorageByKeyName
from oauth2client.client import AccessTokenRefreshError
from model import UserSettings
import util
MINUTES_PER_HOUR = 60
# 8am in minutes.
DAY_TIME_START = 8 * MINUTES_PER_HOUR
# 8pm in minutes.
DAY_TIME_STOP = 20 * MINUTES_PER_HOUR
# Limit requests per batch request to 50.
BATCH_REQUEST_COUNT = 50
def _insert_cat_fact_callback(userid, response, exception):
"""Callback for the Mirror API insert batch request."""
if exception:
logging.error(
'Failed to insert cat fact for user %s: %s', userid, exception)
class PushCronHandler(webapp2.RequestHandler):
"""Handler for push cron job."""
def get(self):
"""Retrieve all users and add taskqueue to poll Twitter feed."""
body = {
'text': util.get_cat_fact(),
'notification': {'level': 'DEFAULT'}
}
# Limit 50 requests per batch request.
batch_requests = []
count = BATCH_REQUEST_COUNT
for user_settings in self.entities_to_process():
request = self._get_cat_fact_insert_request(
user_settings.key().name(), body)
if request:
if count >= BATCH_REQUEST_COUNT:
batch = BatchHttpRequest(callback=_insert_cat_fact_callback)
batch_requests.append(batch)
count = 0
batch.add(request)
count += 1
for batch in batch_requests:
batch.execute()
def entities_to_process(self):
"""Yield entities that should be processed."""
now = datetime.datetime.utcnow()
quarter_mark = (now.minute / 15) * 15
now_minute = now.hour * 60 + quarter_mark
query = UserSettings.all()
if quarter_mark == 30:
query.filter('frequency IN', [15, 30])
elif quarter_mark == 15 or quarter_mark == 45:
query.filter('frequency =', 15)
for user_settings in query:
if user_settings.night_mode:
yield user_settings
else:
shifted_now = (now_minute - user_settings.timezone_offset) % 1440
# Verify that this is day time in the user's timezone.
if shifted_now >= DAY_TIME_START and shifted_now < DAY_TIME_STOP:
yield user_settings
def _get_cat_fact_insert_request(self, userid, body):
"""Poll Twitter feed for the provided user."""
try:
creds = StorageByKeyName(UserSettings, userid, 'credentials').get()
creds.refresh(httplib2.Http())
service = util.create_service('mirror', 'v1', creds)
return service.timeline().insert(body=body)
except AccessTokenRefreshError:
logging.error('Unable to refresh token for user %s', userid)
return None
PUSH_ROUTES = [
('/push', PushCronHandler)
]
| {"/push/handler.py": ["/util.py"], "/settings/handler.py": ["/errors.py", "/util.py"], "/index/handler.py": ["/util.py"]} |
52,267 | CourtJesterG/mirror-catfacts-python | refs/heads/master | /errors.py | # Copyright (C) 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Error classes."""
__author__ = 'alainv@google.com (Alain Vongsouvanh)'
import json
import util
class Error(Exception):
"""Base API error used inside this module."""
code = 500
class BadRequestError(Error):
"""Bad request error."""
code = 400
class UnauthorizedError(Error):
"""Unauthorized error."""
code = 401
class NotFoundError(Error):
"""Not found error."""
code = 404
class InternalServerError(Error):
"""Unauthorized error."""
code = 500
def error_aware(method):
"""Decorator catching Cat Facts errors.
Args:
method: Method being decorated.
Returns:
Decorated method.
"""
def _request(request_handler, *args):
"""Surround request_handler.method(*args) with try/except for errors.
Args:
request_handler: Request handler which method is being called.
"""
try:
method(request_handler, *args)
except Error, error:
response_body = {
'error': {
'status': error.code,
'message': error.message
}
}
request_handler.response.clear()
request_handler.response.set_status(error.code)
util.write_response(request_handler, response_body)
return _request
| {"/push/handler.py": ["/util.py"], "/settings/handler.py": ["/errors.py", "/util.py"], "/index/handler.py": ["/util.py"]} |
52,268 | CourtJesterG/mirror-catfacts-python | refs/heads/master | /util.py | # Copyright (C) 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utility classes and methods for Mirror Cat Facts."""
__author__ = 'alainv@google.com (Alain Vongsouvanh)'
import logging
import json
import random
import webapp2
import httplib2
from apiclient.discovery import build
from oauth2client.client import AccessTokenCredentials
CLIENT_SECRETS_FILE = 'client_secrets.json'
SCOPES = [
'https://www.googleapis.com/auth/glass.timeline',
'https://www.googleapis.com/auth/plus.login'
]
TOKENINFO_URL = 'https://www.googleapis.com/oauth2/v2/tokeninfo?access_token=%s'
CAT_FACTS_FILENAME = 'cat_facts.txt'
def create_service(service, version, creds=None):
"""Create a Google API service.
Load an API service from a discovery document and authorize it with the
provided credentials.
This sends a request to Google's Discovery API everytime the function is
called. A more efficient way to use this API is to cache the API discovery
file and use apiclient.discovery.build_from_document instead.
Args:
service: Service name (e.g 'mirror', 'oauth2').
version: Service version (e.g 'v1').
creds: Credentials used to authorize service.
Returns:
Authorized Google API service.
"""
# Instantiate an Http instance
http = httplib2.Http()
if creds:
# Authorize the Http instance with the passed credentials
creds.authorize(http)
return build(service, version, http=http)
def verify_token(access_token):
"""Verify that the access token has been issued for our application.
Args:
access_token: Token to verify.
Returns:
User ID if access_token is valid and has been issued for our application.
"""
url = TOKENINFO_URL % access_token
http = httplib2.Http()
tokeninfo = json.loads(http.request(url, 'GET')[1])
if tokeninfo.get('audience') != get_client_id():
return None
# Verify that the token has the required scopes.
token_scopes = tokeninfo.get('scope').split(' ')
for required_scope in SCOPES:
if required_scope not in token_scopes:
return None
return tokeninfo['user_id']
def get_client_id():
"""Return the application's client ID."""
client_secrets = json.load(file('client_secrets.json'))
return client_secrets['web']['client_id']
def write_response(request, data):
"""Write a request's response body as JSON."""
request.response.headers['Content-type'] = 'application/json'
request.response.out.write(json.dumps(data))
def get_cat_fact():
"""Retrieve a random cat fact."""
# This should probably cached.
f = open(CAT_FACTS_FILENAME)
facts = list(f)
if facts:
return facts[random.randrange(0, len(facts))]
else:
return 'No cat fact found :('
| {"/push/handler.py": ["/util.py"], "/settings/handler.py": ["/errors.py", "/util.py"], "/index/handler.py": ["/util.py"]} |
52,269 | CourtJesterG/mirror-catfacts-python | refs/heads/master | /oauth/handler.py | # Copyright (C) 2013 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""OAuth 2.0 handlers."""
__author__ = 'alainv@google.com (Alain Vongsouvanh)'
import json
import webapp2
from oauth2client.appengine import StorageByKeyName
from oauth2client.client import flow_from_clientsecrets
from oauth2client.client import FlowExchangeError
import errors
import model
import util
# Defaults to EST.
DEFAULT_TIMEZONE_OFFSET = 240
class OAuthCodeExchangeHandler(webapp2.RequestHandler):
"""Request handler for OAuth 2.0 code exchange."""
@errors.error_aware
def post(self):
"""Handle code exchange."""
self._process_request_body()
self._exchange_code()
user = self._create_user()
util.write_response(self, user.to_dict())
def _process_request_body(self):
"""Parse the request body."""
try:
request = json.loads(self.request.body)
self._code = request.get('code')
if not self._code:
raise errors.BadRequestError('`code` attribute is required')
self._timezone_offset = request.get(
'timezoneOffset', DEFAULT_TIMEZONE_OFFSET)
except ValueError:
raise errors.BadRequestError('Unsupported request body')
def _exchange_code(self):
"""Retrieve credentials for the current user."""
oauth_flow = self._create_oauth_flow()
# Perform the exchange of the code.
try:
creds = oauth_flow.step2_exchange(self._code)
except FlowExchangeError, e:
raise errors.InternalServerError('Unable to exchange code: ', e.message)
# Verify that the token has been issued for our application.
self._userid = util.verify_token(creds.access_token)
if not self._userid:
raise errors.BadRequestError('Unknown client ID')
# Verify that we can retrieve valid refresh token for the current user.
if creds.refresh_token:
# Store the credentials in the data store using the userid as the key.
StorageByKeyName(
model.UserSettings, self._userid, 'credentials').put(creds)
else:
# Look for existing credentials in our datastore.
creds = StorageByKeyName(
model.UserSettings, self._userid, 'credentials').get()
if not creds or not creds.refresh_token:
raise errors.UnauthorizedError('No refresh token')
return creds
def _create_user(self):
"""Create a new user model."""
user_settings = model.UserSettings.get_by_key_name(self._userid)
user_settings.timezone_offset = self._timezone_offset
user_settings.put()
return user_settings
def _create_oauth_flow(self):
"""Create OAuth2.0 flow controller."""
flow = flow_from_clientsecrets(
util.CLIENT_SECRETS_FILE, scope=' '.join(util.SCOPES))
flow.redirect_uri = 'postmessage'
return flow
OAUTH_ROUTES = [
('/auth', OAuthCodeExchangeHandler),
]
| {"/push/handler.py": ["/util.py"], "/settings/handler.py": ["/errors.py", "/util.py"], "/index/handler.py": ["/util.py"]} |
52,270 | CourtJesterG/mirror-catfacts-python | refs/heads/master | /settings/handler.py | # Copyright (C) 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Settings handlers."""
__author__ = 'alainv@google.com (Alain Vongsouvanh)'
import webapp2
import json
import errors
from model import UserSettings
import util
class SettingsHandler(webapp2.RequestHandler):
"""Handler for the settings endpoint."""
@errors.error_aware
def get(self):
"""Retrieve settings for the provided user."""
self._get_user()
util.write_response(self, self._user.to_dict())
@errors.error_aware
def put(self):
"""Update settings for the provided user."""
self._get_user()
self._process_request_body()
util.write_response(self, self._user.to_dict())
def _get_user(self):
userid = util.verify_token(self.request.headers.get('Authorization'))
if not userid:
raise errors.BadRequestError('Unknown client ID')
self._user = UserSettings.get_by_key_name(userid)
if not self._user:
raise errors.NotFoundError('Unknown user')
def _process_request_body(self):
"""Parse the request body."""
try:
data = json.loads(self.request.body)
self._user.night_mode = data.get('nightMode', self._user.night_mode)
self._user.frequency = data.get('frequency', self._user.frequency)
self._user.timezone_offset = data.get(
'timezoneOffset', self._user.timezone_offset)
self._user.put()
except ValueError:
raise errors.BadRequestError('Unsupported request body')
SETTINGS_ROUTES = [
('/settings', SettingsHandler),
]
| {"/push/handler.py": ["/util.py"], "/settings/handler.py": ["/errors.py", "/util.py"], "/index/handler.py": ["/util.py"]} |
52,271 | CourtJesterG/mirror-catfacts-python | refs/heads/master | /index/handler.py | # Copyright (C) 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""RequestHandlers for starter project."""
__author__ = 'alainv@google.com (Alain Vongsouvanh)'
import jinja2
import webapp2
import util
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader('templates'),
autoescape=True)
class IndexHandler(webapp2.RequestHandler):
"""Request handler to display the index page."""
def get(self):
"""Display the index page."""
approval_prompt = 'auto'
button_display = 'none'
if self.request.get('approvalPrompt') == 'force':
approval_prompt = 'force'
button_display = 'block'
template_data = {
'approvalPrompt': approval_prompt,
'buttonDisplay': button_display,
'clientId': util.get_client_id(),
'scope': ' '.join(util.SCOPES),
}
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.write(template.render(template_data))
INDEX_ROUTES = [
('/', IndexHandler),
]
| {"/push/handler.py": ["/util.py"], "/settings/handler.py": ["/errors.py", "/util.py"], "/index/handler.py": ["/util.py"]} |
52,275 | zackhillman/weather | refs/heads/master | /weather/email_service.py | import smtplib, ssl
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import time
def sendEmail(location, weather, toEmail):
"""
Sends an email to given toEmail. Body of email includes given location and weather.
"""
port = 465
smtp_server = "smtp.gmail.com"
sender_email = "zackweather2@gmail.com"
password = 'Zackweather1'
msg = MIMEMultipart('alternative')
msg['Subject'] = getSubject(weather)
msg['From'] = 'zackweather2@gmail.com'
msg['To'] = toEmail
html = """\
<html>
<body>
<p>Hi! <br><br>
It is currently {} degrees in {}, {}.
</p>
<img height="50" width="50" src="https://www.weatherbit.io/static/img/icons/{}.png">
</body>
</html>
""".format(weather['today_temp'], location.name, location.state, weather['iCode'])
part2 = MIMEText(html, 'html')
msg.attach(part2)
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(sender_email, password)
server.sendmail(sender_email, toEmail, msg.as_string())
def getSubject(weather):
code = weather['condition']
diff = weather['today_temp'] - weather['tomorrow_temp']
sun = code >= 800 and code <= 803
rain = code >= 200 and code <= 623 or weather['precip'] > 0
if diff >= 5 or sun: return 'It is nice out! Enjoy a discount on us.'
if diff <= -5 or rain: return 'Not so nice out? That is okay, enjoy a discount on us.'
return 'Enjoy a discount on us'
| {"/weather/admin.py": ["/weather/models.py", "/weather/forms.py"], "/weather/management/commands/sendemail.py": ["/weather/models.py", "/weather/weather_service.py", "/weather/email_service.py"], "/weather/migrations/0001_initial.py": ["/weather/models.py"], "/weather/forms.py": ["/weather/models.py"]} |
52,276 | zackhillman/weather | refs/heads/master | /weather/admin.py | from django.contrib import admin
from .models import Location, User
from django.contrib import admin
from .forms import SubscribeForm
# Register your models here.
admin.site.register(Location)
class UserAdmin(admin.ModelAdmin):
form = SubscribeForm
admin.site.register(User, UserAdmin) | {"/weather/admin.py": ["/weather/models.py", "/weather/forms.py"], "/weather/management/commands/sendemail.py": ["/weather/models.py", "/weather/weather_service.py", "/weather/email_service.py"], "/weather/migrations/0001_initial.py": ["/weather/models.py"], "/weather/forms.py": ["/weather/models.py"]} |
52,277 | zackhillman/weather | refs/heads/master | /weather/management/commands/sendemail.py | from django.core.management.base import BaseCommand, CommandError
from weather.models import User
from weather.weather_service import WeatherData
from weather.email_service import sendEmail
class Command(BaseCommand):
help = 'Sends email to users'
def handle(self, *args, **options):
wd = WeatherData()
queryset = User.objects.all()
for user in queryset:
lat = user.location.lat
lon = user.location.lon
weather = wd.getWeather((lat, lon))
try:
sendEmail(user.location, weather, user.email)
self.stdout.write(self.style.SUCCESS('Successfully sent email to: {}'.format(user.email)))
except:
self.stdout.write(self.style.ERROR('Failed to send email to: {}'.format(user.email)))
| {"/weather/admin.py": ["/weather/models.py", "/weather/forms.py"], "/weather/management/commands/sendemail.py": ["/weather/models.py", "/weather/weather_service.py", "/weather/email_service.py"], "/weather/migrations/0001_initial.py": ["/weather/models.py"], "/weather/forms.py": ["/weather/models.py"]} |
52,278 | zackhillman/weather | refs/heads/master | /weather/migrations/0001_initial.py | # Generated by Django 2.2.6 on 2019-10-16 01:28
from django.db import migrations, models
import django.db.models.deletion
import os,csv
from weather.models import Location
def top_cities(apps, schema_editor):
# We can't import the Person model directly as it may be a newer
# version than this migration expects. We use the historical version.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
with open(os.path.join(BASE_DIR, 'top_cities_w_coord.csv')) as top_cities:
reader = csv.reader(top_cities)
for row in reader:
location = Location()
location.name = row[0]
location.state = row[1]
location.lat = float(row[2])
location.lon = -1*float(row[3])
location.save()
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('state', models.CharField(max_length=100)),
('lon', models.DecimalField(decimal_places=6, max_digits=9)),
('lat', models.DecimalField(decimal_places=6, max_digits=9)),
],
),
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(max_length=254, unique=True)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='weather.Location')),
],
),
migrations.RunPython(top_cities),
]
| {"/weather/admin.py": ["/weather/models.py", "/weather/forms.py"], "/weather/management/commands/sendemail.py": ["/weather/models.py", "/weather/weather_service.py", "/weather/email_service.py"], "/weather/migrations/0001_initial.py": ["/weather/models.py"], "/weather/forms.py": ["/weather/models.py"]} |
52,279 | zackhillman/weather | refs/heads/master | /weather/forms.py | from django import forms
from .models import User
from dal import autocomplete
class SubscribeForm(forms.ModelForm):
class Meta:
model = User
fields = ['email', 'location']
widgets = {
'location': autocomplete.ModelSelect2(url='select2_fk') #for autocomplete view
} | {"/weather/admin.py": ["/weather/models.py", "/weather/forms.py"], "/weather/management/commands/sendemail.py": ["/weather/models.py", "/weather/weather_service.py", "/weather/email_service.py"], "/weather/migrations/0001_initial.py": ["/weather/models.py"], "/weather/forms.py": ["/weather/models.py"]} |
52,280 | zackhillman/weather | refs/heads/master | /weather/weather_service.py | import requests, json
class WeatherData():
def __init__(self):
self.info = {}
self.key = '4e2cd17eb05943aa8192f7ccabec1a22'
def getWeather(self, coord):
if coord in self.info:
return self.info[coord]
else:
return self.callAPI(coord)
def callAPI(self, coord):
try:
lat = coord[0]
lon = coord[1]
url = 'http://api.weatherbit.io/v2.0/forecast/daily?days=2&units=I&lat={}&lon={}&key={}'.format(lat, lon, self.key)
response = requests.get(url).json()
today = response['data'][0]
tomorrow = response['data'][1]
data = {
'today_temp': today['temp'],
'tomorrow_temp': tomorrow['temp'],
'precip': today['pop'],
'condition': today['weather']['code'],
'iCode': today['weather']['icon']
}
self.info[coord] = data
return data
except:
print(response)
return | {"/weather/admin.py": ["/weather/models.py", "/weather/forms.py"], "/weather/management/commands/sendemail.py": ["/weather/models.py", "/weather/weather_service.py", "/weather/email_service.py"], "/weather/migrations/0001_initial.py": ["/weather/models.py"], "/weather/forms.py": ["/weather/models.py"]} |
52,281 | zackhillman/weather | refs/heads/master | /weather/models.py | from django.db import models
class Location(models.Model):
name = models.CharField(max_length=100) #city name
state = models.CharField(max_length=100)
lon = models.DecimalField(max_digits=9, decimal_places=6)
lat = models.DecimalField(max_digits=9, decimal_places=6)
def __str__(self):
return "{}, {}".format(self.name, self.state)
# Represents a subscriber: email & location (fk)
class User(models.Model):
email = models.EmailField(unique = True)
location = models.ForeignKey(Location, on_delete=models.DO_NOTHING)
def __str__(self):
return self.email + ":" + str(self.location) | {"/weather/admin.py": ["/weather/models.py", "/weather/forms.py"], "/weather/management/commands/sendemail.py": ["/weather/models.py", "/weather/weather_service.py", "/weather/email_service.py"], "/weather/migrations/0001_initial.py": ["/weather/models.py"], "/weather/forms.py": ["/weather/models.py"]} |
52,282 | luckytheyukondog/my-first-blog | refs/heads/master | /blog/forms.py | from django import forms
from django.forms import TextInput
from .models import Post, thick
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ('title', 'text',)
class ThicknessForm(forms.ModelForm):
class Meta:
model = thick
fields = ('angle', 'dhthick')
labels = {
"angle": "Angle of feature to core axis (0-90):",
"dhthick":"Downhole thickness:"
}
widgets = {
'angle': TextInput(attrs={'placeholder': ''}),
'dhthick': TextInput(attrs={'placeholder': ''}),
} | {"/blog/forms.py": ["/blog/models.py"]} |
52,283 | luckytheyukondog/my-first-blog | refs/heads/master | /blog/migrations/0002_thick.py | # Generated by Django 2.2.1 on 2019-05-14 03:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blog', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='thick',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('angle', models.FloatField()),
('dhthick', models.FloatField()),
],
),
]
| {"/blog/forms.py": ["/blog/models.py"]} |
52,284 | luckytheyukondog/my-first-blog | refs/heads/master | /blog/truethickness.py |
from flask import Flask, request
from calculator import calc
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route("/", methods=["GET", "POST"])
def adder_page():
errors = ""
if request.method == "POST":
a = None
d = None
try:
a = float(request.form["a"])
except:
errors += "<p>{!r} is not a number.</p>\n".format(request.form["a"])
try:
d = float(request.form["d"])
except:
errors += "<p>{!r} is not a number.</p>\n".format(request.form["d"])
if a is not None and d is not None:
result = calc(a, d)
return '''
<html>
<body>
<p>The result is {result}</p>
<p><a href="/">Click here to calculate again</a>
</body>
</html>
'''.format(result=result)
return '''
<html>
<head>
<title>LuckytheDog</title>
</head>
<body>
{errors}
<h1>True Thickness Calculator</h1>
<p>Angle to core axis:
<form method="post" action=".">
<p><input name="a" /></p>
<p>Downhole thickness:
<p><input name="d" /></p>
<p><input type="submit" value="Calculate" /></p>
</form>
</body>
</html>
'''.format(errors=errors)
| {"/blog/forms.py": ["/blog/models.py"]} |
52,285 | luckytheyukondog/my-first-blog | refs/heads/master | /blog/models.py | from django.conf import settings
from django.db import models
from django.utils import timezone
from bokeh.core.properties import List, String, Dict, Int
from bokeh.models import LayoutDOM
class Post(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
class thick(models.Model):
angle = models.FloatField()
dhthick = models.FloatField()
| {"/blog/forms.py": ["/blog/models.py"]} |
52,286 | luckytheyukondog/my-first-blog | refs/heads/master | /blog/calculator.py | import math
def calc(angle,dhthick):
angle=math.radians(angle)
angle=math.sin(angle)
return angle*dhthick | {"/blog/forms.py": ["/blog/models.py"]} |
52,289 | YAZAH/StrategyIA | refs/heads/dev | /tests/Executors/test_coachExecutor.py | # Under MIT License, see LICENSE.txt
""" Module de test pour CoachExecutor, nosetests style """
from nose.tools import assert_equal
from ai.InfoManager import InfoManager
from ai.Executor.CoachExecutor import CoachExecutor
from RULEngine.Game import Ball, Field, Player, Team
__author__ = 'RoboCupULaval'
class TestCoachExecutor:
""" Class pour CoachExecutor """
@classmethod
def setup(cls):
""" Setup """
players = []
for i in range(6):
players.append(Player.Player(i))
cls.info_manager = InfoManager(Field.Field(Ball.Ball()),
Team.Team(players, True),
Team.Team(players, False))
cls.coach = CoachExecutor(cls.info_manager)
def test_exec(self):
""" Test basic de exec, le prochain play et le play actuel ne concorde
pas.
"""
# FIXME: actuellement get_next_play retourne un play fix
self.info_manager.set_play('pHalt')
self.coach.exec()
assert_equal(self.info_manager.get_current_play(), 'pTestBench')
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,290 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sNull.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
from RULEngine.Util.Pose import Pose
import copy
__author__ = 'RoboCupULaval'
class sNull(SkillBase):
"""
sNull generate next pose which is its pose
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
return copy.deepcopy(pose_player)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,291 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/pDemoGoalKeeper.py | #Under MIT License, see LICENSE.txt
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
SEQUENCE_DEMO_GOAL_KEEPER = ['tGoalKeeper', 'tGoalKeeper', 'tGoalKeeper',
'tGoalKeeper', 'tGoalKeeper', 'tGoalKeeper']
class pDemoGoalKeeper(PlayBase):
"""
Demonstration mode:
+ GoalKeeper behaviour for all bots.
"""
def __init__(self):
PlayBase.__init__(self, self.__class__.__name__)
self._sequence = [SEQUENCE_DEMO_GOAL_KEEPER]
def getTactics(self, index=None):
if index is None:
return self._sequence[0]
else:
return self._sequence[index]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,292 | YAZAH/StrategyIA | refs/heads/dev | /UltimateStrategy.py | #Under MIT License, see LICENSE.txt
""" Module supérieur de l'IA """
from RULEngine.Strategy.Strategy import Strategy
from RULEngine.Command import Command
from RULEngine.Util.Pose import Pose
import RULEngine.Util.geometry as geometry
from ai.Executor.CoachExecutor import CoachExecutor
from ai.Executor.PlayExecutor import PlayExecutor
from ai.Executor.TacticExecutor import TacticExecutor
from ai.Executor.SkillExecutor import SkillExecutor
from ai.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class UltimateStrategy(Strategy):
""" Niveau supérieur de l'IA, est appelé et créé par Framework.
La classe créée une partie du GameState et exécute la boucle principale
de la logique de l'IA.
À chaque itération, les Executors sont déclenchés et InfoManager est
mit à jour.
À la fin d'une itération, les commandes des robots sont récupérées dans
l'InfoManager et finalement envoyée au serveur de communication.
"""
def __init__(self, field, referee, team, opponent_team, is_team_yellow=False):
""" Constructeur, réplique une grande partie du GameState pour
construire l'InfoManager. TODO: éliminer cette redondance (DRY)
"""
Strategy.__init__(self, field, referee, team, opponent_team)
# Create InfoManager
self.team.is_team_yellow = is_team_yellow
self.info_manager = InfoManager(field, team, opponent_team)
# Create Executors
self.ex_coach = CoachExecutor(self.info_manager)
self.ex_play = PlayExecutor(self.info_manager)
self.ex_tactic = TacticExecutor(self.info_manager)
self.ex_skill = SkillExecutor(self.info_manager)
def on_start(self):
""" Boucle principale de l'IA, est appelé par Framework """
self.info_manager.update()
# Main Strategy sequence
self.ex_coach.exec()
self.ex_play.exec()
self.ex_tactic.exec()
self.ex_skill.exec()
# ::COMMAND SENDER::
# TODO: Extraire en méthode
for i in range(6):
next_action = self.info_manager.get_player_next_action(i)
if isinstance(next_action, Pose):
# Move Manager :: if next action is Pose
command = Command.MoveToAndRotate(self.team.players[i],
self.team,
next_action)
self._send_command(command)
elif isinstance(next_action, int):
# Kick Manager :: if next action is int
if not 0 < next_action <= 8:
next_action = 5
command = Command.Kick(self.team.players[i],
self.team,
next_action)
self._send_command(command)
player_pos = self.info_manager.get_player_position(i)
ball_pos = self.info_manager.get_ball_position()
if geometry.get_distance(player_pos, ball_pos) > 150:
player_pos = self.info_manager.get_player_position(i)
self.info_manager.set_player_next_action(i, player_pos)
else:
# Path Manager :: if next action is list of Pose
# TODO: refactor dans PathExecutor
if geometry.get_distance(self.info_manager.get_player_position(i),
next_action[0].position) < 180:
next_pose = next_action.pop(0)
if len(next_action) == 0:
next_action = next_pose
self.info_manager.set_player_next_action(i, next_action)
command = Command.MoveToAndRotate(self.team.players[i],
self.team,
next_pose)
self._send_command(command)
else:
# TODO: code smell
command = Command.MoveToAndRotate(self.team.players[i],
self.team,
next_action[0])
self._send_command(command)
def on_halt(self):
self.on_start()
def on_stop(self):
self.on_start()
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,293 | YAZAH/StrategyIA | refs/heads/dev | /tests/Executors/test_pathfinderExecutor.py | #Under MIT License, see LICENSE.txt
# TODO Faire des tests quand le pathfinder sera implemente
from unittest import TestCase
from ai.Executor.PathfinderExecutor import *
from RULEngine.Game.Field import Field
from RULEngine.Game.Ball import Ball
from RULEngine.Game.Team import Team
from RULEngine.Game.Player import Player
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class TestPathfinderExecutor(TestCase):
"""Tests de la classe PathfinderExecutor"""
def setUp(self):
self.current_skill = None
self.current_target = Pose(Position(0, 0), 0)
self.current_goal = Pose(Position(1, 1), 1)
# Initialisation de l'InfoManager avec des équipes de robots et une balle
self.team = Team([Player(bot_id) for bot_id in range(6)], True)
for player in self.team.players:
self.team.players[player.id].position = Position(100 * player.id, 100 * player.id)
self.op_team = Team([Player(bot_id) for bot_id in range(6)], False)
for player in self.op_team.players:
self.op_team.players[player.id].position = Position(-100 * player.id - 100, -100 * player.id - 100)
self.field = Field(Ball())
self.field.ball.set_position(Position(1000, 0), 1)
self.info = InfoManager(self.field, self.team, self.op_team)
def test_execSkillnNull(self):
"""Test la fonction exec si current_Skill == None"""
self.assertRaises(Exception,self.current_skill,None)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,294 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Play/test_playBase.py | #Under MIT License, see LICENSE.txt
import unittest
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
class TestPlayBase(unittest.TestCase):
def setUp(self):
self.play_book = PlayBase()
def test_getTactics(self):
pass
def test_getBook(self):
self.assertIsInstance(self.play_book.getBook(), dict)
if __name__ == '__main__':
unittest.main() | {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,295 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/pDefense.py | ##Under MIT License, see LICENSE.txt
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
SEQUENCE_DEFENSE = ['tGoalKeeper', 'tGoalKeeper', 'tGoalKeeper',
'tGoalKeeper', 'tGoalKeeper', 'tGoalKeeper']
class pDefense(PlayBase):
"""
Competition mode:
x GoalKeeper behaviour versus three forwards.
"""
def __init__(self):
PlayBase.__init__(self, self.__class__.__name__)
self._sequence = [SEQUENCE_DEFENSE]
def getTactics(self, index=None):
if index is None:
return self._sequence[0]
else:
return self._sequence[index]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,296 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sFollowTarget.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sFollowTarget import sFollowTarget
from RULEngine.Util.Pose import Pose, Position
from RULEngine.Util.geometry import get_angle
__author__ = 'RoboCupULaval'
class TestSkillFollowTarget(TestCase):
""" Tests de la classe sGoToTarget """
def setUp(self):
self.skill = sFollowTarget()
self.target = Pose(Position(0, 0), 0)
self.goal = Pose(Position(1, 1), 1)
self.bot_pos = Pose(Position(2, 2), 2)
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sFollowTarget)
def test_name(self):
self.assertEqual(self.skill.name, sFollowTarget.__name__)
def test_return(self):
result = self.skill.act(self.bot_pos, self.target.position, self.goal.position)
angle = get_angle(self.bot_pos.position, self.target.position)
result_hope = Pose(self.target.position, angle)
self.assertIsNotNone(result)
self.assertIsInstance(result, Pose)
self.assertEqual(result.orientation, result_hope.orientation)
self.assertEqual(result.position, result_hope.position)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,297 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/test_sFollowTarget.py | # Under MIT License, see LICENSE.txt
""" Module de test pour Action GoToTarget """
from nose.tools import assert_equal
from ai.STP.Skill.sFollowTarget import sFollowTarget
from RULEngine.Util.geometry import get_angle
from RULEngine.Util.Position import Position
from RULEngine.Util.Pose import Pose
__author__ = 'RoboCupULaval'
def test_act():
""" Test de base """
player = Pose(Position(0,0), 0)
target = Position(500, -300)
angle = get_angle(player.position, target)
expect = Pose(target, angle)
action = sFollowTarget()
result = action.act(player, target, None)
assert_equal(result.position, expect.position)
# comparaison foireuse de float
delta = result.orientation - expect.orientation
assert delta < 0.001
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,298 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sGeneratePath.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sGeneratePath import sGeneratePath
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class TestSkillGeneratePath(TestCase):
""" Tests de la classe sGeneratePath """
def setUp(self):
self.skill = sGeneratePath()
self.target = Pose(Position(0, 0), 0)
self.goal = Pose(Position(1, 1), 1)
self.bot_pos = Pose(Position(2, 2), 2)
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sGeneratePath)
def test_name(self):
self.assertEqual(self.skill.name, sGeneratePath.__name__)
def test_return(self):
result = self.skill.act(self.bot_pos, self.target, self.goal)
bot_angle = self.bot_pos.orientation
result_hope = [Pose(Position(0, 0), bot_angle),
Pose(Position(0, 3000), bot_angle),
Pose(Position(3000, 3000), bot_angle),
Pose(Position(3000, 0), bot_angle),
Pose(Position(0, 0), bot_angle)
]
self.assertIsNotNone(result)
self.assertIsInstance(result, list)
for i, obj in enumerate(result):
self.assertIsInstance(obj, Pose)
self.assertEqual(obj.orientation, result_hope[i].orientation)
self.assertEqual(obj.position, result_hope[i].position)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,299 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Tactic/test_tGoalKeeper.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from RULEngine.Game.Field import Field
from RULEngine.Game.Ball import Ball
from RULEngine.Game.Team import Team
from RULEngine.Game.Player import Player
from RULEngine.Util.Pose import Pose, Position
from ai.STP.Tactic.tGoalKeeper import tGoalKeeper
from ai.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class TestTacticGoalKeeper(TestCase):
""" Tests de la classe tGoalKeeper """
def setUp(self):
self.tactic = tGoalKeeper()
# Initialisation de l'InfoManager avec des équipes de robots et une balle
self.team = Team([Player(bot_id) for bot_id in range(6)], True)
for player in self.team.players:
self.team.players[player.id].position = Position(100 * player.id, 100 * player.id)
self.op_team = Team([Player(bot_id) for bot_id in range(6)], False)
for player in self.op_team.players:
self.op_team.players[player.id].position = Position(-100 * player.id - 100, -100 * player.id - 100)
self.field = Field(Ball())
self.field.ball.set_position(Position(1000, 0), 1)
self.info = InfoManager(self.field, self.team, self.op_team)
def test_construction(self):
self.assertNotEqual(self.tactic, None)
self.assertIsInstance(self.tactic, tGoalKeeper)
def test_name(self):
self.assertEqual(self.tactic.name, tGoalKeeper.__name__)
def test_return(self):
result = self.tactic.apply(self.info, 0)
ball_pst = self.info.get_ball_position()
self.assertIsNotNone(result)
self.assertIsInstance(result, dict)
self.assertEqual(result, {'skill': 'sGoBehindTargetGoal_GK', 'target': ball_pst, 'goal': Position(-4500, 0)})
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,300 | YAZAH/StrategyIA | refs/heads/dev | /ai/Algorithm/RVOPathfinder.py | # Under MIT License, see LICENSE.txt
from RULEngine.Util.geometry import Position, get_angle, get_distance
import timeit as t
import math as m
from StrategyIA.UltimateStrat.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class RVOPathfinder:
"""Pathfinder qui esquive les obstacles mobiles.
Calcule un vecteur de base à suivre pour atteindre la cible.
Ce vecteur sera modifié 10fois (2 projections par obstacle)
pour prévoir leur déplacement et ainsi les esquiver.
"""
def vector_generator(self, id_player, target):
player = InfoManager.get_player_position(id_player) # Position du joueur
# target = InfoManager.get_ball_position() # Position de la balle
const_path = -10000 # Constante de réglage
obstacles_list = [] # Liste des obstacles (de 1 à 6, le 0 étant celui qui va chercher la balle)
for num in range(1, 6): # On remplit la liste des obstacle avec la position de chacun (position, id)
obstacles_list.append((InfoManager.get_player_position(num), num))
theta = get_angle(player, target) # angle entre le joueur et la balle
begin = t.timeit() # Pour calculer le temps
if get_distance(player, target) > 150: # Tant que la distance entre le robot est la balle > 100mm
relative_vector = Position((player.x + m.cos(theta) * 100),
(player.y + m.sin(theta) * 100)) # On donne un vecteur au robot à suivre
print("Vecteur initial du robot à suivre: " + str(relative_vector))
for obstacle in obstacles_list: # Boucle pour chaque obstacle dans la liste
alpha = get_angle(player, obstacle[0]) # Angle entre joueur et obstacle
obstacle_velocity = InfoManager.get_speed(obstacle[1]) # Vitesse de l'obstacle obstacle[1]
print("Vecteur vitesse de l'obstacle: " + str(obstacle[1]) + ": " + str(obstacle_velocity[
'vector']))
projected_list = projection_calculation(obstacle, obstacle_velocity) # Fonction de calcul
dist = get_distance(player, obstacle[0]) # Distance joueur-obstacle
dist_revised = const_path / dist # Cte pour régler les vecteurs obstacles.
obstacle_vector = Position(m.cos(alpha) * dist_revised,
m.sin(alpha) * dist_revised) # vecteur obstacle de base
print("Vecteur de base est de: " + str(obstacle_vector))
for projected_obstacle in projected_list: # Pour chaque obstacle
# Distance entre joueur et la projection de l'obstacle
distance = get_distance(player, projected_obstacle)
distance_revised = const_path / distance # Cte pour régler les vecteurs obstacles pondérés
# Vecteur de la projection de l'obstacle
projected_obstacle_vector = Position(m.cos(alpha) * distance_revised,
m.sin(alpha) * distance_revised)
# On ajoute le vecteur de la projection au vecteur obstacle de base
obstacle_vector += projected_obstacle_vector
print("Vecteur après les projections est de: " + str(obstacle_vector))
relative_vector += obstacle_vector # On ajoute les vecteurs des projections au vecteur initial
n = m.atan2(relative_vector.y - player.y, relative_vector.x - player.x)
relative_vector = Position(player.x + m.cos(n) * 100,
player.y + m.sin(n) * 100) # Vecteur final du robot à suivre
end = t.timeit() # Le temps nécessaire pour calculer un nouveau vecteur
print("\nTemps utilisé pour le calcul du vecteur final: " + str(abs(end - begin)) + " seconde")
print("Vecteur final du robot à suivre: " + str(relative_vector) + "\n")
return relative_vector
else:
return player
# return {'skill': 'sFollowTarget', 'target': relative_vector, 'goal': target}
# else:
# return {'skill': 'sStop', 'target': player, 'goal': player}
def projection_calculation(obstacle, obstacle_velocity, projected_obstacle_list=None, delta_t=1, acceleration=1500):
"""Calcul de la projection d'un obstacle.
argument:
obstacle -- Numéro de l'obstacle
obstacle_velocity -- Vitesse de l'obstacle
projectedObstacleList -- Liste qui contient la projection de l'obstacle (vide par défaut)
deltaT -- 1 Seconde
acceleration -- Accélération du robot (par défaut 1500mm/s**2)
"""
if projected_obstacle_list is None:
projected_obstacle_list = []
for i in range(2):
# Calcul de la projection dans le axe des x
projection_x = obstacle[0].x + float(obstacle_velocity['vector'][0]) * (delta_t * i / 50) \
+ acceleration * ((delta_t * i / 50) ** 2) / 2
# Calcul de la projection dans le axe des y
projection_y = obstacle[0].y + float(obstacle_velocity['vector'][1]) * (delta_t * i / 50) \
+ acceleration * ((delta_t * i / 50) ** 2) / 2
# Projection des 2 prochaines positions de l’obstacle (à 0s et 0.02s)
projection = Position(projection_x, projection_y)
# On l'ajoute dans la liste (Projec1, Projec2)
projected_obstacle_list.append(projection)
print("Pour le robot numéro " + str(obstacle[1]) + " : Projection dans " + str(i / 50) + " seconde: " + str(
projection))
return projected_obstacle_list
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,301 | YAZAH/StrategyIA | refs/heads/dev | /ai/Executor/TacticExecutor.py | # Under MIT License, see LICENSE.txt
""" Cet Executor se charge d'assigner les Skill aux robots en fonction de leur
Tactic.
"""
from ai.Executor.Executor import Executor
__author__ = 'RoboCupULaval'
class TacticExecutor(Executor):
""" TacticExecutor est une séquence de requêtes qui assigne un Skill à
chaque robot.
"""
def __init__(self, info_manager):
""" Constructeur.
:param info_manager: Référence à la facade InfoManager pour pouvoir
accéder aux informations du GameState.
"""
Executor.__init__(self, info_manager)
def exec(self):
""" Obtient la Tactic de chaque robot et calcul la Skill à assigner."""
# Execution for each players
for id_player in range(self.info_manager.get_count_player()):
# 1 - what's player tactic ?
current_tactic = self.info_manager.get_player_tactic(id_player)
# 2 - get specific tactic from tactic book
tactic = self.tactic_book[current_tactic]
# 3 - select skill, target, goal from tactic object
action = tactic().apply(self.info_manager, id_player)
# 4 - set skill, target, goal
self.info_manager.set_player_skill_target_goal(id_player, action)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,302 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/tGoalKeeper.py | #Under MIT License, see LICENSE.txt
from RULEngine.Util.constant import *
from ai.STP.Tactic.TacticBase import TacticBase
from RULEngine.Util.geometry import *
__author__ = 'RoboCupULaval'
class tGoalKeeper(TacticBase):
"""
Basic behaviour for Goal Keeper.
"""
def __init__(self):
TacticBase.__init__(self, self.__class__.__name__)
def apply(self, info_manager, id_player):
p_ball = info_manager.get_ball_position()
return {'skill': 'sGoBehindTargetGoal_GK', 'target': p_ball, 'goal': Position(-4500, 0)}
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,303 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sKickLow.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
__author__ = 'jama'
class sKickLow(SkillBase):
"""
sKickLow generate kick if ball is front of it with low speed
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
return 2
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,304 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/tStop.py | #Under MIT License, see LICENSE.txt
from ai.STP.Tactic.TacticBase import TacticBase
__author__ = 'RoboCupULaval'
class tStop(TacticBase):
def __init__(self):
TacticBase.__init__(self, self.__class__.__name__)
def apply(self, info_manager, id_player):
bot_position = info_manager.get_player_position(id_player)
return {'skill': 'sStop', 'target': bot_position, 'goal': bot_position}
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,305 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/PlayBase.py | # Under MIT License, see LICENSE.txt
""" Module contenant la classe abstraite PlayBase """
from abc import abstractmethod
__author__ = 'RoboCupULaval'
class PlayBase:
""" Un Play contients:
+ Une séquence de Tactic pour chaque robot.
+ Le PlayBook -> un dictionnaire {PlayName: Play object}
"""
@abstractmethod
def __init__(self, name='pBook'):
self.name = name
@abstractmethod
def getTactics(self, index=None):
""" Retourne la Tactic.
:param index: L'index du robot, par défaut None.
:return: list [TacticR0, TacticR1, ... , TacticR5]
"""
pass
def __getitem__(self, item):
"""
:param item: str
:return: Play
"""
return self.getBook()[item]
def getBook(self):
""" Retourne le PlayBook
:return: dict {'Play.__name__' = Play}
"""
return dict(zip([cls.__name__ for cls in self.__class__.__subclasses__()],
self.__class__.__subclasses__()))
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,306 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sKickMedium.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
__author__ = 'jama'
class sKickMedium(SkillBase):
"""
sKickMedium generate kick if ball is front of it with medium speed
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
return 3
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,307 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sGeneratePath.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class sGeneratePath(SkillBase):
"""
sGeneratePath generate a predefined path
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
bot_angle = pose_player.orientation
return [Pose(Position(0, 0), bot_angle),
Pose(Position(0, 3000), bot_angle),
Pose(Position(3000, 3000), bot_angle),
Pose(Position(3000, 0), bot_angle),
Pose(Position(0, 0), bot_angle)
]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,308 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sFollowTarget.py | # Under MIT License, see LICENSE.txt
""" Action: fait suivre le robot une cible """
from ai.STP.Skill.SkillBase import SkillBase
from RULEngine.Util.Pose import Pose
from RULEngine.Util.geometry import get_angle
__author__ = 'RoboCupULaval'
class sFollowTarget(SkillBase):
""" sFollowTarget génère une Pose selon la target """
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
angle = get_angle(pose_player.position, pose_target)
return Pose(pose_target, angle)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,309 | YAZAH/StrategyIA | refs/heads/dev | /ai/Executor/PathfinderExecutor.py | #Under MIT License, see LICENSE.txt
# TODO: Implementer l'algorithme de pathfinding et rendre générique pour cette fonction
from ai.Executor.Executor import Executor
from ai.InfoManager import InfoManager
import random
import math
__author__ = 'agingrasc'
class PathfinderExecutor:
"""
PathfinderExecutor est une serie d'iteration pour trouver le prochain
point de deplacement de chaque joueur avec un RapidRandomTree pathfinder.
1 - Quel est la position actuel du joueur?
2 - Quel est son objectif?
3 - Generation du mouvement a effectuer.
S3 - Validation de chaque delta contre les contraintes.
"""
def __init__(self, InfoManager):
Executor.__init__(self, InfoManager)
self.rrt = []
def exec(self):
# Fonction vide pour faire marcher le test
for i in range(InfoManager.getCountPlayer()):
None
def gen_rrt(player):
"""Prend un joueur et genere son rrt pour trouver un chemin"""
# 1 - Position du joueur
pos = InfoManager.getPlayerPosition(player)
# 2 - Cible
target = InfoManager.getPlayerTarget(player)
# 3 - Generation
# rrt doit etre implemente
def is_near(target, latest):
# Fonction vide pour faire marcher le test
None
def norm(pos1, pos2):
x1, y1 = pos1
x2, y2 = pos2
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,310 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/tFollowBall.py | #Under MIT License, see LICENSE.txt
from ai.STP.Tactic.TacticBase import TacticBase
from RULEngine.Util.geometry import *
__author__ = 'RoboCupULaval'
class tFollowBall(TacticBase):
def __init__(self):
TacticBase.__init__(self, self.__class__.__name__)
def apply(self, info_manager, id_player):
ball_position = info_manager.get_ball_position()
bot_position = info_manager.get_player_position(id_player)
#print("follow:" + str(bot_position))
#print(info_manager.black_board['friend'][str(id_player)].keys())
dst_ball_bot = get_distance(ball_position, bot_position)
if dst_ball_bot > 500:
return {'skill': 'sGoToTarget', 'target': ball_position, 'goal': bot_position}
else:
return {'skill': 'sGoToTarget', 'target': bot_position, 'goal': bot_position}
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,311 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Tactic/test_tPath.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from RULEngine.Game.Field import Field
from RULEngine.Game.Ball import Ball
from RULEngine.Game.Team import Team
from RULEngine.Game.Player import Player
from RULEngine.Util.Pose import Pose, Position
from ai.STP.Tactic.tPath import tPath
from ai.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class TestTacticStop(TestCase):
""" Tests de la classe tPath """
def setUp(self):
self.tactic = tPath()
# Initialisation de l'InfoManager avec des équipes de robots et une balle
self.team = Team([Player(bot_id) for bot_id in range(6)], True)
for player in self.team.players:
self.team.players[player.id].position = Position(100 * player.id, 100 * player.id)
self.op_team = Team([Player(bot_id) for bot_id in range(6)], False)
for player in self.op_team.players:
self.op_team.players[player.id].position = Position(-100 * player.id - 100, -100 * player.id - 100)
self.field = Field(Ball())
self.field.ball.set_position(Position(1000, 0), 1)
self.info = InfoManager(self.field, self.team, self.op_team)
def test_construction(self):
self.assertNotEqual(self.tactic, None)
self.assertIsInstance(self.tactic, tPath)
def test_name(self):
self.assertEqual(self.tactic.name, tPath.__name__)
def test_if_next_action_is_pose(self):
self.info.friend['0']['next_pose'] = Pose(Position(2000, 0), 0)
result = self.tactic.apply(self.info, 0)
ball_pst = self.info.get_ball_position()
self.assertIsNotNone(result)
self.assertIsInstance(result, dict)
self.assertEqual(result, {'skill': 'sGeneratePath', 'target': ball_pst, 'goal': ball_pst})
def test_if_next_action_is_list_of_pose(self):
self.info.friend['0']['next_pose'] = [Pose(Position(2000, 0), 0), Pose(Position(0, 2000), 0)]
result = self.tactic.apply(self.info, 0)
ball_pst = self.info.get_ball_position()
self.assertIsNotNone(result)
self.assertIsInstance(result, dict)
self.assertEqual(result, {'skill': 'sWait', 'target': ball_pst, 'goal': ball_pst})
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,312 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sKickMedium.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sKickMedium import sKickMedium
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class TestSkillKickMedium(TestCase):
""" Tests de la classe sKickMedium """
def setUp(self):
self.skill = sKickMedium()
self.target = Pose(Position(0, 0), 0)
self.goal = Pose(Position(1, 1), 1)
self.bot_pos = Pose(Position(2, 2), 2)
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sKickMedium)
def test_name(self):
self.assertEqual(self.skill.name, sKickMedium.__name__)
def test_return(self):
result = self.skill.act(self.bot_pos, self.target, self.goal)
self.assertIsNotNone(result)
self.assertIsInstance(result, int)
self.assertEqual(result, 3)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,313 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Play/test_pHalt.py | # Under MIT License, see LICENSE.txt
""" Module test pHalt """
import unittest
from ai.STP.Play.pHalt import pHalt, SEQUENCE_HALT
class testPPathAxis(unittest.TestCase):
""" Class test pHalt """
def setUp(self):
self.pHalt = pHalt()
def test_getTactics_with_no_args(self):
self.assertEqual(SEQUENCE_HALT, self.pHalt.getTactics())
def test_getTactics_with_index(self):
self.assertEqual(SEQUENCE_HALT[0], self.pHalt.getTactics(0))
def test_get_Tactics_with_invalid_index(self):
self.assertRaises(IndexError, self.pHalt.getTactics, 6)
if __name__ == '__main__':
unittest.main()
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,314 | YAZAH/StrategyIA | refs/heads/dev | /ai/Executor/Executor.py | #Under MIT License, see LICENSE.txt
from abc import abstractmethod
from ai.STP.Skill.SkillBase import SkillBase
from ai.STP.Tactic.TacticBase import TacticBase
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
class Executor:
def __init__(self, info_manager):
self.info_manager = info_manager
self.play_book = PlayBase()
self.tactic_book = TacticBase()
self.skill_book = SkillBase()
@abstractmethod
def exec(self):
pass | {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,315 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sWait.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
__author__ = 'RoboCupULaval'
class sWait(SkillBase):
"""
sWait is a no-change action
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
return None
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,316 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/SkillBase.py | #Under MIT License, see LICENSE.txt
from abc import abstractmethod
__author__ = 'RoboCupULaval'
class SkillBase:
"""
Skill contain :
+ Analyze current situation on the field and generate next specific robot position thanks to its target and goal.
+ Skill book - Regroup all skill action in dictionary {'Skill.__name__':Skill object}
"""
@abstractmethod
def __init__(self, name='sBook'):
self.name = name
@abstractmethod
def act(self, pose_player, pose_target, pose_goal):
"""
Active skill and set next specific robot position
:param pose_player: Pose
:param pose_target: Pose
:param pose_goal: Pose
:return: Pose
"""
pass
def __getitem__(self, item):
"""
:param item: str
:return: Skill
"""
return self.getBook()[item]
def getBook(self):
"""
:return: dict like {'Skill.__name__' = Skill}
"""
return dict(zip([cls.__name__ for cls in self.__class__.__subclasses__()], self.__class__.__subclasses__())) | {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,317 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/__init__.py | #Under MIT License, see LICENSE.txt
__author__ = 'RoboCupULaval'
import ai.STP.Play.pDemoGoalKeeper
import ai.STP.Play.pDemoFollowBall
import ai.STP.Play.pHalt
import ai.STP.Play.pPath
import ai.STP.Play.pQueueLeuLeu
import ai.STP.Play.pTestBench
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,318 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/tPath.py | #Under MIT License, see LICENSE.txt
from ai.STP.Tactic.TacticBase import TacticBase
from RULEngine.Util.geometry import *
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
DEAD_ZONE = 300
class tPath(TacticBase):
def __init__(self):
TacticBase.__init__(self, self.__class__.__name__)
def apply(self, info_manager, id_player):
ball_pst = info_manager.get_ball_position()
bot_pst = info_manager.get_player_position(id_player)
dst = get_distance(ball_pst, bot_pst)
if isinstance(info_manager.get_player_next_action(id_player), Pose):
return {'skill': 'sGeneratePath', 'target': ball_pst, 'goal': ball_pst}
else:
return {'skill': 'sWait', 'target': ball_pst, 'goal': ball_pst}
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,319 | YAZAH/StrategyIA | refs/heads/dev | /tests/Executors/test_tacticExecutor.py | # Under MIT License, see LICENSE.txt
""" Module de test pour TacticExecutor """
from unittest import TestCase
from RULEngine.Game.Field import Field
from RULEngine.Game.Ball import Ball
from RULEngine.Game.Team import Team
from RULEngine.Game.Player import Player
from RULEngine.Util.Pose import Position
from ai.STP.Play.PlayBase import PlayBase
from ai.STP.Tactic.tNull import tNull
from ai.STP.Tactic.TacticBase import TacticBase
from ai.STP.Skill.SkillBase import SkillBase
from ai.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class TestTacticExecutor(TestCase):
""" Class de test pour TacticExecutor """
def setUp(self):
""" Set up """
self.playbook = PlayBase()
self.tacticbook = TacticBase()
self.skillbook = SkillBase()
# Initialise InfoManager with teams, field, play, tactic and skill.
self.team = Team([Player(bot_id) for bot_id in range(6)], True)
for player in self.team.players:
self.team.players[player.id].position = Position(100 * player.id, 100 * player.id)
self.op_team = Team([Player(bot_id) for bot_id in range(6)], False)
for player in self.op_team.players:
pos_x = -100 * player.id - 100
pos_y = -100 * player.id - 100
self.op_team.players[player.id].position = Position(pos_x, pos_y)
self.field = Field(Ball())
self.field.ball.set_position(Position(1000, 0), 1)
self.info = InfoManager(self.field, self.team, self.op_team)
self.info.update()
# simulate the CoachExecutor without the static function getcurrentplay from the infomanager
self.info.set_play('pHalt')
self.info.init_play_sequence()
# simulate the PlayExecutor with a known play
current_play = 'pHalt'
play = self.playbook[current_play]
play = play()
tactics = play.getTactics()
for i, t in enumerate(tactics):
print("id: " + str(i) + " -- tactic: " + str(t))
self.info.set_player_tactic(i, t)
def test_construction(self):
self.assertNotEqual(self.playbook, None)
self.assertNotEqual(self.tacticbook, None)
self.assertNotEqual(self.skillbook, None)
self.assertIsInstance(self.playbook, PlayBase)
self.assertIsInstance(self.tacticbook, TacticBase)
self.assertIsInstance(self.skillbook, SkillBase)
def test_exec(self):
for id_player in range(self.info.get_count_player()):
self.assertTrue(id_player in range(self.info.get_count_player()))
current_tactic = self.info.get_player_tactic(id_player)
self.assertIs(current_tactic, 'tNull')
self.assertTrue(current_tactic == 'tNull')
tactic = self.tacticbook[current_tactic]
self.assertTrue(tactic == tNull)
self.assertIs(tactic, tNull)
action = tactic().apply(self.info, id_player)
self.info.set_player_skill_target_goal(id_player, action)
self.assertIs(self.info.get_player_skill(id_player), 'sNull')
self.assertIs(self.info.get_player_goal(id_player),
self.info.get_player_position(id_player))
self.assertIs(self.info.get_player_target(id_player),
self.info.get_player_position(id_player))
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,320 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/tTestBench.py | # Under MIT License, see LICENSE.txt
from RULEngine.Util.Position import Position
from ai.STP.Tactic.TacticBase import TacticBase
from ai.Util.geometry import distance
__author__ = 'RoboCupULaval'
class tTestBench(TacticBase):
def __init__(self):
TacticBase.__init__(self, self.__class__.__name__)
def apply(self, info_manager, id_player):
bot_pst = info_manager.get_player_position(id_player)
ball_pst = info_manager.get_ball_position()
action = info_manager.get_player_next_action(id_player)
### PATH and KICK :: TestBench ###
if distance(Position(), ball_pst) < 300:
if distance(bot_pst, ball_pst) < 180:
return {'skill': 'sKickHigh', 'target': bot_pst, 'goal': bot_pst}
else:
return {'skill': 'sFollowTarget', 'target': ball_pst, 'goal': bot_pst}
else:
if isinstance(action, list):
return {'skill': 'sWait', 'target': bot_pst, 'goal': bot_pst}
else:
return {'skill': 'sGeneratePath', 'target': bot_pst, 'goal': bot_pst}
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,321 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/tFollowPrevFriend.py | # Under MIT License, see LICENSE.txt
""" Tactic pour suivre le précédent robot """
from ai.STP.Tactic.TacticBase import TacticBase
from RULEngine.Util.geometry import *
__author__ = 'RoboCupULaval'
class tFollowPrevFriend(TacticBase):
def __init__(self):
TacticBase.__init__(self, self.__class__.__name__)
def apply(self, info_manager, id_player):
player_position = info_manager.get_prev_player_position(id_player)
bot_position = info_manager.get_player_position(id_player)
dst_ball_bot = get_distance(player_position, bot_position)
if dst_ball_bot > 500:
return {'skill': 'sGoToTarget', 'target': player_position, 'goal': bot_position}
else:
return {'skill': 'sGoToTarget', 'target': bot_position, 'goal': bot_position}
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,322 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/pTestBench.py | #Under MIT License, see LICENSE.txt
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
SEQUENCE_TEST_BENCH = ['tTestBench', 'tStop', 'tStop', 'tStop', 'tStop', 'tStop']
class pTestBench(PlayBase):
"""
pTestBench is a test bench play for testing some tactics
"""
def __init__(self):
PlayBase.__init__(self, self.__class__.__name__)
self._sequence = SEQUENCE_TEST_BENCH
def getTactics(self, index=None):
if index is None:
return self._sequence
else:
return self._sequence[index]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,323 | YAZAH/StrategyIA | refs/heads/dev | /ai/Executor/PlayExecutor.py | # Under MIT License, see LICENSE.txt
""" Executor qui se charge de mettre en place les Tactic d'un Play.
"""
from ai.Executor.Executor import Executor
__author__ = 'RoboCupULaval'
class PlayExecutor(Executor):
""" PlayExecutor est une série de requêtes qui sélectionnes les Tactic des
joueurs.
"""
def __init__(self, info_manager):
""" Constructeur de la classe.
:param info_manager: Référence à la facade InfoManager pour pouvoir
accéder aux informations du GameState.
"""
Executor.__init__(self, info_manager)
def exec(self):
""" Obtient le Play actuel, vérifie qu'il existe et assigne la Tactic
appropriée à chaque robot.
"""
# 1 - what's current play
current_play = self.info_manager.get_current_play()
# 2 - what's current play sequence ?
current_seq = self.info_manager.get_current_play_sequence()
# 3 - get specific play sequence from play book
play = self.play_book[current_play]
play = play()
# 4 - set tactics (str) for each players on black board
for i, tactic in enumerate(play.getTactics()):
self.info_manager.set_player_tactic(i, tactic)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,324 | YAZAH/StrategyIA | refs/heads/dev | /ai/Executor/CoachExecutor.py | # Under MIT License, see LICENSE.txt
""" Cet Executor détermine selon les informations du GameState le prochain Play. """
from ai.Executor.Executor import Executor
__author__ = 'RoboCupULaval'
class CoachExecutor(Executor):
""" CoachExecutor est une série de requêtes pour choisir un Play.
1 - Quel est le nouvel état?
2 - Quel est le Play actuel?
3 - Quel devrait être le nouveau Play?
4 - Générer le Play selon le Play choisie et le GameState actuel.
5 - Assigner le Play s'il est différent que l'actuel.
"""
def __init__(self, info_manager):
Executor.__init__(self, info_manager)
def exec(self):
# 1 - what's current state ?
state = self.info_manager.get_next_state()
# 2 - what's current play
current_play = self.info_manager.get_current_play()
# 3 - what's play with state ?
play = self.info_manager.get_next_play(state)
# 4 - compare current play and generate play
if not current_play == play:
# 5 - set play and init sequence if play is not same
self.info_manager.set_play(play)
self.info_manager.init_play_sequence()
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,325 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Tactic/test_tFollowPrevFriend.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from RULEngine.Game.Field import Field
from RULEngine.Game.Ball import Ball
from RULEngine.Game.Team import Team
from RULEngine.Game.Player import Player
from RULEngine.Util.Pose import Pose, Position
from ai.STP.Tactic.tFollowPrevFriend import tFollowPrevFriend
from ai.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class TestTacticFollowPrevFriend(TestCase):
""" Tests de la classe tFollowPrevFriend """
def setUp(self):
self.tactic = tFollowPrevFriend()
# Initialisation de l'InfoManager avec des équipes de robots et une balle
self.team = Team([Player(bot_id) for bot_id in range(6)], True)
for player in self.team.players:
self.team.players[player.id].position = Position(100 * player.id, 100 * player.id)
self.op_team = Team([Player(bot_id) for bot_id in range(6)], False)
for player in self.op_team.players:
self.op_team.players[player.id].position = Position(-100 * player.id - 100, -100 * player.id - 100)
self.field = Field(Ball())
self.field.ball.set_position(Position(1000, 0), 1)
self.info = InfoManager(self.field, self.team, self.op_team)
def test_construction(self):
self.assertNotEqual(self.tactic, None)
self.assertIsInstance(self.tactic, tFollowPrevFriend)
def test_name(self):
self.assertEqual(self.tactic.name, tFollowPrevFriend.__name__)
def test_if_ball_is_far(self):
result = self.tactic.apply(self.info, 0)
bot_pst = self.info.get_player_position(0)
player_pst = self.info.get_prev_player_position(0)
self.assertIsNotNone(result)
self.assertIsInstance(result, dict)
expect = {'skill': 'sGoToTarget', 'target': player_pst, 'goal': bot_pst}
print("Expected\n" + str(expect))
print("Result\n" + str(result))
self.assertEqual(result, expect)
def test_if_ball_is_too_near(self):
# Changement de la position de la balle pour la mettre proche du robot 0
self.info.ball['position'] = Position(50, 50)
result = self.tactic.apply(self.info, 0)
bot_pst = self.info.get_player_position(0)
self.assertIsNotNone(result)
self.assertIsInstance(result, dict)
self.assertEqual(result, {'skill': 'sGoToTarget', 'target': bot_pst, 'goal': bot_pst})
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,326 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sGoToTarget.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sGoToTarget import sGoToTarget
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class TestSkillGoToTarget(TestCase):
""" Tests de la classe sGoToTarget """
def setUp(self):
self.skill = sGoToTarget()
self.target = Pose(Position(0, 0), 0)
self.goal = Pose(Position(1, 1), 1)
self.bot_pos = Pose(Position(2, 2), 2)
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sGoToTarget)
def test_name(self):
self.assertEqual(self.skill.name, sGoToTarget.__name__)
def test_return(self):
result = self.skill.act(self.bot_pos, self.target.position, self.goal.position)
result_hope = Pose(self.target.position, self.bot_pos.orientation)
self.assertIsNotNone(result)
self.assertIsInstance(result, Pose)
self.assertEqual(result.orientation, result_hope.orientation)
self.assertEqual(result.position, result_hope.position)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,327 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sGoBehindTargetGoal_GK.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sGoBehindTargetGoal_GK import sGoBehindTargetGoal_GK
from RULEngine.Util.Pose import Pose, Position
from RULEngine.Util.geometry import get_angle, get_distance
from RULEngine.Util.area import stayInsideCircle
__author__ = 'RoboCupULaval'
class TestSkillGoBehindTargetGoal_GK(TestCase):
""" Tests de la classe sGoBehindTargetGoal_GK """
def setUp(self):
self.skill = sGoBehindTargetGoal_GK()
self.target = Pose(Position(0, 0), 0)
self.goal = Pose(Position(1, 1), 1)
self.bot_pos = Pose(Position(2, 2), 2)
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sGoBehindTargetGoal_GK)
def test_name(self):
self.assertEqual(self.skill.name, sGoBehindTargetGoal_GK.__name__)
def test_return(self):
result = self.skill.act(self.bot_pos, self.target.position, self.goal.position)
# Calcul de la prochaine pose du gardien de but
dst_target_player = get_distance(self.goal.position, self.target.position)
new_pose = Pose(self.target.position, get_angle(self.goal.position, self.target.position))
new_pose.position = stayInsideCircle(new_pose.position, self.goal.position, dst_target_player / 2)
self.assertIsNotNone(result)
self.assertIsInstance(result, Pose)
self.assertEqual(result.orientation, new_pose.orientation)
self.assertEqual(result.position, new_pose.position)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,328 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sKickHigh.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
__author__ = 'RoboCupULaval'
class sKickHigh(SkillBase):
"""
sKick generate kick if ball is front of it with maximum speed
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
return 8
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,329 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/pDemoFollowBall.py | #Under MIT License, see LICENSE.txt
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
SEQUENCE_DEMO_FOLLOW_BALL = ['tFollowBall', 'tFollowBall', 'tFollowBall',
'tFollowBall', 'tFollowBall', 'tFollowBall']
class pDemoFollowBall(PlayBase):
"""
Demonstration mode:
+ Follow ball on the field behaviour of all bots.
"""
def __init__(self):
PlayBase.__init__(self, self.__class__.__name__)
self._sequence = [SEQUENCE_DEMO_FOLLOW_BALL]
def getTactics(self, index=None):
if index is None:
return self._sequence[0]
else:
return self._sequence[index]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,330 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sStop.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sStop import sStop
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class TestSkillStop(TestCase):
""" Tests de la classe sWait """
def setUp(self):
self.skill = sStop()
self.target = Pose(Position(0, 0), 0)
self.goal = Pose(Position(1, 1), 1)
self.bot_pos = Pose(Position(2, 2), 2)
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sStop)
def test_name(self):
self.assertEqual(self.skill.name, sStop.__name__)
def test_return(self):
result = self.skill.act(self.bot_pos, self.target, self.goal)
self.assertIsNotNone(result)
self.assertIsInstance(result, Pose)
self.assertEqual(result.orientation, self.bot_pos.orientation)
self.assertEqual(result.position.x, self.bot_pos.position.x)
self.assertEqual(result.position.y, self.bot_pos.position.y)
self.assertEqual(result.position.z, self.bot_pos.position.z)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,331 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Play/test_pPath.py | #Under MIT License, see LICENSE.txt
import unittest
from ai.STP.Play.pPath import *
class testPPathAxis(unittest.TestCase):
def setUp(self):
self.pPath = pPath()
def test_getTactics_with_no_args(self):
self.assertEqual(SEQUENCE_PATH, self.pPath.getTactics())
def test_getTactics_with_index(self):
self.assertEqual(SEQUENCE_PATH, self.pPath.getTactics(0))
def test_get_Tactics_with_invalid_index(self):
self.assertRaises(IndexError, self.pPath.getTactics, 6)
if __name__ == '__main__':
unittest.main()
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,332 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sGoBehindTargetGoal_GK.py | #Under MIT License, see LICENSE.txt
import math as m
from ai.STP.Skill.SkillBase import SkillBase
from RULEngine.Util.Pose import Pose, Position
from RULEngine.Util.area import *
__author__ = 'RoboCupULaval'
class sGoBehindTargetGoal_GK(SkillBase):
"""
Skill which set position between ball and yellow goal inside goal area.
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pst_target, pst_goal):
dst_target_player = get_distance(pst_goal, pst_target)
new_pos = Pose(pst_target, get_angle(pst_goal, pst_target))
new_pos.position = stayInsideCircle(new_pos.position, pst_goal, dst_target_player / 2)
# new_pos.position = stayInsideCircle(new_pos.position, pst_goal, 350)
# new_pos.position = stayInsideSquare(new_pos.position, 300, -300, 2500, 2920)
return new_pos
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,333 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sPath.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
from RULEngine.Util.Pose import Pose, Position
from RULEngine.Util.geometry import *
import math as m
LEN_VECTOR = 850
DST_SAFE = 650
AGL_FRONT = 0.90
__author__ = 'RoboCupULaval'
class sPath(SkillBase):
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pst_target, pst_goal):
botPose = Pose(Position(pose_player.position.x, pose_player.position.y), pose_player.orientation)
return self._genRelativePose(Pose(pst_target, botPose.orientation), botPose)
def _genRelativePose(self, pose_ref, pose_obj):
agl = m.radians((get_angle(pose_obj.position, pose_ref.position) - pose_ref.orientation + 180)%360)
dst = get_distance(pose_ref.position, pose_obj.position)
nPstX = dst * m.cos(agl)
nPstY = dst * m.sin(agl)
#print(agl)
print("DEBUG",m.degrees(agl))
if nPstX > -DST_SAFE and not m.pi*AGL_FRONT < agl < 2*m.pi - m.pi*AGL_FRONT:
if not -DST_SAFE < nPstY < DST_SAFE:
return self.__moveRelativeBack(pose_obj)
else:
if nPstY > 0:
return self.__moveRelativeLeft(pose_obj)
else:
return self.__moveRelativeRight(pose_obj)
elif m.pi*AGL_FRONT < agl < 2*m.pi - m.pi*AGL_FRONT or -75 < nPstY < 75:
return self.__moveRelativeFront(pose_obj)
else:
if nPstY > 0:
return self.__moveRelativeRight(pose_obj)
else:
return self.__moveRelativeLeft(pose_obj)
@staticmethod
def __moveRelativeFront(pose, lenght=LEN_VECTOR):
#print('Front')
angle = m.radians(pose.orientation)
pst_x = lenght * m.cos(angle) + pose.position.x
pst_y = lenght * m.sin(angle) + pose.position.y
return Pose(Position(pst_x, pst_y), angle)
@staticmethod
def __moveRelativeBack(pose, lenght=LEN_VECTOR):
#print('Back')
angle = m.radians(pose.orientation)
pst_x = lenght * m.cos(angle + m.pi) + pose.position.x
pst_y = lenght * m.sin(angle + m.pi) + pose.position.y
return Pose(Position(pst_x, pst_y), angle)
@staticmethod
def __moveRelativeLeft(pose, lenght=LEN_VECTOR):
#print('Left')
angle = m.radians(pose.orientation)
pst_x = lenght * m.cos(angle + m.pi/2.0) + pose.position.x
pst_y = lenght * m.sin(angle + m.pi/2.0) + pose.position.y
return Pose(Position(pst_x, pst_y), angle)
@staticmethod
def __moveRelativeRight(pose, lenght=LEN_VECTOR):
#print('Right')
angle = m.radians(pose.orientation)
pst_x = lenght * m.cos(angle - m.pi/2.0) + pose.position.x
pst_y = lenght * m.sin(angle - m.pi/2.0) + pose.position.y
return Pose(Position(pst_x, pst_y), angle)
#if __name__ == '__main__':
# sPath().act(Pose(Position(-255, -50), 0), Position(0, 0), Position(0, 0)) | {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,334 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Play/test_pDemoFollwBall.py | #Under MIT License, see LICENSE.txt
import unittest
from ai.STP.Play.pDemoFollowBall import *
class testPPathAxis(unittest.TestCase):
def setUp(self):
self.pDemoFollowBall = pDemoFollowBall()
def test_getTactics_with_no_args(self):
self.assertEqual(SEQUENCE_DEMO_FOLLOW_BALL, self.pDemoFollowBall.getTactics())
def test_getTactics_with_index(self):
self.assertEqual(SEQUENCE_DEMO_FOLLOW_BALL, self.pDemoFollowBall.getTactics(0))
def test_get_Tactics_with_invalid_index(self):
self.assertRaises(IndexError, self.pDemoFollowBall.getTactics, 6)
if __name__ == '__main__':
unittest.main()
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,335 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Tactic/test_tFollowBall.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from RULEngine.Game.Field import Field
from RULEngine.Game.Ball import Ball
from RULEngine.Game.Team import Team
from RULEngine.Game.Player import Player
from RULEngine.Util.Pose import Pose, Position
from ai.STP.Tactic.tFollowBall import tFollowBall
from ai.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class TestTacticFollowBall(TestCase):
""" Tests de la classe tFollowBall """
def setUp(self):
self.tactic = tFollowBall()
# Initialisation de l'InfoManager avec des équipes de robots et une balle
self.team = Team([Player(bot_id) for bot_id in range(6)], True)
for player in self.team.players:
self.team.players[player.id].position = Position(100 * player.id, 100 * player.id)
self.op_team = Team([Player(bot_id) for bot_id in range(6)], False)
for player in self.op_team.players:
self.op_team.players[player.id].position = Position(-100 * player.id - 100, -100 * player.id - 100)
self.field = Field(Ball())
self.field.ball.set_position(Position(1000, 0), 1)
self.info = InfoManager(self.field, self.team, self.op_team)
def test_construction(self):
self.assertNotEqual(self.tactic, None)
self.assertIsInstance(self.tactic, tFollowBall)
def test_name(self):
self.assertEqual(self.tactic.name, tFollowBall.__name__)
def test_if_ball_is_far(self):
result = self.tactic.apply(self.info, 0)
bot_pst = self.info.get_player_position(0)
ball_pst = self.info.get_ball_position()
self.assertIsNotNone(result)
self.assertIsInstance(result, dict)
self.assertEqual(result, {'skill': 'sGoToTarget', 'target': ball_pst, 'goal': bot_pst})
def test_if_ball_is_too_near(self):
# Changement de la position de la balle pour la mettre proche du robot 0
self.info.ball['position'] = Position(50, 50)
result = self.tactic.apply(self.info, 0)
bot_pst = self.info.get_player_position(0)
self.assertIsNotNone(result)
self.assertIsInstance(result, dict)
self.assertEqual(result, {'skill': 'sGoToTarget', 'target': bot_pst, 'goal': bot_pst})
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,336 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/tKickerTest.py | # Under MIT License, see LICENSE.txt
from ai.STP.Tactic.TacticBase import TacticBase
from ai.Util.geometry import distance
from RULEngine.Util.Position import Position
__author__ = 'RoboCupULaval'
class tKickerTest(TacticBase):
def __init__(self):
TacticBase.__init__(self, self.__class__.__name__)
def apply(self, info_manager, id_player):
bot_pst = info_manager.getPlayerPosition(id_player)
ball_pst = info_manager.getBallPosition()
if distance(Position(), ball_pst) < 500:
if distance(bot_pst, ball_pst) < 180:
return {'skill': 'sKickMedium', 'target': bot_pst, 'goal': bot_pst}
else:
return {'skill': 'sFollowTarget', 'target': ball_pst, 'goal': bot_pst}
else:
return {'skill': 'sFollowTarget', 'target': Position(1000, 0), 'goal': bot_pst}
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,337 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sWait.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sWait import sWait
__author__ = 'RoboCupULaval'
class TestSkillWait(TestCase):
""" Tests de la classe sWait """
def setUp(self):
self.skill = sWait()
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sWait)
def test_name(self):
self.assertEqual(self.skill.name, sWait.__name__)
def test_return(self):
result = self.skill.act(None, None, None)
self.assertIsNone(result)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,338 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/pQueueLeuLeu.py | #Under MIT License, see LICENSE.txt
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
SEQUENCE_QUEUELEULEU = ['tFollowBall', 'tFollowPrevFriend', 'tFollowPrevFriend',
'tFollowPrevFriend', 'tFollowPrevFriend', 'tFollowPrevFriend']
class pQueueLeuLeu(PlayBase):
"""
pQueueLeuLeu is a simple play where first follow ball and others follow previous friend id
"""
def __init__(self):
PlayBase.__init__(self, self.__class__.__name__)
self._sequence = [SEQUENCE_QUEUELEULEU]
def getTactics(self, index=None):
if index is None:
return self._sequence[0]
else:
return self._sequence[index]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,339 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/__init__.py | #Under MIT License, see LICENSE.txt
__author__ = 'RoboCupULaval'
import ai.STP.Skill.sKickHigh
import ai.STP.Skill.sKickLow
import ai.STP.Skill.sGoToTarget
import ai.STP.Skill.sGoBehindTargetGoal_GK
import ai.STP.Skill.sNull
import ai.STP.Skill.sPath
import ai.STP.Skill.sFollowTarget
import ai.STP.Skill.sKickHigh
import ai.STP.Skill.sKickMedium
import ai.STP.Skill.sKickLow
import ai.STP.Skill.sStop
import ai.STP.Skill.sWait
import ai.STP.Skill.sGeneratePath
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,340 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sStop.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class sStop(SkillBase):
"""
sStop immobilize bot with current position
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
return Pose(pose_player.position, pose_player.orientation)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,341 | YAZAH/StrategyIA | refs/heads/dev | /ai/Executor/SkillExecutor.py | #Under MIT License, see LICENSE.txt
# TODO: Execeptions personnalisees pour les edges cases (ex: current_skill == None)
from ai.Executor.Executor import Executor
__author__ = 'RoboCupULaval'
class SkillExecutor(Executor):
"""
SkillExecutor est une sequence de requetes qui choisie la prochaine
pose pour chaque joueur.
1 - Quelle est l'action du joueur?
2 - Quelle est la cible du joueur?
3 - Quel est le but du joueur ?
4 - Avoir l'objet action
5 - Generer la pose suivante
6 - Mettre en place la pose suivante
"""
def __init__(self, info_manager):
Executor.__init__(self, info_manager)
def exec(self):
# Execution pour chaque joueur
for id_player in range(self.info_manager.get_count_player()):
# 1 - Quelle est l'action du joueur ?
current_skill = self.info_manager.get_player_skill(id_player)
# 2 - Quelle est la cible du joueur ?
current_target = self.info_manager.get_player_target(id_player)
# 3 - Quel est le but du joueur ?
current_goal = self.info_manager.get_player_goal(id_player)
# 4 - Avoir l'objet action
skill = self.skill_book[current_skill]
current_pose = self.info_manager.get_player_pose(id_player)
# 5 - Generer la pose suivante
next_pose = skill().act(current_pose, current_target, current_goal)
# 6 - Mettre en place la pose suivante
if next_pose is not None:
self.info_manager.set_player_next_action(id_player, next_pose)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,342 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Play/test_pQueueLeuLeu.py | #Under MIT License, see LICENSE.txt
import unittest
from ai.STP.Play.pQueueLeuLeu import *
class TestPQueueLeuLeu(unittest.TestCase):
def setUp(self):
self.pTestQueueLeuLeu = pQueueLeuLeu()
def test_getTactics_with_no_args(self):
self.assertEqual(SEQUENCE_QUEUELEULEU, self.pTestQueueLeuLeu.getTactics())
def test_getTactics_with_index(self):
self.assertEqual(SEQUENCE_QUEUELEULEU, self.pTestQueueLeuLeu.getTactics(0))
def test_get_Tactics_with_invalid_index(self):
self.assertRaises(IndexError, self.pTestQueueLeuLeu.getTactics, 6)
if __name__ == '__main__':
unittest.main()
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,343 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/pPath.py | #Under MIT License, see LICENSE.txt
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
SEQUENCE_PATH = ['tNull', 'tNull', 'tNull',
'tNull', 'tPath', 'tNull']
class pPath(PlayBase):
"""
Default mode:
+ All bots stop their current action.
"""
def __init__(self):
PlayBase.__init__(self, self.__class__.__name__)
self._sequence = [SEQUENCE_PATH]
def getTactics(self, index=None):
if index is None:
return self._sequence[0]
else:
return self._sequence[index]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,344 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Skill/sGoToTarget.py | #Under MIT License, see LICENSE.txt
from ai.STP.Skill.SkillBase import SkillBase
from RULEngine.Util.Pose import Pose
__author__ = 'RoboCupULaval'
class sGoToTarget(SkillBase):
"""
sGoToTarget generate next pose which is target pose
"""
def __init__(self):
SkillBase.__init__(self, self.__class__.__name__)
def act(self, pose_player, pose_target, pose_goal):
return Pose(pose_target, pose_player.orientation)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,345 | YAZAH/StrategyIA | refs/heads/dev | /main.py | # Under MIT License, see LICENSE.txt
""" Point d'entrée de l'intelligence artificielle. """
from RULEngine.Framework import Framework
from UltimateStrategy import UltimateStrategy
__author__ = 'RoboCupULaval'
if __name__ == '__main__':
Framework().start_game(UltimateStrategy)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,346 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Skill/test_sNull.py | # Under MIT License, see LICENSE.txt
from unittest import TestCase
from ai.STP.Skill.sNull import sNull
from RULEngine.Util.Pose import Pose, Position
__author__ = 'RoboCupULaval'
class TestSkillNull(TestCase):
""" Tests de la classe sNull """
def setUp(self):
self.skill = sNull()
self.target = Pose(Position(0, 0), 0)
self.goal = Pose(Position(1, 1), 1)
self.bot_pos = Pose(Position(2, 2), 2)
def test_construction(self):
self.assertNotEqual(self.skill, None)
self.assertIsInstance(self.skill, sNull)
def test_name(self):
self.assertEqual(self.skill.name, sNull.__name__)
def test_return(self):
result = self.skill.act(self.bot_pos, self.target, self.goal)
self.assertIsNotNone(result)
self.assertIsInstance(result, Pose)
self.assertEqual(result.orientation, self.bot_pos.orientation)
self.assertEqual(result.position, self.bot_pos.position)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,347 | YAZAH/StrategyIA | refs/heads/dev | /tests/Executors/test_playExecutor.py | # Under MIT License, see LICENSE.txt
""" Module pour tester PlayExecutor """
from unittest import TestCase
from RULEngine.Game.Field import Field
from RULEngine.Game.Ball import Ball
from RULEngine.Game.Team import Team
from RULEngine.Game.Player import Player
from RULEngine.Util.Pose import Pose, Position
from ai.STP.Play.PlayBase import PlayBase
from ai.STP.Play.pHalt import pHalt
from ai.STP.Tactic.TacticBase import TacticBase
from ai.STP.Skill.SkillBase import SkillBase
from ai.InfoManager import InfoManager
__author__ = 'RoboCupULaval'
class TestPlayExecutor(TestCase):
""" Unit test pour PlayExecutor """
def setUp(self):
self.playbook = PlayBase()
self.tacticbook = TacticBase()
self.skillbook = SkillBase()
#Initialise InfoManager with teams, field, play, tactic and skill.
self.team = Team([Player(bot_id) for bot_id in range(6)], True)
for player in self.team.players:
self.team.players[player.id].position = Position(100 * player.id, 100 * player.id)
self.op_team = Team([Player(bot_id) for bot_id in range(6)], False)
for player in self.op_team.players:
player.position = Position(-100 * player.id - 100, -100 * player.id - 100)
#self.op_team.players[player.id].position = Position(-100 * player.id - 100, -100 * player.id - 100)
self.field = Field(Ball())
self.field.ball._position = Position(1000, 0)
self.info = InfoManager(self.field, self.team, self.op_team)
self.info.update()
#simulate the CoachExecutor
self.info.set_play('pHalt')
self.info.init_play_sequence()
def test_construction(self):
self.assertNotEqual(self.playbook, None)
self.assertNotEqual(self.tacticbook, None)
self.assertNotEqual(self.skillbook, None)
self.assertIsInstance(self.playbook, PlayBase)
self.assertIsInstance(self.tacticbook, TacticBase)
self.assertIsInstance(self.skillbook, SkillBase)
def test_exec(self):
# TODO: Trouver un moyen de simuler un Play dans un PlayBook
current_play = 'pHalt'
current_sequence = self.info.get_current_play_sequence()
self.assertIsNotNone(current_sequence)
self.assertTrue(current_sequence in range(self.info.get_count_player()))
#If this line work then the play is in the playbook
play = self.playbook.getBook()[current_play]
self.assertTrue(play == pHalt)
play = play()
#tNull is the tactic for every robot in the play pHalt
for i, tactic in enumerate(play.getTactics()):
self.info.set_player_tactic(i, tactic)
self.assertIs(self.info.get_player_tactic(i), 'tNull')
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,348 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Play/test_pDemoGoalKeeper.py | #Under MIT License, see LICENSE.txt
import unittest
from ai.STP.Play.pDemoGoalKeeper import *
from ai.STP.Play.pDemoGoalKeeper import pDemoGoalKeeper
class testPPathAxis(unittest.TestCase):
def setUp(self):
self.pDemoGoalKeeper = pDemoGoalKeeper()
def test_getTactics_with_no_args(self):
self.assertEqual(SEQUENCE_DEMO_GOAL_KEEPER, self.pDemoGoalKeeper.getTactics())
def test_getTactics_with_index(self):
self.assertEqual(SEQUENCE_DEMO_GOAL_KEEPER, self.pDemoGoalKeeper.getTactics(0))
def test_get_Tactics_with_invalid_index(self):
self.assertRaises(IndexError, self.pDemoGoalKeeper.getTactics, 6)
if __name__ == '__main__':
unittest.main()
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,349 | YAZAH/StrategyIA | refs/heads/dev | /tests/STP/Play/test_pTestBench.py | # Under MIT License, see LICENSE.txt
""" Module de test de pTestBench """
from nose.tools import assert_equal, assert_raises
from ai.STP.Play.pTestBench import pTestBench, SEQUENCE_TEST_BENCH
class TestTestBench:
""" Class test pTestBench """
@classmethod
def setup(cls):
cls.pTestBench = pTestBench()
def test_getTactics_with_no_args(self):
assert_equal(SEQUENCE_TEST_BENCH, self.pTestBench.getTactics())
def test_getTactics_with_index(self):
assert_equal(SEQUENCE_TEST_BENCH[0], self.pTestBench.getTactics(0))
def test_get_Tactics_with_invalid_index(self):
assert_raises(IndexError, self.pTestBench.getTactics, 6)
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,350 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Play/pHalt.py | # Under MIT License, see LICENSE.txt
""" Module contenant la stratégie pHalt. """
from ai.STP.Play.PlayBase import PlayBase
__author__ = 'RoboCupULaval'
SEQUENCE_HALT = ['tNull', 'tNull', 'tNull',
'tNull', 'tNull', 'tNull']
class pHalt(PlayBase):
""" Cette stratégie applique la Tactic tHalt à tous les robots.
Ils s'arrêtent complètement.
"""
def __init__(self):
PlayBase.__init__(self, self.__class__.__name__)
self._sequence = SEQUENCE_HALT
def getTactics(self, index=None):
if index is None:
return self._sequence
else:
return self._sequence[index]
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,351 | YAZAH/StrategyIA | refs/heads/dev | /ai/STP/Tactic/__init__.py | #Under MIT License, see LICENSE.txt
__author__ = 'RoboCupULaval'
import ai.STP.Tactic.tFollowBall
import ai.STP.Tactic.tFollowPrevFriend
import ai.STP.Tactic.tGoalKeeper
import ai.STP.Tactic.tNull
import ai.STP.Tactic.tPath
import ai.STP.Tactic.tKickerTest
import ai.STP.Tactic.tStop
import ai.STP.Tactic.tTestBench
import ai.STP.Tactic.tStop
| {"/tests/Executors/test_coachExecutor.py": ["/ai/Executor/CoachExecutor.py"], "/ai/STP/Skill/sNull.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoGoalKeeper.py": ["/ai/STP/Play/PlayBase.py"], "/UltimateStrategy.py": ["/ai/Executor/CoachExecutor.py", "/ai/Executor/PlayExecutor.py", "/ai/Executor/TacticExecutor.py", "/ai/Executor/SkillExecutor.py"], "/tests/Executors/test_pathfinderExecutor.py": ["/ai/Executor/PathfinderExecutor.py"], "/tests/STP/Play/test_playBase.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Play/pDefense.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/test_sFollowTarget.py": ["/ai/STP/Skill/sFollowTarget.py"], "/tests/STP/Skill/test_sGeneratePath.py": ["/ai/STP/Skill/sGeneratePath.py"], "/tests/STP/Tactic/test_tGoalKeeper.py": ["/ai/STP/Tactic/tGoalKeeper.py"], "/ai/Executor/TacticExecutor.py": ["/ai/Executor/Executor.py"], "/ai/STP/Skill/sKickLow.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sKickMedium.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sGeneratePath.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sFollowTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/PathfinderExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tPath.py": ["/ai/STP/Tactic/tPath.py"], "/tests/STP/Skill/test_sKickMedium.py": ["/ai/STP/Skill/sKickMedium.py"], "/tests/STP/Play/test_pHalt.py": ["/ai/STP/Play/pHalt.py"], "/ai/Executor/Executor.py": ["/ai/STP/Skill/SkillBase.py", "/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sWait.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/__init__.py": ["/ai/STP/Play/pDemoGoalKeeper.py", "/ai/STP/Play/pDemoFollowBall.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Play/pPath.py", "/ai/STP/Play/pQueueLeuLeu.py", "/ai/STP/Play/pTestBench.py"], "/tests/Executors/test_tacticExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pTestBench.py": ["/ai/STP/Play/PlayBase.py"], "/ai/Executor/PlayExecutor.py": ["/ai/Executor/Executor.py"], "/ai/Executor/CoachExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Tactic/test_tFollowPrevFriend.py": ["/ai/STP/Tactic/tFollowPrevFriend.py"], "/tests/STP/Skill/test_sGoToTarget.py": ["/ai/STP/Skill/sGoToTarget.py"], "/tests/STP/Skill/test_sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/sGoBehindTargetGoal_GK.py"], "/ai/STP/Skill/sKickHigh.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Play/pDemoFollowBall.py": ["/ai/STP/Play/PlayBase.py"], "/tests/STP/Skill/test_sStop.py": ["/ai/STP/Skill/sStop.py"], "/tests/STP/Play/test_pPath.py": ["/ai/STP/Play/pPath.py"], "/ai/STP/Skill/sGoBehindTargetGoal_GK.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/STP/Skill/sPath.py": ["/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoFollwBall.py": ["/ai/STP/Play/pDemoFollowBall.py"], "/tests/STP/Tactic/test_tFollowBall.py": ["/ai/STP/Tactic/tFollowBall.py"], "/tests/STP/Skill/test_sWait.py": ["/ai/STP/Skill/sWait.py"], "/ai/STP/Play/pQueueLeuLeu.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/__init__.py": ["/ai/STP/Skill/sKickHigh.py", "/ai/STP/Skill/sKickLow.py", "/ai/STP/Skill/sGoToTarget.py", "/ai/STP/Skill/sGoBehindTargetGoal_GK.py", "/ai/STP/Skill/sNull.py", "/ai/STP/Skill/sPath.py", "/ai/STP/Skill/sFollowTarget.py", "/ai/STP/Skill/sKickMedium.py", "/ai/STP/Skill/sStop.py", "/ai/STP/Skill/sWait.py", "/ai/STP/Skill/sGeneratePath.py"], "/ai/STP/Skill/sStop.py": ["/ai/STP/Skill/SkillBase.py"], "/ai/Executor/SkillExecutor.py": ["/ai/Executor/Executor.py"], "/tests/STP/Play/test_pQueueLeuLeu.py": ["/ai/STP/Play/pQueueLeuLeu.py"], "/ai/STP/Play/pPath.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Skill/sGoToTarget.py": ["/ai/STP/Skill/SkillBase.py"], "/main.py": ["/UltimateStrategy.py"], "/tests/STP/Skill/test_sNull.py": ["/ai/STP/Skill/sNull.py"], "/tests/Executors/test_playExecutor.py": ["/ai/STP/Play/PlayBase.py", "/ai/STP/Play/pHalt.py", "/ai/STP/Skill/SkillBase.py"], "/tests/STP/Play/test_pDemoGoalKeeper.py": ["/ai/STP/Play/pDemoGoalKeeper.py"], "/tests/STP/Play/test_pTestBench.py": ["/ai/STP/Play/pTestBench.py"], "/ai/STP/Play/pHalt.py": ["/ai/STP/Play/PlayBase.py"], "/ai/STP/Tactic/__init__.py": ["/ai/STP/Tactic/tFollowBall.py", "/ai/STP/Tactic/tFollowPrevFriend.py", "/ai/STP/Tactic/tGoalKeeper.py", "/ai/STP/Tactic/tPath.py", "/ai/STP/Tactic/tKickerTest.py", "/ai/STP/Tactic/tStop.py", "/ai/STP/Tactic/tTestBench.py"]} |
52,372 | reptileinx/backup_aws_resources | refs/heads/master | /test_copy_manual_failsafe_snapshot_standalone.py | import sure
from boto3 import client
from botocore.exceptions import ClientError
from mock import MagicMock
from moto import mock_rds2, mock_sns
import os
os.environ['FAILSAFE_ACCOUNT_ID'] = '23423525334242'
import rdscopysnapshots as copy_service
def test_get_snapshot_date_is_now_when_snapshot_is_not_available():
snapshot = MagicMock()
copy_service.datetime = MagicMock(return_value='2017, 10, 13, 13, 37, 33, 521429')
copy_service.get_snapshot_date(snapshot).should.equal(copy_service.datetime.now())
@mock_rds2
def test_get_snapshot_date_is_snapshot_creation_time_when_snapshot_is_available():
rds = client("rds", region_name="ap-southeast-2")
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_1',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
resp = rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-1',
DBInstanceIdentifier='failsafe_database_1')
copy_service.get_snapshot_date(resp['DBSnapshot']).should.equal(resp['DBSnapshot']['SnapshotCreateTime'])
@mock_rds2
def test_copy_manual_failsafe_snapshot_and_save():
rds = client("rds", region_name="ap-southeast-2")
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_1',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_2',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'false'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_3',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'NotFailsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-1', DBInstanceIdentifier='failsafe_database_1')
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-2', DBInstanceIdentifier='failsafe_database_2')
response = copy_service.get_snapshots(rds, 'failsafe_database_1', 'Manual')
response[0]["DBSnapshotIdentifier"].should.equal('failsafe-snapshot-1')
@mock_rds2
def test_create_failsafe_manual_snapshot_exists_if_snapshot_exists():
rds = client("rds", region_name="ap-southeast-2")
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_1',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_2',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'false'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_2',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'NotFailsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-1', DBInstanceIdentifier='failsafe_database_1')
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-2', DBInstanceIdentifier='failsafe_database_2')
rds.modify_db_snapshot_attribute = MagicMock()
copy_service.create_name_of_failsafe_snapshot = MagicMock(return_value='failsafe-snapshot-1')
copy_service.wait_until_failsafe_snapshot_is_available = MagicMock(return_value={'available=False'})
copy_service.get_name_of_newest_automated_snapshot = MagicMock(return_value='rds:snapshot-1')
rds.copy_db_snapshot = MagicMock(
return_value={'DBSnapshot': {'Timezone': 'string',
'DBSnapshotIdentifier': copy_service.create_name_of_failsafe_snapshot(
'rds:snapshot-1', 'failsafe-'),
'IAMDatabaseAuthenticationEnabled': True,
'DBSnapshotArn': 'string',
'DBInstanceIdentifier': 'failsafe_database_1'}})
copy_service.logger = MagicMock()
copy_service.create_failsafe_manual_snapshot.when.called_with(rds, 'failsafe_database_1').should.have.return_value(
'failsafe-snapshot-1')
copy_service.logger.warn.assert_called_with(
'Manual snapshot already exists for the automated snapshot rds:snapshot-1')
@mock_rds2
def test_create_failsafe_manual_snapshot_copies_automated_snapshot():
name_of_rds_automated_snapshot = 'rds:snapshot-3'
rds = client("rds", region_name="ap-southeast-2")
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_1',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_2',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'false'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_3',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'NotFailsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-1', DBInstanceIdentifier='failsafe_database_1')
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-2', DBInstanceIdentifier='failsafe_database_2')
copy_service.logger = MagicMock()
copy_service.create_name_of_failsafe_snapshot = MagicMock(return_value='failsafe-snapshot-3')
copy_service.wait_until_failsafe_snapshot_is_available = MagicMock(return_value={'available=True'})
copy_service.get_name_of_newest_automated_snapshot = MagicMock(return_value=name_of_rds_automated_snapshot)
rds.copy_db_snapshot = MagicMock(
return_value={'DBSnapshot': {'Timezone': 'string',
'DBSnapshotIdentifier': copy_service.create_name_of_failsafe_snapshot(
name_of_rds_automated_snapshot),
'IAMDatabaseAuthenticationEnabled': True,
'DBSnapshotArn': 'string',
'DBInstanceIdentifier': 'failsafe_database_1'}})
response = copy_service.create_failsafe_manual_snapshot(rds, 'failsafe_database_1')
response.should.be.true
copy_service.logger.info.assert_called_with('Snapshot rds:snapshot-3 copied to failsafe-snapshot-3')
@mock_rds2
def test_get_db_from_event():
response = copy_service.get_db_instances_from_notification(get_event())
response.should.contain('reptileinx-02-db')
@mock_rds2
def test_unrecoverable_exception_is_raised_when_delete_snapshot_fails_with_no_snapshot_to_delete():
copy_service.logger = MagicMock()
copy_service.handler.when.called_with(get_event(), None).should_not.throw(ClientError)
copy_service.logger.info.assert_called_with(
"Preparing deletion of previously created manual snapshots for DB instance - reptileinx-02-db")
@mock_rds2
def test_unrecoverable_exception_is_ignored_and_delete_continues():
rds = client("rds", region_name="ap-southeast-2")
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_1',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_2',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-2',
DBInstanceIdentifier='failsafe_database_2')
copy_service.logger = MagicMock()
copy_service.share_failsafe_snapshot = MagicMock()
copy_service.send_sns_to_failsafe_account = MagicMock()
copy_service.create_failsafe_manual_snapshot = MagicMock(return_value=True)
copy_service.handler.when.called_with(None, None).should.throw(TypeError)
@mock_sns
def test_get_subscription_sns_topic_arn_throws_error_when_sns_arn_not_found():
copy_service.logger = MagicMock()
sns = client('sns', region_name='ap-southeast-2')
sns.create_topic(Name='TopicName')
copy_service.get_subscription_sns_topic_arn()
copy_service.logger.error.assert_called_with(
'Initial setup required. Failsafe SNS topic reptileinx_save_failsafe_snapshot_sns_topic not found.')
@mock_sns
def test_send_sns_to_failsafe_account():
sns = client('sns', region_name='ap-southeast-2')
topic_arn = 'arn:aws:sns:ap-southeast-2:280000000083:SnsRdsSave'
sns.publish = MagicMock()
copy_service.get_subscription_sns_topic_arn = MagicMock(return_value=topic_arn)
copy_service.send_sns_to_failsafe_account = MagicMock()
copy_service.send_sns_to_failsafe_account. \
when.called_with('failsafe_database',
'failsafe-snapshot').should_not.throw(ClientError)
copy_service.send_sns_to_failsafe_account \
.when.called_with('failsafe_database',
'failsafe-snapshot').should_not.throw(copy_service.ClientException)
def create_name_of_failsafe_snapshot_returns_name_with_prefix():
copy_service.create_name_of_failsafe_snapshot = MagicMock()
copy_service.create_failsafe_manual_snapshot \
.when.called_with('rds:i_am_an_automated_snapshot',
'failsafe-').should.have.return_value('failsafe-i_am_an_automated_snapshot')
def test_event_guard():
copy_service.logger = MagicMock()
copy_service.event_guard(get_event())
copy_service.logger.info.assert_called_with('received event RDS-EVENT-0002 from RDS')
def get_event():
event = {
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:ap-southeast-2:129000003686:reptileinx_snapshot:183d5f808",
"EventSource": "aws:sns",
"Sns": {
"SignatureVersion": "1",
"Timestamp": "2017-11-26T16:09:22.468Z",
"Signature": "HK7LOsTVTwrNlObnsDUwp1/VuQWqPPdDJ/+knKv9OdfcouZwsx3GopiQ==",
"SigningCertUrl": "https://sns.ap-southeast-2.amazonaws.com/SimpleNotificationService-4330041.pem",
"MessageId": "545cb72c-c453-5b99-9219-e5b82d2152a4",
"Message": {
"Event Source": "db-instance",
"Event Time": "2017-11-26 16:05:27.306",
"Identifier Link": "https://console.aws.amazon.com/rds/home?reg-02-db",
"Source ID": "reptileinx-02-db",
"Event ID": "http://docs.amzonw.com/AmazRDS/latest/UserGuide/USER_Events.html#RDS-EVENT-0002",
"Event Message": "Backing up DB instance"
},
"MessageAttributes": {},
"Type": "Notification",
"TopicArn": "arn:aws:sns:ap-southeast-2:129000003686:reptileinx_copy_failsafe_snapshot_sns_topic",
"Subject": "RDS Notification Message"
}
}
]
}
return event
__all__ = ['sure'] # trick linting to consider python sure by exporting it
| {"/test_copy_manual_failsafe_snapshot_standalone.py": ["/rdscopysnapshots.py"], "/test_save_manual_failsafe_snapshot_standalone.py": ["/rdssavesnapshot.py"]} |
52,373 | reptileinx/backup_aws_resources | refs/heads/master | /test_save_manual_failsafe_snapshot_standalone.py | import datetime
import sure
from boto3 import client
from mock import MagicMock
from moto import mock_rds2
import rdssavesnapshot as save_service
@mock_rds2
def test_delete_snapshot_before_copying():
rds = client('rds', region_name='ap-southeast-2')
save_service.logger = MagicMock()
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_5',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-5', DBInstanceIdentifier='failsafe_database_5')
manual_snapshots = save_service.get_snapshots(rds, db_instance_id='failsafe_database_5', snapshot_type='manual')
save_service.local_snapshot_deletion_required('failsafe-snapshot-5', manual_snapshots)
save_service.logger. \
warn.assert_called_with('Local copy of failsafe-snapshot-5 already exists - deleting it before copying')
@mock_rds2
def test_local_snapshot_deletion_required():
rds = client('rds', region_name='ap-southeast-2')
save_service.logger = MagicMock()
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_5',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-5', DBInstanceIdentifier='failsafe_database_5')
manual_snapshots = save_service.get_snapshots(rds, db_instance_id='failsafe_database_5', snapshot_type='manual')
save_service.local_snapshot_deletion_required('failsafe-snapshot-52313', manual_snapshots).should_not.be.true
@mock_rds2
def test_evaluate_snapshot_age():
rds = client('rds', region_name='ap-southeast-2')
save_service.logger = MagicMock()
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_5',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-5', DBInstanceIdentifier='failsafe_database_5')
manual_snapshot = save_service.get_snapshots(rds, db_instance_id='failsafe_database_5', snapshot_type='manual')[0]
age = save_service.evaluate_snapshot_age(manual_snapshot)
age.days.should.be(-1)
@mock_rds2
def test_delete_expired_snapshots():
rds = client('rds', region_name='ap-southeast-2')
save_service.logger = MagicMock()
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_5',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-5', DBInstanceIdentifier='failsafe_database_5')
manual_snapshot = save_service.get_snapshots(rds, db_instance_id='failsafe_database_5', snapshot_type='manual')[0]
save_service.perform_delete = MagicMock()
save_service.delete_expired_snapshots(manual_snapshot, rds, datetime.timedelta(50))
save_service.perform_delete.assert_called()
@mock_rds2
def test_handler_prints_message_when_no_instance_with_tags_is_found():
event = MagicMock()
save_service.logger = MagicMock()
save_service.handler(event, None)
save_service.logger.info.assert_called_with('No instances tagged for RDS failsafe backup have been found...')
@mock_rds2
def test_save_logs_warning_when_no_snapshot_is_shared():
save_service.TESTING_HACK = True
event = setup_event()
save_service.get_snapshots = MagicMock(return_value=None)
save_service.delete_old_failsafe_manual_snapshots = MagicMock()
save_service.logger = MagicMock()
save_service.handler.when.called_with(event, None).should.have.raised(save_service.ClientException)
save_service.logger.warn.assert_called_with('No shared snapshots found.')
@mock_rds2
def test_error_is_logged_if_shared_snapshot_is_not_found():
rds = client('rds', region_name='ap-southeast-2')
instance = 'some_db'
failsafe_snapshot_id = 'some_snapshot_id'
save_service.get_snapshots = MagicMock()
save_service.logger = MagicMock()
save_service.copy_manual_failsafe_snapshot_and_save(rds, instance, failsafe_snapshot_id)
save_service.logger.error.assert_called_with(
'Shared snapshot with id ...:snapshot:{} failed to copy.'.format(failsafe_snapshot_id))
@mock_rds2
def test_copy_manual_failsafe_snapshot_and_save_no_shared_snapshot():
rds = client('rds', region_name='ap-southeast-2')
save_service.logger = MagicMock()
save_service.get_snapshots = MagicMock(return_value=None)
save_service.copy_manual_failsafe_snapshot_and_save \
.when.called_with(rds, 'instance', 'snapshot-1').should.have.raised(save_service.ClientException)
save_service.logger.warn.assert_called_with('No shared snapshots found.')
def get_response():
return [
{u'Engine': 'mysql', u'SnapshotCreateTime': (2017, 10, 6, 4, 0, 27, 727000,),
u'AvailabilityZone': 'ap-southeast-2a',
u'PercentProgress': 100, u'MasterUsername': 'admin', u'Encrypted': False,
u'LicenseModel': 'general-public-license', u'StorageType': 'gp2', u'Status': 'available',
u'VpcId': 'vpc-g4463543', u'DBSnapshotIdentifier': 'db-under-test-snaps',
u'InstanceCreateTime': (2017, 10, 5, 4, 45, 30, 702000,),
u'OptionGroupName': 'default:mysql-5-6', u'AllocatedStorage': 50, u'EngineVersion': '5.6.27',
u'SnapshotType': 'manual', u'IAMDatabaseAuthenticationEnabled': False, u'Port': 3306,
u'DBInstanceIdentifier': 'db-under-test'},
{u'MasterUsername': 'admin', u'LicenseModel': 'general-public-license',
u'InstanceCreateTime': (2017, 10, 5, 4, 45, 30, 702000,), u'Engine': 'mysql',
u'VpcId': 'vpc-g4463543', u'SourceRegion': 'ap-southeast-2', u'AllocatedStorage': 50, u'Status': 'available',
u'PercentProgress': 100,
u'DBSnapshotIdentifier': 'failsafe-db-under-test-snap',
u'EngineVersion': '5.6.27', u'OptionGroupName': 'default:mysql-5-6',
u'SnapshotCreateTime': (2017, 10, 8, 5, 14, 1, 181000,),
u'AvailabilityZone': 'ap-southeast-2a', u'StorageType': 'gp2', u'Encrypted': False,
u'IAMDatabaseAuthenticationEnabled': False, u'SnapshotType': 'manual', u'Port': 3306,
u'DBInstanceIdentifier': 'db-under-test'}]
def get_snapshots(*args, **kwargs):
if kwargs['db_instance_id'] is '':
return [
{
'DBSnapshotIdentifier': 'failsafe-db-under-test-snap',
'DBInstanceIdentifier': 'db-under-test'
}
]
return get_response()
@mock_rds2
def test_end_to_end_method_called_in_correct_order():
rds = client('rds', region_name='ap-southeast-2')
event = setup_event()
save_service.TESTING_HACK = True
save_service.delete_old_failsafe_manual_snapshots = MagicMock()
m = MagicMock()
save_service.get_snapshots = MagicMock(side_effect=get_snapshots)
shared_snapshots = m.get_snapshots(rds, db_instance_id='', snapshot_type='shared')
manual_snapshots = m.get_snapshots(rds, db_instance_id='failsafe_database_1', snapshot_type='shared')
save_service.re.search = MagicMock()
save_service.match_shared_snapshot_requiring_copy = MagicMock(return_value=True)
save_service.delete_duplicate_snapshots = MagicMock()
save_service.read_test_notification_payload = MagicMock()
save_service.copy_failsafe_snapshot = MagicMock()
save_service.read_notification_payload = MagicMock()
save_service.handler(event, None)
save_service.read_test_notification_payload.assert_called()
save_service.read_notification_payload.assert_not_called()
save_service.delete_duplicate_snapshots.assert_called_once()
save_service.copy_failsafe_snapshot.assert_called()
@mock_rds2
def test_get_snapshots_with_no_instance_name():
rds = client('rds', region_name='ap-southeast-2')
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_1',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-1', DBInstanceIdentifier='failsafe_database_1')
instance = ''
snapshot_type = 'manual'
list_of_snapshots = save_service.get_snapshots(rds, db_instance_id=instance, snapshot_type=snapshot_type)
type(list_of_snapshots).should.be(list)
list_of_snapshots.should.have.length_of(1)
@mock_rds2
def test_get_snapshots_with_instance_name():
rds = client('rds', region_name='ap-southeast-2')
rds.create_db_instance(DBInstanceIdentifier='failsafe_database_2',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-2', DBInstanceIdentifier='failsafe_database_2')
instance = 'failsafe_database_2'
snapshot_type = 'manual'
list_of_snapshots = save_service.get_snapshots(rds, db_instance_id=instance, snapshot_type=snapshot_type)
type(list_of_snapshots).should.be(list)
list_of_snapshots[0]['DBSnapshotIdentifier'].should_not.be.empty
def setup_event():
return {
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:EXAMPLE",
"EventSource": "aws:sns",
"Sns": {
"SignatureVersion": "1",
"Timestamp": "1970-01-01T00:00:00.000Z",
"Signature": "EXAMPLE",
"SigningCertUrl": "EXAMPLE",
"MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e",
"Message": {
"default": {
"Instance": "db-under-test",
"FailsafeSnapshotID": "failsafe-db-under-test-snap"}
},
"MessageAttributes": {
"Test": {
"Type": "String",
"Value": "TestString"
},
"TestBinary": {
"Type": "Binary",
"Value": "TestBinary"
}
},
"Type": "Notification",
"UnsubscribeUrl": "EXAMPLE",
"TopicArn": "arn:aws:sns:EXAMPLE",
"Subject": "TestInvoke"
}
}
]
}
__all__ = ['sure'] # trick linting to consider python sure by exporting it
| {"/test_copy_manual_failsafe_snapshot_standalone.py": ["/rdscopysnapshots.py"], "/test_save_manual_failsafe_snapshot_standalone.py": ["/rdssavesnapshot.py"]} |
52,374 | reptileinx/backup_aws_resources | refs/heads/master | /rdscopysnapshots.py | from __future__ import print_function
import json
import logging
import os
import re
import time
from datetime import datetime, timedelta, timezone
from boto3 import client
from botocore.exceptions import ClientError
"""
This Lambda function, when deployed using the AWS SAM template
'rds_copy_snap_template.yaml', will be part of the 'RDS Snapshot Copy Stack'.
When run with default AWS Lambda payload, this function will make a manual
copy of the most recent automated snapshot for one or more RDS instances.
It then shares the snapshot with a 'restricted' Failsafe account, sends an
SNS notification to the subscription Topic.
"""
FAILSAFE_SNAPSHOT_PREFIX = 'failsafe-'
SNS_RDS_SAVE_TOPIC = 'reptileinx_save_failsafe_snapshot_sns_topic'
AWS_DEFAULT_REGION = 'ap-southeast-2'
FAILSAFE_ACCOUNT_ID = os.getenv('FAILSAFE_ACCOUNT_ID', '2352525252332')
MANUAL_SNAPSHOT_EXISTS_MESSAGE = 'Manual snapshot already exists ' \
'for the automated snapshot {}'
def _get_aedt_timezone():
"""
utility method to set UTC timezone to Sydney - location of datacentre
:return:
AEDT timezone object
"""
UTCPLUSTEN = timedelta(hours=10)
return timezone(UTCPLUSTEN, 'AEDT')
logger = logging.getLogger()
logger.setLevel(logging.INFO)
class ClientException(Exception):
pass
def create_failsafe_manual_snapshot(rds, instance):
"""
Checks if the database instance has a recent automated snapshot created.
Creates a copy of the automated snapshot to a manual snapshot.
The manual snapshot is allocated a unique name.
The created manual snapshot is modified such that it can be shared with the
account passed in as ACCOUNT_TO_SHARE_WITH.
:param rds: instantiated boto3 object
:param instance: name of database instance from which to copy snapshot
:return:
- None: if a copy of the automated snapshot has been created already
- Snapshot: dictionary payload of the snapshot successfully copied
"""
logger.info('Creating manual copy of the most recent automated '
'snapshot of database instance - {}'.format(instance))
name_of_newest_automated_snapshot = \
get_name_of_newest_automated_snapshot(instance, rds)
name_of_created_failsafe_snapshot = \
create_name_of_failsafe_snapshot(
name_of_newest_automated_snapshot,
FAILSAFE_SNAPSHOT_PREFIX)
manual_snapshots = get_snapshots(rds, instance, 'manual')
for manual_snapshot in manual_snapshots:
if manual_snapshot['DBSnapshotIdentifier'] == \
name_of_created_failsafe_snapshot:
logger.warn(MANUAL_SNAPSHOT_EXISTS_MESSAGE.format(
name_of_newest_automated_snapshot))
return name_of_created_failsafe_snapshot
else:
return perform_copy_automated_snapshot(
instance,
name_of_created_failsafe_snapshot,
name_of_newest_automated_snapshot, rds)
def perform_copy_automated_snapshot(
instance, name_of_created_failsafe_snapshot,
name_of_newest_automated_snapshot,
rds):
"""
Where the actual copying of the automated snapshot actually happens.
If the copy successfully completes the automated_snapshot_copied flag is
update and sent to the main function for further use. The function was
mainly pulled out to help with testing the unimplemented method
rds.copy_db_snapshot in moto. Otherwise errors are bubbled up to be
handled by a generic try catch all. AWS will record any logs.
:param instance: DB instance of automated snapshot that is being copied
:param name_of_created_failsafe_snapshot: the resulting name of the
failsafe manual snapshot
:param name_of_newest_automated_snapshot: the name of the newest automated
snapshot being copied
:param rds: the Boto3 client with the help of which we interrogate
AWS RDS services
:return: Name of Failsafe snapshot or empty string
"""
if name_of_newest_automated_snapshot:
response = rds.copy_db_snapshot(
SourceDBSnapshotIdentifier=name_of_newest_automated_snapshot,
TargetDBSnapshotIdentifier=name_of_created_failsafe_snapshot
)
wait_until_failsafe_snapshot_is_available(
rds,
instance, name_of_created_failsafe_snapshot)
logger.info('Snapshot {} copied to {}'.format(
name_of_newest_automated_snapshot,
name_of_created_failsafe_snapshot))
return response.get('DBSnapshot', {}).get('DBSnapshotIdentifier', '')
def create_name_of_failsafe_snapshot(name_of_newest_automated_snapshot,
failsafe_snapshot_name_prefix):
name_of_created_failsafe_snapshot = \
failsafe_snapshot_name_prefix + name_of_newest_automated_snapshot[4:]
return name_of_created_failsafe_snapshot
def get_name_of_newest_automated_snapshot(instance, rds):
automated_snapshots = get_snapshots(rds, instance, 'automated')
newest_automated_snapshot = automated_snapshots[-1]
name_of_newest_automated_snapshot = \
newest_automated_snapshot['DBSnapshotIdentifier']
return name_of_newest_automated_snapshot
def send_sns_to_failsafe_account(instance, name_of_created_failsafe_snapshot):
"""
Sends an SNS notification to the subscribed Lambda function.
The notification contains the Failsafe snapshot payload:
{
'Instance': instance,
'FailsafeSnapshotID': name_of_created_failsafe_snapshot
}
:param instance: DB instance of automated snapshot that is being copied
:param name_of_created_failsafe_snapshot:
name of Failsafe Snapshot to be shared
:return: None
"""
failsafe_sns_save_topic_arn = get_subscription_sns_topic_arn()
if failsafe_sns_save_topic_arn:
logger.info('Sending SNS alert to failsafe topic - {}'
.format(failsafe_sns_save_topic_arn))
failsafe_notification_payload = {
'Instance': instance,
'FailsafeSnapshotID': name_of_created_failsafe_snapshot}
logger.warn('message sent: {}'.format(failsafe_notification_payload))
sns = client('sns', region_name=AWS_DEFAULT_REGION)
sns.publish(
TargetArn=failsafe_sns_save_topic_arn,
Message=json.dumps({'default': json.dumps(
failsafe_notification_payload)}),
MessageStructure='json')
def share_failsafe_snapshot(rds, name_of_failsafe_snapshot):
"""
Shares the Failsafe snapshot with the Backup account
:param rds: the Boto3 client using which we interrogate AWS RDS services
:param name_of_failsafe_snapshot: name of Failsafe Snapshot to be shared
:return: None
"""
if FAILSAFE_ACCOUNT_ID:
logger.info(
'Sharing snapshot... {} to account ... {} '
.format(name_of_failsafe_snapshot, FAILSAFE_ACCOUNT_ID))
logger.warn('Security Notice: DB Snapshot {0}'
'will remain shared to {1} until when snapshot is deleted'
.format(name_of_failsafe_snapshot, FAILSAFE_ACCOUNT_ID))
rds.modify_db_snapshot_attribute(
DBSnapshotIdentifier=name_of_failsafe_snapshot,
AttributeName='restore',
ValuesToAdd=[
FAILSAFE_ACCOUNT_ID
]
)
def wait_until_failsafe_snapshot_is_available(rds,
instance,
failsafe_snapshot):
"""
A function that allows the lambda function to wait for long running events
to complete. This allows us to have more control on the overall workflow of
RDS Snapshot Backups
:param rds: the Boto3 client used to interrogate AWS RDS services
:param instance: name of database instance to copy snapshot from
:param failsafe_snapshot: name of the Failsafe snapshot being created
:return: None
"""
logger.info('Waiting for copy of {} to complete.'
.format(failsafe_snapshot))
available = False
while not available:
time.sleep(10)
manual_snapshots = get_snapshots(rds, instance, 'manual')
for manual_snapshot in manual_snapshots:
if manual_snapshot['DBSnapshotIdentifier'] == failsafe_snapshot:
logger.info('{}: {}...'
.format(manual_snapshot['DBSnapshotIdentifier'],
manual_snapshot['Status']))
if manual_snapshot['Status'] == 'available':
available = True
break
def delete_old_failsafe_manual_snapshots(rds, instance):
"""
Deletes any previously created failsafe manual snapshots. Failsafe manual
snapshot here being a copy of the automated snapshot that has been shared
with the Failsafe account. This is a security feature to ensure
snapshots are not shared for periods more than 48 hours.
:param rds: the Boto3 client used to interrogate AWS RDS services
:param instance: name of database instance to copy snapshot from
:return: None
"""
logger.info('Preparing deletion of previously created manual snapshots'
'for DB instance - {}'.format(instance))
manual_snapshots = get_snapshots(rds, instance, 'manual')
for manual_snapshot in manual_snapshots:
snapshot_id_prefix_is_not_failsafe = \
manual_snapshot['DBSnapshotIdentifier'][:9] != 'failsafe-'
if snapshot_id_prefix_is_not_failsafe:
logger.info('Ignoring manual snapshot {}'
.format(manual_snapshot['DBSnapshotIdentifier']))
continue
logger.info('Deleting previously created manual snapshot - {}'
.format(manual_snapshot['DBSnapshotIdentifier']))
rds.delete_db_snapshot(
DBSnapshotIdentifier=manual_snapshot['DBSnapshotIdentifier'])
def get_snapshot_date(snapshot):
"""
This is a helper function to ascertain snapshot has completed creating.
When SnapshotCreateTime is present then the snapshot has finished creating
:param snapshot: snapshot being created
:return: datetime value of when snapshot was created
"""
return datetime.now(_get_aedt_timezone()) \
if snapshot['Status'] != 'available' \
else snapshot['SnapshotCreateTime']
def get_snapshots(rds, instance, snapshot_type):
"""
Gets a sorted list automated or manual snapshots depepnding on the
snapshot_type value
:param rds: the Boto3 client used to interrogate AWS RDS services
:param instance: the specific instance to get snapshots from
:param snapshot_type: can be 'automated' or 'manual'
:return: sorted list of snapshots
"""
# TODO: refactor call this api once
if instance:
snapshots = rds.describe_db_snapshots(
SnapshotType=snapshot_type,
DBInstanceIdentifier=instance,
IncludeShared=True)['DBSnapshots']
else:
snapshots = rds.describe_db_snapshots(
SnapshotType=snapshot_type,
IncludeShared=True)['DBSnapshots']
if snapshots is not None:
sorted_snapshots = sorted(snapshots, key=get_snapshot_date)
return sorted_snapshots
def get_subscription_sns_topic_arn():
"""
Helper function to get the SNS Topic arn.
:return: sns topic arn
"""
sns = client('sns', region_name=AWS_DEFAULT_REGION)
sns_topic_list = sns.list_topics().get('Topics', [])
for sns_topic in sns_topic_list:
if not re.search(SNS_RDS_SAVE_TOPIC, sns_topic['TopicArn']):
continue
else:
failsafe_sns_topic_arn = sns_topic['TopicArn']
logger.info('Setting failsafe topic arn to - {}'
.format(failsafe_sns_topic_arn))
return failsafe_sns_topic_arn
logger.error('Initial setup required. Failsafe SNS topic {} not found.'
.format(SNS_RDS_SAVE_TOPIC))
def event_guard(event):
for record in event['Records']:
if record['EventSource'] == 'aws:sns' and record['Sns']['Message']:
event_id_raw = json.loads(
json.dumps(record['Sns']['Message']))['Event ID']
event_id = re.findall(r'#(.*)', event_id_raw)[0].encode('ascii')
logger.info('received event {} from RDS'.format(event_id))
if event_id != 'RDS-EVENT-0002':
raise ClientException('received an event'
' not suitable for backup...')
def run_rds_snapshot_backup(instance):
"""
The function that AWS Lambda service invokes when executing the code in
this module.
:param instance: instance that triggered the Copy SNS Topic
:return: true if an automated snapshot was copied, shared and a
notification was sent to an SNS Topic
"""
if instance:
try:
rds = client('rds', region_name=AWS_DEFAULT_REGION)
delete_old_failsafe_manual_snapshots(rds, instance)
name_of_created_failsafe_snapshot = \
create_failsafe_manual_snapshot(rds, instance)
if name_of_created_failsafe_snapshot:
share_failsafe_snapshot(rds, name_of_created_failsafe_snapshot)
send_sns_to_failsafe_account(instance,
name_of_created_failsafe_snapshot)
except ClientError as e:
logger.error(str(e))
else:
raise ClientException('No instances tagged for RDS failsafe'
'backup have been found...')
def get_db_instances_from_notification(event):
for record in event['Records']:
db_instance = \
json.loads(json.dumps(record['Sns']['Message']))['Source ID']
return db_instance
def handler(event, context):
"""
The function that AWS Lambda service invokes when executing the code.
:param event: used to to pass in event data to the handler.
An RDS notification will trigger this process
:param context: we are not providing any runtime information to the handler
:return: true if an automated snapshot was copied, shared and a
notification was sent to an SNS Topic
"""
event_guard(event)
db_instance = get_db_instances_from_notification(event)
run_rds_snapshot_backup(db_instance)
if __name__ == "__main__":
event = []
context = []
handler(event, context)
| {"/test_copy_manual_failsafe_snapshot_standalone.py": ["/rdscopysnapshots.py"], "/test_save_manual_failsafe_snapshot_standalone.py": ["/rdssavesnapshot.py"]} |
52,375 | reptileinx/backup_aws_resources | refs/heads/master | /test_rdscopysnapshots.py | from datetime import tzinfo, timedelta, datetime
import pytest
import sure
from boto3 import client
import rdscopysnapshots as automated_snapshot_processor
REGION = 'ap-southeast-2'
INSTANCES = ["devarch-db"]
# Handle timezones correctly
ZERO = timedelta(0)
class UTC(tzinfo):
def utcoffset(self, dt):
return ZERO
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return ZERO
utc = UTC()
rds = client("rds", region_name='ap-southeast-2', endpoint_url='http://localhost:5000')
def setup_module():
instance_1 = rds.create_db_instance(DBInstanceIdentifier='devarch-db',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
DBSecurityGroups=["my_sg"])
instance_2 = rds.create_db_instance(DBInstanceIdentifier='second_database',
AllocatedStorage=10,
Engine='mysql',
DBName='staging-mysql',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
DBSecurityGroups=["my_sg"])
instance_3 = rds.create_db_instance(DBInstanceIdentifier='third_database',
AllocatedStorage=10,
Engine='mysql',
DBName='staging-mysql',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
DBSecurityGroups=["my_sg"])
instance_4 = rds.create_db_instance(DBInstanceIdentifier='forth_database',
AllocatedStorage=10,
Engine='mysql',
DBName='staging-mysql',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
Tags=[
{
'Key': 'Failsafe',
'Value': 'false'
},
],
DBSecurityGroups=["my_sg"])
failsafe_database_1 = rds.create_db_instance(DBInstanceIdentifier='failsafe_database_2',
AllocatedStorage=10,
Engine='mysql',
DBName='staging-mysql',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
failsafe_database_2 = rds.create_db_instance(DBInstanceIdentifier='failsafe_database',
AllocatedStorage=10,
Engine='postgres',
DBName='staging-postgres',
DBInstanceClass='db.m1.small',
LicenseModel='license-included',
MasterUsername='root_failsafe',
MasterUserPassword='hunter_failsafe',
Port=3000,
Tags=[
{
'Key': 'Failsafe',
'Value': 'true'
},
],
DBSecurityGroups=["my_sg"])
databases_created = [instance_1, instance_2, instance_3, instance_4, failsafe_database_1, failsafe_database_2]
for db in databases_created:
print db
rds.create_db_snapshot(DBSnapshotIdentifier='failsafe-snapshot-1', DBInstanceIdentifier='failsafe_database')
rds.create_db_snapshot(DBSnapshotIdentifier='snapshot-2', DBInstanceIdentifier='failsafe_database')
rds.create_db_snapshot(DBSnapshotIdentifier='snapshot-3', DBInstanceIdentifier='failsafe_database')
rds.create_db_snapshot(DBSnapshotIdentifier='snapshot-4', DBInstanceIdentifier='failsafe_database')
rds.create_db_snapshot(DBSnapshotIdentifier='snapshot-5', DBInstanceIdentifier='failsafe_database')
rds.create_db_snapshot(DBSnapshotIdentifier='snapshot-6', DBInstanceIdentifier='failsafe_database')
def test_rds_get_db_instances_with_failsafe_tag_true():
db_instance_list = []
instances = automated_snapshot_processor.get_db_instances_by_tags(rds, db_instance_list)
print instances
instances[0].should.be.equal('failsafe_database_2')
instances[1].should.be.equal('failsafe_database')
def test_get_sorted_list_of_snapshots():
sorted_snapshots_list = automated_snapshot_processor.get_snapshots(rds, 'failsafe_database', 'manual')
for snapshot in sorted_snapshots_list:
print snapshot['DBSnapshotIdentifier']
sorted_snapshots_list[0]['DBSnapshotIdentifier'].should.be.equal('failsafe-snapshot-1')
# TODO: find out why only one RDS Snapshot is returned. For delete snapshot all the snapshots are deleted
# TODO: Do not know how to test for automated snapshots
@pytest.mark.skip(reason="no way of currently testing this")
def test_create_failsafe_manual_snapshot():
response = automated_snapshot_processor.create_failsafe_manual_snapshot(rds, 'failsafe_database')
print response
pass
def test_get_snapshot_date():
snp = rds.describe_db_snapshots()['DBSnapshots'][0]
# for s in snp['DBSnapshots']['DBSnapshotIdentifier']:
# print snp
resp = automated_snapshot_processor.get_snapshot_date(snp)
print type(resp)
isinstance(resp, datetime).should.be.true
def teardown_module():
print "teardown_module"
try:
list_of_databases = rds.describe_db_instances()['DBInstances']
for instance_payload in list_of_databases:
db_instance = instance_payload['DBInstanceIdentifier']
print("deleting database named ...{0}".format(db_instance))
response = rds.delete_db_instance(
DBInstanceIdentifier=db_instance,
SkipFinalSnapshot=False)
list_of_snapshots = rds.describe_db_snapshots()['DBSnapshots']
for snapshots_payload in list_of_snapshots:
snapshot_instance = snapshots_payload['DBSnapshotIdentifier']
print("deleting snapshot named ...{0}".format(snapshot_instance))
response = rds.delete_db_snapshot(DBSnapshotIdentifier=snapshot_instance)
print response
except Exception as error:
print error
__all__ = ['sure'] # trick linting to consider python sure by exporting it
| {"/test_copy_manual_failsafe_snapshot_standalone.py": ["/rdscopysnapshots.py"], "/test_save_manual_failsafe_snapshot_standalone.py": ["/rdssavesnapshot.py"]} |
52,376 | reptileinx/backup_aws_resources | refs/heads/master | /rdssavesnapshot.py | """
A Lambda saves the most recently shared failsafe RDS manual snapshot to the
Failsafe account. The RDS Instance should be tagged with 'Failsafe=true'
to get its snapshots backed up. The Lambda will be extended to send a
success message to a slack channel in future. Use the AWS SAM Templates
(rds_save_snap_template) provided to deploy this function. This function
depends on the Resources created by the rds_copy_snap_template
FAILSAFE_TAG: this tag has to put on the target DB for its snapshots
to be backed up to the Failsafe Account
"""
from __future__ import print_function
import json
import logging
import re
import time
from datetime import tzinfo, timedelta, datetime
from boto3 import client
from botocore.exceptions import ClientError
SERVICE_CONNECTION_DEFAULT_REGION = "ap-southeast-2"
FAILSAFE_TAG = 'failsafe'
SNAPSHOT_RETENTION_PERIOD_IN_DAYS = 31
ZERO = timedelta(0) # Handle timezones correctly
TESTING_HACK = False
logger = logging.getLogger()
logger.setLevel(logging.INFO)
class ClientException(Exception):
pass
class UTC(tzinfo):
"""
To help with formatting date/time
"""
def utcoffset(self, dt):
return ZERO
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return ZERO
utc = UTC()
def terminate_copy_manual_failsafe_snapshot():
logger.warn('No shared snapshots found.')
raise ClientException('No shared snapshots found.')
def copy_manual_failsafe_snapshot_and_save(rds,
instance,
failsafe_snapshot_id):
"""
Function discovers the shared snapshot and copies it to the failsafe
snasphot
:param rds: the Boto3 client which use to interrogate AWS RDS services
:param instance: rds db snapshot we save to the failsafe account
:param failsafe_snapshot_id: the identifier of the
failsafe snapshot to be created
:return:
"""
logger.info('Making local copy of {} in Failsafe account'
.format(failsafe_snapshot_id))
manual_snapshots = get_snapshots(rds,
db_instance_id=instance,
snapshot_type='manual')
shared_snapshots = get_snapshots(rds,
db_instance_id='',
snapshot_type='shared')
if not shared_snapshots:
terminate_copy_manual_failsafe_snapshot()
shared_snapshot_id = ''.join(
[shared_snapshot['DBSnapshotIdentifier']
for shared_snapshot in shared_snapshots
for shared_snapshot_arn in [re.search(
failsafe_snapshot_id,
shared_snapshot['DBSnapshotIdentifier'])]
if shared_snapshot_arn])
snapshot_copied = [
data_of_copied_snapshot(failsafe_snapshot_id,
instance,
manual_snapshots,
rds,
shared_snapshot_id)
if match_shared_snapshot_requiring_copy(failsafe_snapshot_id,
shared_snapshot_id) else None]
if not snapshot_copied.pop():
logger.error('Shared snapshot with id ...:snapshot:{} failed to copy.'
.format(failsafe_snapshot_id))
def data_of_copied_snapshot(failsafe_snapshot_id,
instance,
manual_snapshots,
rds,
shared_snapshot_id):
logger.info('Failsafe Snapshot {} matched successfully'
.format(shared_snapshot_id))
delete_duplicate_snapshots(failsafe_snapshot_id,
manual_snapshots, rds)
snapshot_copied = copy_failsafe_snapshot(failsafe_snapshot_id,
instance,
rds,
shared_snapshot_id)
return snapshot_copied
def copy_failsafe_snapshot(failsafe_snapshot_id,
instance,
rds,
shared_snapshot_id):
"""
Performs copy of the shared manual snapshot to the failsafe manual
snapshot and saves it
:param failsafe_snapshot_id: the identifier of the failsafe snapshot
provided
:param instance: the instance of the database whose snapshot will
be backed-up
:param rds: the Boto3 client with the help of which we interrogate
AWS RDS services
:param shared_snapshot_id: the identifier of the snapshot being copied
:return: payload of the copied snapshot
"""
response = rds.copy_db_snapshot(
SourceDBSnapshotIdentifier=shared_snapshot_id,
TargetDBSnapshotIdentifier=failsafe_snapshot_id
)
wait_until_snapshot_is_available(rds, instance, failsafe_snapshot_id)
logger.info("Snapshot {} copied to {}"
.format(shared_snapshot_id, failsafe_snapshot_id))
return response
def delete_duplicate_snapshots(failsafe_snapshot_id, manual_snapshots, rds):
"""
Helper function to delete snapshots whose creation is being repeated.
The failsafe snapshot already exists but the rdssavesnapshot lambda
has been invoked
:param failsafe_snapshot_id:
:param manual_snapshots:
:param rds: the Boto3 client with the help of which we interrogate
AWS RDS services
:return:
"""
logger.warn("Initiating duplicate snapshot cleanup...")
if local_snapshot_deletion_required(failsafe_snapshot_id,
manual_snapshots):
perform_delete(failsafe_snapshot_id, rds)
logger.info("Duplicate snapshot cleanup successfully complete")
return
def perform_delete(failsafe_snapshot_id, rds):
rds.delete_db_snapshot(
DBSnapshotIdentifier=failsafe_snapshot_id
)
def match_shared_snapshot_requiring_copy(failsafe_snapshot_id,
shared_snapshot_identifier):
"""
Helper function to find which shared snapshot requires copying using
a string matcher
:param failsafe_snapshot_id: Failsafe snapshot id from the SNS event
:param shared_snapshot_identifier: Shared snapshot id being matched for
copy in failsafe account
:return: a match object with boolean value of True if there is a match,
and None if not.
"""
logger.info("Checking if snapshot {} requires copying"
.format(shared_snapshot_identifier))
regexp = r".*\:{}".format(re.escape(failsafe_snapshot_id))
return re.match(regexp, shared_snapshot_identifier)
def local_snapshot_deletion_required(failsafe_snapshot_id, manual_snapshots):
"""
Helper function that runs before every copy snapshot invocation.
This function will delete any previously created
failsafe snapshot and create a new one in its place.
:param failsafe_snapshot_id: Failsafe snapshot ID that will be created
:param manual_snapshots: Shared manual snapshot requiring backup to
failsafe account
:return:
"""
failsafe_snapshot_id_exists = [manual_snapshot
for manual_snapshot in manual_snapshots if
manual_snapshot['DBSnapshotIdentifier'] ==
failsafe_snapshot_id]
if not failsafe_snapshot_id_exists:
return False
if failsafe_snapshot_id_exists.pop():
logger.warn(
'Local copy of {} already exists - deleting it before copying'
.format(manual_snapshot['DBSnapshotIdentifier']))
return True
def wait_until_snapshot_is_available(rds, instance, snapshot):
"""
A function that allows the lambda function to wait for long running events
to complete. This allows us to have more control on the overall workflow of
RDS Snapshot Backups
:param rds: the Boto3 client used to interrogate AWS RDS services
:param instance: name of database instance to copy snapshot from
:param snapshot: name of the Failsafe snapshot being created
:return: None
"""
logger.info("Waiting for copy of {} to complete.".format(snapshot))
available = False
while not available:
time.sleep(10)
manual_snapshots = get_snapshots(rds,
db_instance_id=instance,
snapshot_type='manual')
for manual_snapshot in manual_snapshots:
if manual_snapshot['DBSnapshotIdentifier'] == snapshot:
logger.info("{}: {}..."
.format(manual_snapshot['DBSnapshotIdentifier'],
manual_snapshot['Status']))
if manual_snapshot['Status'] == "available":
available = True
break
def delete_old_failsafe_manual_snapshots(rds, instance):
"""
Deletes expired snapshots in accordance with the retention policy
:param rds: the Boto3 client used interrogate AWS RDS services
:param instance:
:return:
"""
logger.info("Checking if instance {} has expired snapshots "
.format(instance))
logger.warn("Manual snapshots older than {} days will be deleted."
.format(SNAPSHOT_RETENTION_PERIOD_IN_DAYS))
manual_snapshots = get_snapshots(rds,
db_instance_id=instance,
snapshot_type='manual')
for manual_snapshot in manual_snapshots:
if manual_snapshot['Status'] != "available":
continue
snapshot_age = evaluate_snapshot_age(manual_snapshot)
delete_expired_snapshots(manual_snapshot, rds, snapshot_age)
def delete_expired_snapshots(manual_snapshot, rds, snapshot_age):
"""
Helper function that deletes expired failsafe snapshots in accordance with
the retention policy
:param manual_snapshot: expired snapshots to be deleted
:param rds: the Boto3 client used to interrogate AWS RDS services
:param snapshot_age: evaluated age of the failsafe manual snapshot
:return:
"""
if snapshot_age.days >= SNAPSHOT_RETENTION_PERIOD_IN_DAYS:
logger.warn("Deleting: {}"
.format(manual_snapshot['DBSnapshotIdentifier']))
perform_delete(manual_snapshot['DBSnapshotIdentifier'], rds)
else:
logger.info("Not deleting snapshot - {} (it is only {} days old)"
.format(manual_snapshot['DBSnapshotIdentifier'],
snapshot_age.days))
def evaluate_snapshot_age(manual_snapshot):
"""
Helper function to get age of snapshot as per current date
:param manual_snapshot: manual snapshot in failsafe account
:return: snapshot age
"""
snapshot_date = manual_snapshot['SnapshotCreateTime']
current_date = datetime.now(utc)
snapshot_age = current_date - snapshot_date
return snapshot_age
def get_snapshot_date(snapshot):
"""
This is a helper function to ascertain snapshot has completed creating.
When SnapshotCreateTime is present then the snapshot has finished creating
:param snapshot: snapshot being created
:return: datetime value of when snapshot was created
"""
return datetime.now(utc) if snapshot['Status'] != 'available' \
else snapshot['SnapshotCreateTime']
def get_snapshots(rds, **options):
"""
This function performs an aws api call to get the snapshots depending on
the arguments passed
:param rds: the Boto3 client used to interrogate AWS RDS services
:param options:
db_instance_id: the specific instance to get snapshots from
snapshot_type: can be 'manual' or 'shared' snapshot type
:return: list of snapshots
"""
instance = options.get('db_instance_id', '')
snapshot_type = options.get('snapshot_type', '')
return get_snapshots_by_filters(rds,
db_instance_id=instance,
snapshot_type=snapshot_type)
def get_snapshots_by_filters(rds, **options):
snapshots = rds.describe_db_snapshots(
SnapshotType=options.get('snapshot_type', ''),
DBInstanceIdentifier=options.get('db_instance_id', ''),
IncludeShared=True)['DBSnapshots']
return sorted(snapshots, key=get_snapshot_date) if snapshots is not None \
else None
def read_notification_payload(record, attribute):
"""
Helper function to read the event payload passed through by sns
:param record: snapshot object message
:param attribute: the attribute being read and returned
:return: returns instance or snapshot-id depending on attribute
"""
message = json.loads(record['Sns']['Message'])
return message[attribute]
def read_test_notification_payload(record, attribute):
"""
Helper function to read the event payload passed through by test functions
:param record: snapshot object message
:param attribute: the attribute being read and returned
:return: returns instance or snapshot-id depending on attribute
"""
return json.loads(json.dumps(record['Sns']
['Message']))['default'][attribute]
def handler(event, context):
"""
The function that AWS Lambda service invokes when executing the code.
:param event: used to to pass in event data to the handler.
The payload sent from the rdscopysnapshot function looks like:
{
'Instance': instance,
'FailsafeSnapshotID': name_of_created_failsafe_snapshot
}
:param context: provides runtime information to the handler if required
:return:
"""
rds = client('rds', region_name=SERVICE_CONNECTION_DEFAULT_REGION)
for record in event['Records']:
if record['EventSource'] == 'aws:sns' and record['Sns']['Message']:
if TESTING_HACK:
instance = read_test_notification_payload(record, 'Instance')
snapshot_id = read_test_notification_payload(
record,
'FailsafeSnapshotID')
else:
instance = read_notification_payload(record, 'Instance')
snapshot_id = read_notification_payload(record,
'FailsafeSnapshotID')
logger.info('Retrieved Instance: {0} '
'and FailsafeSnapshotID: {1}'
.format(instance, snapshot_id))
try:
copy_manual_failsafe_snapshot_and_save(rds, instance, snapshot_id)
delete_old_failsafe_manual_snapshots(rds, instance)
except ClientError as e:
logger.error(str(e))
else:
logger.info('No instances tagged for RDS failsafe backup found...')
| {"/test_copy_manual_failsafe_snapshot_standalone.py": ["/rdscopysnapshots.py"], "/test_save_manual_failsafe_snapshot_standalone.py": ["/rdssavesnapshot.py"]} |
52,388 | anevolina/GoogleCalendarBot | refs/heads/master | /tg_bot/add_event_bot.py | """Main module to start telegram bot - it connects all functions to telegram API"""
import os
from dotenv import load_dotenv
from os.path import join, dirname
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import tg_bot.GC_TelegramBot as GC_TelegramBot
# Load .env & token for the bot
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
TLGR_TOKEN = os.environ.get('TLGR_TOKEN')
# Initialize updater and dispatcher
updater = Updater(token=TLGR_TOKEN)
dispatcher = updater.dispatcher
# define command handlers
bind_calendar_handler = CommandHandler('bind', GC_TelegramBot.add_calendar_callback)
cancel_handler = CommandHandler('cancel', GC_TelegramBot.chancel_callback)
start_handler = CommandHandler('start', GC_TelegramBot.start_callback)
help_handler = CommandHandler('help', GC_TelegramBot.help_callback)
unbind_calendar_handler = CommandHandler('unbind', GC_TelegramBot.unbind_calendar_callback)
logout_handler = CommandHandler('logout', GC_TelegramBot.logout_callback)
# define other handlers
message_handler = MessageHandler(Filters.text, GC_TelegramBot.handle_user_message)
# adding handlers to dispatcher
dispatcher.add_handler(bind_calendar_handler)
dispatcher.add_handler(cancel_handler)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(help_handler)
dispatcher.add_handler(unbind_calendar_handler)
dispatcher.add_handler(logout_handler)
dispatcher.add_handler(message_handler)
# and start the bot...
updater.start_polling() | {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
52,389 | anevolina/GoogleCalendarBot | refs/heads/master | /core/calendar_core.py | """Core module to communicate with Google Calendar API"""
import datetime
import pickle
import os
from pymongo import MongoClient
from google_auth_oauthlib.flow import Flow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from core.logger import GCLogger
MongoDB = 'mongodb://localhost:27017/'
def get_authorisation_url():
"""The first step to authorize with URL - is to generate it.
Output:
auth_url - a user should follow this URL, and get authorization code at the very end;"""
flow = get_flow()
auth_url, _ = flow.authorization_url(prompt='consent')
return auth_url
def fetch_token(user_id, code):
"""The second step to authorize with URL - is to check the returned code.
Input:
user_id - user_id as it will be in the database;
code - code, given to the user after following auth_url;
Output:
True/False - whether authorization succeeded or not;"""
flow = get_flow()
try:
flow.fetch_token(code=code)
credentials = flow.credentials
save_user(user_id, credentials=pickle.dumps(credentials))
return True
except Exception as e:
logger.exception(e, user_id=user_id, code=code)
return False
def get_flow():
"""Return flow for authorization with necessary scopes"""
scopes = ['https://www.googleapis.com/auth/calendar']
client_secret = get_path('client_secret.json')
flow = Flow.from_client_secrets_file(
client_secret,
scopes=scopes,
redirect_uri='urn:ietf:wg:oauth:2.0:oob')
return flow
def get_path(file_name):
"""Return full path to the file with given file_name, located at the same directory"""
path = os.path.dirname(os.path.abspath(__file__))
file_name = os.path.join(path, file_name)
return file_name
def connect_db():
"""Return connection to the database with user settings"""
m_client = MongoClient(MongoDB)
conn = m_client.add_event_settings
return conn
def save_user(user_id, **kwargs):
"""Commit user settings to the database;
Input:
user_id - user id as it is in the database;
**kwargs - columns to save; accepted keys = [credentials, time_zone, calendar_id];"""
settings = connect_db()
save_settings(settings, user_id, **kwargs)
def save_settings(settings, user_id, **kwargs):
"""save user settings;
Input:
settings - connection to database with settings;
user_id - user id as it is in the database;
**kwargs - column names(keys) and values to save; accepted keys = [credentials, time_zone, calendar_id];"""
settings.settings.update_one({'_id': user_id}, {"$set": kwargs}, True)
def create_calendar(user_id, calendar_name, service=None):
"""Create new calendar in authorized Google Calendars account.
Inherit time_zone from saved settings or from the primary calendar
Input:
user_id - user id as it is in the database;
calendar_name - a name for the new calendar;
service - in case we already have built calendar service;
Output:
True/False - whether operation succeeded or not;"""
settings = get_user_settings(user_id)
credentials = settings.get('credentials')
time_zone = settings.get('time_zone')
credentials = pickle.loads(credentials)
service = service or get_calendar_sevice(user_id, credentials=credentials)
if not time_zone:
time_zone = get_calendar_time_zone(user_id, service=service)
calendar = {
'summary': calendar_name,
'timeZone': time_zone
}
try:
created_calendar = service.calendars().insert(body=calendar).execute()
calendar_id = created_calendar['id']
save_user(user_id, calendar_id=calendar_id, time_zone=time_zone)
except HttpError as err:
logger.error(err, user_id=user_id, calendar_name=calendar_name)
calendar_id = None
return calendar_id is not None
def fetch_calendar(user_id, calendar_name):
"""Try to fetch calendar by the given name - in case user wants to bind existed calendar.
Plus save it to user settings;
Input:
user_id - user id as it is in the database;
calendar_name - space-sensitive... overall very sensitive - make sure you type it right,
or there will be two calendars with almost identical names;
Output:
True/False - whether operation succeeded or not; """
calendar_id = get_calendar_id(user_id, calendar_name)
time_zone = get_calendar_time_zone(user_id, calendar_id=calendar_id)
save_user(user_id, calendar_id=calendar_id, time_zone=time_zone)
return calendar_id is not None
def get_calendar_id(user_id, calendar_name):
"""Get a list of all calendar ids from the user account, and looking for id with a particular name;
Input:
user_id - user id as it is in the database;
calendar_name - not case-sensitive - it compares everything in lowercase;
Output:
calendar_id - if the calendar was found;
None - if the calendar isn't found by the given name; """
credentials = get_credentials(user_id)
service = get_calendar_sevice(user_id, credentials=credentials)
page_token = None
while True:
calendar_list = service.calendarList().list(pageToken=page_token).execute()
for calendar_list_entry in calendar_list['items']:
if calendar_list_entry['summary'].lower() == calendar_name.lower():
return calendar_list_entry['id']
page_token = calendar_list.get('nextPageToken')
if not page_token:
break
return None
def get_user_settings(user_id):
"""Get settings from our database by given user_id"""
settings = connect_db()
result = settings.settings.find_one({'_id': {'$eq': user_id}})
return result
def get_formated_start_end_time(start_time, end_time, time_zone):
"""Get start and end time with formatting to add event;
Input:
start_time, end_time - datetime.datetime/ datetime.date - start and end time for an event;
Output:
start, end - dict - formatted time"""
start = {'timeZone': time_zone}
end = {'timeZone': time_zone}
if isinstance(start_time, datetime.datetime):
start['dateTime'] = start_time.strftime('%Y-%m-%dT%H:%M:%S')
end['dateTime'] = end_time.strftime('%Y-%m-%dT%H:%M:%S')
elif isinstance(start_time, datetime.date):
start['date'] = start_time.strftime('%Y-%m-%d')
end['date'] = end_time.strftime('%Y-%m-%d')
return start, end
def get_calendar_time_zone(user_id, calendar_id=None, credentials=None, service=None):
"""Return calendar time zone from Google Service;
Input:
user_id - as it is in our database;
calendar_id - as it is in Google Service; if not specified - use primary calendar;
Output:
time_zone - string - as it is in Google Service for the calendar;"""
if not service:
credentials = credentials or get_credentials(user_id)
if not calendar_id:
calendar_id = 'primary'
service = service or get_calendar_sevice(user_id, credentials)
result = service.calendarList().get(calendarId=calendar_id).execute()
return result['timeZone']
def get_calendar_sevice(user_id, credentials=None):
"""Return calendar service;
Input:
user_id - as it is in our database;
credentials - optional, if we already have credentials for the user;
Output:
service - Google Calendar service
"""
credentials = credentials or get_credentials(user_id)
try:
service = build('calendar', 'v3', credentials=credentials)
except AttributeError:
logger.error(AttributeError, user_id=user_id)
return None
return service
def get_credentials(user_id):
"""Load credentials from our database and decode it;
Input:
user_id - as it is in our database;
Output:
credentials - dict - credentials for using GC service"""
try:
credentials = pickle.loads(get_user_settings(user_id).get('credentials'))
except TypeError:
logger.error(TypeError, user_id=user_id)
credentials = None
return credentials
def set_calendar_to_primary(user_id):
"""Set calendar id to primary value + restore time zone;
Input:
user_id - as it is in our database;
Output:
True/False - whether operation succeeded or not;"""
try:
time_zone = get_calendar_time_zone(user_id, calendar_id='primary')
save_user(user_id, calendar_id='primary', time_zone=time_zone)
return True
except Exception as e:
logger.exception(e, user_id=user_id)
return False
def del_user(user_id):
"""Delete user from database;
Input:
user_id - as it is in our database;
Output:
True/False - whether operation succeeded or not;"""
settings = connect_db()
res = settings.settings.delete_one({'_id': {'$eq': user_id}})
return res.deleted_count
def add_event(user_id, description, start, end, service=None, attendees=None, location=None):
"""Try to add event;
Input:
user_id - as it is in our database;
description - string - main message for the event; first 50 symbols will be set as a title;
start, end - datetime.datetime/ datetime.date - start and end time for an event
service - Google Calendar service if already known
attendees - [list of emails] - who will be invited to an event
location - string - location for an event
Output:
['CREATED', 'MISTAKE']
"""
settings = get_user_settings(user_id)
credentials = settings.get('credentials')
time_zone = settings.get('time_zone')
calendar_id = settings.get('calendar_id')
if not calendar_id:
set_calendar_to_primary(user_id)
credentials = pickle.loads(credentials)
start_formated, end_formated = get_formated_start_end_time(start, end, time_zone)
event = {
'start': start_formated,
'end': end_formated,
'summary': description[:50],
'description': description,
'location': location,
'attendees': [{'email': email} for email in attendees] if attendees else None
}
service = service or get_calendar_sevice(user_id, credentials)
try:
service.events().insert(calendarId=calendar_id, body=event, sendNotifications=True).execute()
return 'CREATED'
except HttpError as err:
logger.error(err, user_id=user_id)
if err.resp.status == 404:
pass
return 'MISTAKE'
#Connect to the logger
logger = GCLogger()
| {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
52,390 | anevolina/GoogleCalendarBot | refs/heads/master | /core/logger.py | """Settings for project logger"""
import logging
class GCLogger():
def __init__(self):
"""Define logging parameters: level, file, format for messages"""
self.logger = logging.getLogger('GCAddEvent')
self.logger.setLevel(logging.INFO)
fh = logging.FileHandler('GCAddEvent.log')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
self.logger.addHandler(fh)
def info(self, *args, **kwargs):
"""Define logging for info events"""
message = self.get_message(*args, **kwargs)
self.logger.info(message)
def exception(self, *args, **kwargs):
"""Define logging for exceptions"""
message = self.get_message(*args, **kwargs)
self.logger.exception(message)
def error(self, *args, **kwargs):
"""Define logging for errors"""
message = self.get_message(*args, **kwargs)
self.logger.error(message)
def get_message(self, *args, **kwargs):
"""Assemble message from given args and kwargs"""
message = ''
message += ', '.join([str(key) + ': ' + str(val) for key, val in kwargs.items()]) + '; ' if kwargs else ''
message += ', '.join(str(val) for val in args) if args else ''
return message | {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
52,391 | anevolina/GoogleCalendarBot | refs/heads/master | /core/exceptions.py | class GCFlaskException(Exception):
"""
Base exception
"""
pass
class GCUnauthorisedUserError(GCFlaskException):
"""
Error raised when we don't have credentials for current user (function get_user_settings returns None)
to authorise they in Google Calendar service
"""
pass | {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
52,392 | anevolina/GoogleCalendarBot | refs/heads/master | /core/create_tables.py | """Auxiliary module for creating tables for the project.
_______________________________________________________
settings - table - for storing users settings;
settings_backup - table - for storing backups just in case
save_backup - trigger - for saving previous settings before their updates
"""
import sqlite3
conn = sqlite3.connect('calendar_settings.sqlite')
#Functions for create tables and trigger
create_settings = '''CREATE TABLE IF NOT EXISTS settings (
user_id TEXT PRIMARY KEY,
credentials BLOB,
time_zone TEXT,
calendar_id TEXT)'''
create_backup = '''CREATE TABLE IF NOT EXISTS settings_backup (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT,
credentials BLOB,
time_zone TEXT,
calendar_id TEXT,
change_date DATE)'''
save_backup = '''CREATE TRIGGER IF NOT EXISTS save_backup
BEFORE UPDATE
ON settings
BEGIN
INSERT INTO settings_backup (user_id, credentials, time_zone, calendar_id, change_date)
VALUES (old.user_id, old.credentials, old.time_zone, old.calendar_id, DATETIME('NOW')) ;
END;
'''
#Functions for delete tables and trigger
delete_settings = 'DROP TABLE IF EXISTS settings'
delete_backup = 'DROP TABLE IF EXISTS settings_backup'
delete_save_backup = 'DROP TRIGGER IF EXISTS save_backup'
#Uncomment these functions to create tables and trigger
#conn.execute(create_settings)
#conn.execute(create_backup)
#conn.execute(save_backup)
# Uncomment this to delete all
#conn.execute(delete_settings)
#conn.execute(delete_backup)
#conn.execute(delete_save_backup)
| {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
52,393 | anevolina/GoogleCalendarBot | refs/heads/master | /core/test_calendar_core.py | import unittest
from datetime import datetime
from main_api import get_start_end_time
import calendar_core
class CalendarCoreTest(unittest.TestCase):
def test_get_start_end_time(self):
"""Test parsing start and end time from a given string to datetime format"""
start1, end1 = get_start_end_time('27 Jul 2019 11 a.m.')
start2, end2 = get_start_end_time('April 19 2018 at 6 p.m.', 0.5)
start3, end3 = get_start_end_time('June')
self.assertEqual((start1, end1), (datetime(year=2019, month=7, day=27, hour=11, minute=0),
datetime(year=2019, month=7, day=27, hour=12, minute=0)))
self.assertEqual((start2, end2), (datetime(year=2018, month=4, day=19, hour=18, minute=0),
datetime(year=2018, month=4, day=19, hour=18, minute=30)))
self.assertEqual((start3, end3), (datetime.now().date(), datetime.now().date()))
def test_get_update_sql_text(self):
"""Test sql formatting"""
param1 = calendar_core.get_update_sql_text(credentials='value_credentials', calendar_id='123')
param2 = calendar_core.get_update_sql_text(time_zone='Nicosia/Cyprus')
self.assertEqual(param1,'credentials = excluded.credentials,\ncalendar_id = excluded.calendar_id')
self.assertEqual(param2, 'time_zone = excluded.time_zone')
if __name__ == '__main__':
unittest.main() | {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
52,394 | anevolina/GoogleCalendarBot | refs/heads/master | /tg_bot/bot_answers.py | """Module with text messages bot will send to users"""
def get_calendar_status_message(status, message):
if status == 'FETCHED':
message = 'Calendar ' + message + ' was bind with your account'
elif status == 'CREATED':
message = 'Calendar ' + message + ' was created'
else:
message = 'Something went wrong. Please, try again'
return message
def get_event_status_answer(status, start, **kwargs):
if status == 'CREATED':
message = 'Event started from {} was added.'.format(start.strftime("%d %B %Y, %H:%M:%S"))
if kwargs.get('location'):
message += '\nEvent location: ' + kwargs['location']
if kwargs.get('attendees'):
message += '\nInvited guests: ' + ', '.join(kwargs['attendees'])
else:
message = 'Something went wrong. Please, try again'
return message
def get_add_calendar_message():
message = 'Give me exact name of an existed calendar, connected to your account, or any other name to create a new ' \
'calendar\n\n' \
'/cancel to cancel this action'
return message
def get_canceled_message():
message = 'Operation canceled'
return message
def get_help_message():
message = 'To start, type a message... Write here something else, please.\n\n' \
'/bind - to customise in which calendar I will save all events\n' \
'/unbind - to set the calendar to the default value\n' \
'/start - to authorise with new email\n' \
'/logout - to logout from Google Calendar service for this bot'
return message
def get_authorise_url_message(url):
message = 'Please, get a validation code following instructions from this url so I could add ' \
'calendars and events to your account\n\n' + url + \
'\n\n/cancel to cancel this action'
return message
def get_del_status_message(status):
if status:
message = 'Calendar was set to the default value (primary calendar for your email)'
else:
message = 'Something went wrong. Please, try again'
return message
def get_authorised_message():
message = 'Access granted. Now you can add events through this bot.\n\n' + get_help_message()
return message
def get_wrong_code_message():
message = 'Something went wrong. Make sure you paste the whole code for authorisation.\n' \
'/cancel to cancel this operation'
return message
def get_unauthorised_user_error_message():
message = 'You didn\'t authorise at Google Calendar service.\n\n' \
'Press /start to connect'
return message
def get_logout_user_message(status):
if status:
message = 'You\'ve been logout from Google Calendar service'
else:
message = 'Something went wrong, please try again later'
return message | {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
52,395 | anevolina/GoogleCalendarBot | refs/heads/master | /core/main_api.py | import datefinder
import datetime
import re
from functools import wraps
import core.calendar_core as calendar_core
from core.exceptions import GCUnauthorisedUserError
from core.logger import GCLogger
logger = GCLogger()
def check_auth(func):
"""Decorator to quick check if we have records for given user in our database"""
@wraps(func)
def wraper(*args, **kwargs):
if 'user_id' in kwargs.keys():
check_user_settings(kwargs['user_id'])
return func(*args, **kwargs)
return wraper
def check_user_settings(user_id):
"""If we don't have records about given user_id - raise an error"""
if not calendar_core.get_user_settings(user_id):
raise GCUnauthorisedUserError('Current user doesn\'t have credentials in database')
@check_auth
def create_event(user_id, message):
"""Parse given message and try to create an event;
Input:
user_id - as it is in our database;
message - text from the user
Output:
event_status - string; possible variants - ['CREATED', 'MISTAKE']
start - datetime.datetime/ datetime.date - in what time event will start (what date parser found in the message)
attendeed - [list of emails] - who will be invited to an event (who parser found in the message)
location - string - location for an event (doesn't work for now, return empry string)"""
attendees = find_attendees(message)
location = find_location(message)
start, end = get_start_end_time(message)
try:
event_status = calendar_core.add_event(user_id, message, start, end, attendees=attendees, location=location)
except Exception as e:
logger.exception(e, user_id=user_id, message=message)
event_status = None
return event_status, start, attendees, location
def get_start_end_time(message: str, duration=1):
"""Try to find date in a given message;
Output:
start_time, end_time - datetime.datetime/datetime.date - if a particular date was found; if nothing found return
today's date;"""
start_time_match = list(datefinder.find_dates(message))
if start_time_match and start_time_match[0].hour:
start_time = start_time_match[0]
end_time = (start_time_match[0] + datetime.timedelta(hours=duration))
elif start_time_match:
start_time = start_time_match[0].date()
end_time = start_time_match[0].date() + datetime.timedelta(days=duration)
else:
start_time = end_time = datetime.datetime.now().date()
return start_time, end_time
def find_attendees(message):
"""Find all emails in a given message;
Output:
emails - list - all emails according to regexp pattern;"""
emails = re.findall(r'[a-z]{1}[a-z0-9\.\-\_]*@[a-z]+\.[a-z]{2,}', message.lower())
return emails
def find_location(message):
"""Suppose to looking for a location in the message, but I didn't figure out the rule for it"""
return None
@check_auth
def add_calendar(user_id, calendar_name):
"""Try to fetch calendar with the given name, if nothing was found - create one;
Input:
user_id - as it is in our database;
calendar_name - string;
Output:
status - one of ['FETCHED', 'CREATED', 'MISTAKE']"""
fetched = calendar_core.fetch_calendar(user_id, calendar_name)
status = 'FETCHED'
if not fetched:
created = calendar_core.create_calendar(user_id, calendar_name)
if created:
status = 'CREATED'
else:
status = 'MISTAKE'
return status
@check_auth
def unbind_calendar(user_id):
"""Set calendar to primary"""
status = calendar_core.set_calendar_to_primary(user_id)
return status
@check_auth
def logout(user_id):
"""Delete information about user from our database"""
return calendar_core.del_user(user_id)
def authorise_user_step1():
"""Function returns authorization url.
User should follow this url, and grant access to their calendar.
At the very end Google will issue a key which you should pass to the second step."""
auth_url = calendar_core.get_authorisation_url()
return auth_url
def authorise_user_step2(user_id, key):
"""Function will fetch token for given user, using provided key from the previous step."""
return calendar_core.fetch_token(user_id, key) | {"/tg_bot/add_event_bot.py": ["/tg_bot/GC_TelegramBot.py"], "/core/calendar_core.py": ["/core/logger.py"], "/core/main_api.py": ["/core/calendar_core.py", "/core/exceptions.py", "/core/logger.py"], "/tg_bot/GC_TelegramBot.py": ["/tg_bot/bot_answers.py", "/core/main_api.py", "/core/exceptions.py"]} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.