cogames-agents 0.0.0.7__cp312-cp312-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cogames_agents/__init__.py +0 -0
- cogames_agents/evals/__init__.py +5 -0
- cogames_agents/evals/planky_evals.py +415 -0
- cogames_agents/policy/__init__.py +0 -0
- cogames_agents/policy/evolution/__init__.py +0 -0
- cogames_agents/policy/evolution/cogsguard/__init__.py +0 -0
- cogames_agents/policy/evolution/cogsguard/evolution.py +695 -0
- cogames_agents/policy/evolution/cogsguard/evolutionary_coordinator.py +540 -0
- cogames_agents/policy/nim_agents/__init__.py +20 -0
- cogames_agents/policy/nim_agents/agents.py +98 -0
- cogames_agents/policy/nim_agents/bindings/generated/libnim_agents.dylib +0 -0
- cogames_agents/policy/nim_agents/bindings/generated/nim_agents.py +215 -0
- cogames_agents/policy/nim_agents/cogsguard_agents.nim +555 -0
- cogames_agents/policy/nim_agents/cogsguard_align_all_agents.nim +569 -0
- cogames_agents/policy/nim_agents/common.nim +1054 -0
- cogames_agents/policy/nim_agents/install.sh +1 -0
- cogames_agents/policy/nim_agents/ladybug_agent.nim +954 -0
- cogames_agents/policy/nim_agents/nim_agents.nim +68 -0
- cogames_agents/policy/nim_agents/nim_agents.nims +14 -0
- cogames_agents/policy/nim_agents/nimby.lock +3 -0
- cogames_agents/policy/nim_agents/racecar_agents.nim +844 -0
- cogames_agents/policy/nim_agents/random_agents.nim +68 -0
- cogames_agents/policy/nim_agents/test_agents.py +53 -0
- cogames_agents/policy/nim_agents/thinky_agents.nim +677 -0
- cogames_agents/policy/nim_agents/thinky_eval.py +230 -0
- cogames_agents/policy/scripted_agent/README.md +360 -0
- cogames_agents/policy/scripted_agent/__init__.py +0 -0
- cogames_agents/policy/scripted_agent/baseline_agent.py +1031 -0
- cogames_agents/policy/scripted_agent/cogas/__init__.py +5 -0
- cogames_agents/policy/scripted_agent/cogas/context.py +68 -0
- cogames_agents/policy/scripted_agent/cogas/entity_map.py +152 -0
- cogames_agents/policy/scripted_agent/cogas/goal.py +115 -0
- cogames_agents/policy/scripted_agent/cogas/goals/__init__.py +27 -0
- cogames_agents/policy/scripted_agent/cogas/goals/aligner.py +160 -0
- cogames_agents/policy/scripted_agent/cogas/goals/gear.py +197 -0
- cogames_agents/policy/scripted_agent/cogas/goals/miner.py +441 -0
- cogames_agents/policy/scripted_agent/cogas/goals/scout.py +40 -0
- cogames_agents/policy/scripted_agent/cogas/goals/scrambler.py +174 -0
- cogames_agents/policy/scripted_agent/cogas/goals/shared.py +160 -0
- cogames_agents/policy/scripted_agent/cogas/goals/stem.py +60 -0
- cogames_agents/policy/scripted_agent/cogas/goals/survive.py +100 -0
- cogames_agents/policy/scripted_agent/cogas/navigator.py +401 -0
- cogames_agents/policy/scripted_agent/cogas/obs_parser.py +238 -0
- cogames_agents/policy/scripted_agent/cogas/policy.py +525 -0
- cogames_agents/policy/scripted_agent/cogas/trace.py +69 -0
- cogames_agents/policy/scripted_agent/cogsguard/CLAUDE.md +517 -0
- cogames_agents/policy/scripted_agent/cogsguard/README.md +252 -0
- cogames_agents/policy/scripted_agent/cogsguard/__init__.py +74 -0
- cogames_agents/policy/scripted_agent/cogsguard/aligned_junction_held_investigation.md +152 -0
- cogames_agents/policy/scripted_agent/cogsguard/aligner.py +333 -0
- cogames_agents/policy/scripted_agent/cogsguard/behavior_hooks.py +44 -0
- cogames_agents/policy/scripted_agent/cogsguard/control_agent.py +323 -0
- cogames_agents/policy/scripted_agent/cogsguard/debug_agent.py +533 -0
- cogames_agents/policy/scripted_agent/cogsguard/miner.py +589 -0
- cogames_agents/policy/scripted_agent/cogsguard/options.py +67 -0
- cogames_agents/policy/scripted_agent/cogsguard/parity_metrics.py +36 -0
- cogames_agents/policy/scripted_agent/cogsguard/policy.py +1967 -0
- cogames_agents/policy/scripted_agent/cogsguard/prereq_trace.py +33 -0
- cogames_agents/policy/scripted_agent/cogsguard/role_trace.py +50 -0
- cogames_agents/policy/scripted_agent/cogsguard/roles.py +31 -0
- cogames_agents/policy/scripted_agent/cogsguard/rollout_trace.py +40 -0
- cogames_agents/policy/scripted_agent/cogsguard/scout.py +69 -0
- cogames_agents/policy/scripted_agent/cogsguard/scrambler.py +350 -0
- cogames_agents/policy/scripted_agent/cogsguard/targeted_agent.py +418 -0
- cogames_agents/policy/scripted_agent/cogsguard/teacher.py +224 -0
- cogames_agents/policy/scripted_agent/cogsguard/types.py +381 -0
- cogames_agents/policy/scripted_agent/cogsguard/v2_agent.py +49 -0
- cogames_agents/policy/scripted_agent/common/__init__.py +0 -0
- cogames_agents/policy/scripted_agent/common/geometry.py +24 -0
- cogames_agents/policy/scripted_agent/common/roles.py +34 -0
- cogames_agents/policy/scripted_agent/common/tag_utils.py +48 -0
- cogames_agents/policy/scripted_agent/demo_policy.py +242 -0
- cogames_agents/policy/scripted_agent/pathfinding.py +126 -0
- cogames_agents/policy/scripted_agent/pinky/DESIGN.md +317 -0
- cogames_agents/policy/scripted_agent/pinky/__init__.py +5 -0
- cogames_agents/policy/scripted_agent/pinky/behaviors/__init__.py +17 -0
- cogames_agents/policy/scripted_agent/pinky/behaviors/aligner.py +400 -0
- cogames_agents/policy/scripted_agent/pinky/behaviors/base.py +119 -0
- cogames_agents/policy/scripted_agent/pinky/behaviors/miner.py +632 -0
- cogames_agents/policy/scripted_agent/pinky/behaviors/scout.py +138 -0
- cogames_agents/policy/scripted_agent/pinky/behaviors/scrambler.py +433 -0
- cogames_agents/policy/scripted_agent/pinky/policy.py +570 -0
- cogames_agents/policy/scripted_agent/pinky/services/__init__.py +7 -0
- cogames_agents/policy/scripted_agent/pinky/services/map_tracker.py +808 -0
- cogames_agents/policy/scripted_agent/pinky/services/navigator.py +864 -0
- cogames_agents/policy/scripted_agent/pinky/services/safety.py +189 -0
- cogames_agents/policy/scripted_agent/pinky/state.py +299 -0
- cogames_agents/policy/scripted_agent/pinky/types.py +138 -0
- cogames_agents/policy/scripted_agent/planky/CLAUDE.md +124 -0
- cogames_agents/policy/scripted_agent/planky/IMPROVEMENTS.md +160 -0
- cogames_agents/policy/scripted_agent/planky/NOTES.md +153 -0
- cogames_agents/policy/scripted_agent/planky/PLAN.md +254 -0
- cogames_agents/policy/scripted_agent/planky/README.md +214 -0
- cogames_agents/policy/scripted_agent/planky/STRATEGY.md +100 -0
- cogames_agents/policy/scripted_agent/planky/__init__.py +5 -0
- cogames_agents/policy/scripted_agent/planky/context.py +68 -0
- cogames_agents/policy/scripted_agent/planky/entity_map.py +152 -0
- cogames_agents/policy/scripted_agent/planky/goal.py +107 -0
- cogames_agents/policy/scripted_agent/planky/goals/__init__.py +27 -0
- cogames_agents/policy/scripted_agent/planky/goals/aligner.py +168 -0
- cogames_agents/policy/scripted_agent/planky/goals/gear.py +179 -0
- cogames_agents/policy/scripted_agent/planky/goals/miner.py +416 -0
- cogames_agents/policy/scripted_agent/planky/goals/scout.py +40 -0
- cogames_agents/policy/scripted_agent/planky/goals/scrambler.py +174 -0
- cogames_agents/policy/scripted_agent/planky/goals/shared.py +160 -0
- cogames_agents/policy/scripted_agent/planky/goals/stem.py +49 -0
- cogames_agents/policy/scripted_agent/planky/goals/survive.py +96 -0
- cogames_agents/policy/scripted_agent/planky/navigator.py +388 -0
- cogames_agents/policy/scripted_agent/planky/obs_parser.py +238 -0
- cogames_agents/policy/scripted_agent/planky/policy.py +485 -0
- cogames_agents/policy/scripted_agent/planky/tests/__init__.py +0 -0
- cogames_agents/policy/scripted_agent/planky/tests/conftest.py +66 -0
- cogames_agents/policy/scripted_agent/planky/tests/helpers.py +152 -0
- cogames_agents/policy/scripted_agent/planky/tests/test_aligner.py +24 -0
- cogames_agents/policy/scripted_agent/planky/tests/test_miner.py +30 -0
- cogames_agents/policy/scripted_agent/planky/tests/test_scout.py +15 -0
- cogames_agents/policy/scripted_agent/planky/tests/test_scrambler.py +29 -0
- cogames_agents/policy/scripted_agent/planky/tests/test_stem.py +36 -0
- cogames_agents/policy/scripted_agent/planky/trace.py +69 -0
- cogames_agents/policy/scripted_agent/types.py +239 -0
- cogames_agents/policy/scripted_agent/unclipping_agent.py +461 -0
- cogames_agents/policy/scripted_agent/utils.py +381 -0
- cogames_agents/policy/scripted_registry.py +80 -0
- cogames_agents/py.typed +0 -0
- cogames_agents-0.0.0.7.dist-info/METADATA +98 -0
- cogames_agents-0.0.0.7.dist-info/RECORD +128 -0
- cogames_agents-0.0.0.7.dist-info/WHEEL +6 -0
- cogames_agents-0.0.0.7.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# This file has an example of random agents that just take random actions.
|
|
2
|
+
|
|
3
|
+
import
|
|
4
|
+
std/random,
|
|
5
|
+
common
|
|
6
|
+
|
|
7
|
+
type
|
|
8
|
+
RandomAgent* = ref object
|
|
9
|
+
agentId*: int
|
|
10
|
+
cfg*: Config
|
|
11
|
+
random*: Rand
|
|
12
|
+
|
|
13
|
+
RandomPolicy* = ref object
|
|
14
|
+
agents*: seq[RandomAgent]
|
|
15
|
+
|
|
16
|
+
proc newRandomAgent*(agentId: int, environmentConfig: string): RandomAgent =
|
|
17
|
+
var config = parseConfig(environmentConfig)
|
|
18
|
+
result = RandomAgent(agentId: agentId, cfg: config)
|
|
19
|
+
result.random = initRand(agentId)
|
|
20
|
+
|
|
21
|
+
proc reset*(agent: RandomAgent) =
|
|
22
|
+
agent.random = initRand(agent.agentId)
|
|
23
|
+
|
|
24
|
+
proc step*(
|
|
25
|
+
agent: RandomAgent,
|
|
26
|
+
numAgents: int,
|
|
27
|
+
numTokens: int,
|
|
28
|
+
sizeToken: int,
|
|
29
|
+
rawObservation: pointer,
|
|
30
|
+
numActions: int,
|
|
31
|
+
agentAction: ptr int32
|
|
32
|
+
) =
|
|
33
|
+
discard numAgents
|
|
34
|
+
discard numTokens
|
|
35
|
+
discard sizeToken
|
|
36
|
+
discard rawObservation
|
|
37
|
+
discard numActions
|
|
38
|
+
agentAction[] = agent.random.rand(1 .. 4).int32
|
|
39
|
+
|
|
40
|
+
proc newRandomPolicy*(environmentConfig: string): RandomPolicy =
|
|
41
|
+
let cfg = parseConfig(environmentConfig)
|
|
42
|
+
|
|
43
|
+
var agents: seq[RandomAgent] = @[]
|
|
44
|
+
for id in 0 ..< cfg.config.numAgents:
|
|
45
|
+
agents.add(newRandomAgent(id, environmentConfig))
|
|
46
|
+
RandomPolicy(agents: agents)
|
|
47
|
+
|
|
48
|
+
proc stepBatch*(
|
|
49
|
+
policy: RandomPolicy,
|
|
50
|
+
agentIds: pointer,
|
|
51
|
+
numAgentIds: int,
|
|
52
|
+
numAgents: int,
|
|
53
|
+
numTokens: int,
|
|
54
|
+
sizeToken: int,
|
|
55
|
+
rawObservations: pointer,
|
|
56
|
+
numActions: int,
|
|
57
|
+
rawActions: pointer
|
|
58
|
+
) =
|
|
59
|
+
let ids = cast[ptr UncheckedArray[int32]](agentIds)
|
|
60
|
+
let obsArray = cast[ptr UncheckedArray[uint8]](rawObservations)
|
|
61
|
+
let actionArray = cast[ptr UncheckedArray[int32]](rawActions)
|
|
62
|
+
let obsStride = numTokens * sizeToken
|
|
63
|
+
|
|
64
|
+
for i in 0 ..< numAgentIds:
|
|
65
|
+
let idx = int(ids[i])
|
|
66
|
+
let obsPtr = cast[pointer](obsArray[idx * obsStride].addr)
|
|
67
|
+
let actPtr = cast[ptr int32](actionArray[idx].addr)
|
|
68
|
+
step(policy.agents[idx], numAgents, numTokens, sizeToken, obsPtr, numActions, actPtr)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main() -> None:
|
|
9
|
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
10
|
+
sys.path.append(os.path.join(current_dir, "bindings/generated"))
|
|
11
|
+
|
|
12
|
+
import nim_agents as fa # type: ignore[import-not-found]
|
|
13
|
+
|
|
14
|
+
fa.nim_agents_init_chook()
|
|
15
|
+
|
|
16
|
+
num_agents = 2
|
|
17
|
+
num_tokens = 50
|
|
18
|
+
size_token = 3
|
|
19
|
+
observations = np.zeros((num_agents, num_tokens, size_token), dtype=np.uint8)
|
|
20
|
+
actions = np.zeros(num_agents, dtype=np.int32)
|
|
21
|
+
|
|
22
|
+
policy = fa.RandomPolicy("{}")
|
|
23
|
+
subset = np.array([0, 1], dtype=np.int32)
|
|
24
|
+
subset_ptr = subset.ctypes.data_as(ctypes.POINTER(ctypes.c_int32))
|
|
25
|
+
policy.step_batch(
|
|
26
|
+
subset_ptr,
|
|
27
|
+
subset.size,
|
|
28
|
+
num_agents,
|
|
29
|
+
num_tokens,
|
|
30
|
+
size_token,
|
|
31
|
+
observations.ctypes.data,
|
|
32
|
+
num_agents,
|
|
33
|
+
actions.ctypes.data,
|
|
34
|
+
)
|
|
35
|
+
print(actions)
|
|
36
|
+
|
|
37
|
+
single_subset = np.array([0], dtype=np.int32)
|
|
38
|
+
single_ptr = single_subset.ctypes.data_as(ctypes.POINTER(ctypes.c_int32))
|
|
39
|
+
policy.step_batch(
|
|
40
|
+
single_ptr,
|
|
41
|
+
single_subset.size,
|
|
42
|
+
num_agents,
|
|
43
|
+
num_tokens,
|
|
44
|
+
size_token,
|
|
45
|
+
observations.ctypes.data,
|
|
46
|
+
num_agents,
|
|
47
|
+
actions.ctypes.data,
|
|
48
|
+
)
|
|
49
|
+
print(actions[0])
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
main()
|