| 429 | The simplest way to operate multiple quagents on the REPL is to wrap all commands with "future". |
| 430 | |
| 431 | {{{ |
| 432 | client.core=> (future (move :bob 500 0)) |
| 433 | #<core$future_call$reify__5508@12d7d02: :pending> |
| 434 | client.core=> (future (move :joe 500 0)) |
| 435 | #<core$future_call$reify__5508@45ce17: :pending> |
| 436 | }}} |
| 437 | |
| 438 | If you want to apply the same command to many quagents, some typing can be saved with the "pmap" function, which is exactly like "map" except the elements are processed in parallel. |
| 439 | |
| 440 | {{{ |
| 441 | client.core=> (pmap #(move % 1000 0) (get-quagents)) |
| 442 | ([] []) |
| 443 | }}} |
| 444 | |
| 445 | Similarly, the function "pcalls" can be used to execute no-arg functions in parallel. |
| 446 | |
| 447 | {{{ |
| 448 | client.core=> (pcalls #(scan-area :bob 8000) #(move :joe 1500 180)) |
| 449 | ({"quagent_item_gold" ([839.970581 160.375198 0.613917] ... (output truncated) |
| 450 | client.core=> (pp) |
| 451 | ({"quagent_item_gold" |
| 452 | ([839.970581 160.375198 0.613917] |
| 453 | [703.026123 110.582535 0.733509] |
| 454 | [142.61908 136.43396 3.618063]), |
| 455 | "quagent_item_treasure" |
| 456 | ([493.463074 159.83313 1.045044] [908.39563 139.15329 0.567672]), |
| 457 | "info_player_deathmatch" |
| 458 | ([1001.049011 -176.454605 0.007154] |
| 459 | [999.580505 -178.285645 0.007165]), |
| 460 | "player" ([1005.275879 -174.131836 0.0] [30.128914 -90.0 0.0])} |
| 461 | []) ; note that this is the data from the second command |
| 462 | nil |
| 463 | }}} |
| 464 | |
| 465 | Similarly, "pvalues" builds a lazy sequence of values. |
| 466 | |
| 467 | {{{ |
| 468 | client.core=> (pvalues (scan-area :bob 8000) (move :joe 1500 180)) |
| 469 | ({"quagent_item_gold" ([839.970581 160.375198 0.613917] ... (output truncated) |
| 470 | client.core=> (pp) |
| 471 | ({"quagent_item_gold" |
| 472 | ([839.970581 160.375198 0.613917] |
| 473 | [703.026123 110.582535 0.733509] |
| 474 | [142.61908 136.43396 3.618063]), |
| 475 | "quagent_item_treasure" |
| 476 | ([493.463074 159.83313 1.045044] [908.39563 139.15329 0.567672]), |
| 477 | "info_player_deathmatch" |
| 478 | ([1001.049011 -176.454605 0.007154] |
| 479 | [999.580505 -178.285645 0.007165]), |
| 480 | "player" ([1005.275879 -174.131836 0.0] [267.436554 -6.46857 0.0])} |
| 481 | []) |
| 482 | nil |
| 483 | }}} |
| 484 | |
| 485 | |
| 486 | |