Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("installer")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9f7db73aae63536d35e02c009a73a2d19a4a6e8d")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6c55dad574f4c42903af5b9996d72a8b23b25485")]
[assembly: System.Reflection.AssemblyProductAttribute("installer")]
[assembly: System.Reflection.AssemblyTitleAttribute("installer")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1b88c640623d488f80a81c10471e8c7d1e02a9c981c51eac3c8033d039a1e22f
7bb77af3ee0abd80638d125c2539832beada777088237eb6eb5bb82c51a91208
20 changes: 17 additions & 3 deletions logic/pve/official_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
"RLInterfaces",
"RLInterfaces.base_agent",
}
_ALLOWED_GAMELOGIC_IMPORTS = {
"Action",
"N_ACTIONS",
}


class SubmissionRuleError(RuntimeError):
Expand Down Expand Up @@ -82,8 +86,15 @@ def _error(self, node: ast.AST, message: str) -> None:

def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
module = node.module or ""
if module.startswith("GameLogic"):
self._error(node, "imports from GameLogic are not allowed in submissions")
if module == "GameLogic":
for alias in node.names:
if alias.name not in _ALLOWED_GAMELOGIC_IMPORTS:
self._error(
node,
"only Action and N_ACTIONS may be imported from GameLogic by submissions",
)
elif module.startswith("GameLogic"):
self._error(node, "imports from GameLogic internal modules are not allowed in submissions")
if module.startswith("RLInterfaces") and module not in _ALLOWED_RL_IMPORTS:
self._error(
node,
Expand All @@ -101,7 +112,10 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
def visit_Import(self, node: ast.Import) -> None:
for alias in node.names:
if alias.name == "GameLogic" or alias.name.startswith("GameLogic."):
self._error(node, "imports from GameLogic are not allowed in submissions")
self._error(
node,
"use 'from GameLogic import Action, N_ACTIONS' instead of importing GameLogic modules",
)
if alias.name == "RLInterfaces" or (
alias.name.startswith("RLInterfaces.") and alias.name not in _ALLOWED_RL_IMPORTS
):
Expand Down
Loading
Loading