I'm just trying to make sure I understand when, why, and how to use groups when sending messages (packets or what-have-you) across the network. The example that comes to mind for me is this:
So I'm imagining this map divided into four quadrants. Let's say each quadrant has NPCs and players.
The orange star represents Network Group 1.
The red star represents Network Group 2.
The blue star represents Network Group 3.
The green star represents Network Group 4.
So let's say all players start out in the blue star quadrant of the map, they'd be in group 3. Which means that all RPCs sent with "3" as the group argument would be received and processed on all players in that quadrant client's (right?). And any RPCs sent from/to the other groups would be ignored by their client's (right)?
So if an NPC moves to a new position in the green star quadrant, it wouldn't be processed on Groups 1-3 (right)?
Now, if a player moves from the blue star quadrant, into the green star quadrant, his Network Group should be switched (via a trigger collider) from 3 to 4 (right)?
Again, I'm just trying to check my understanding of how groups work when it comes to Networking. There's not much out their in the form of tutorials and what not. At least not that I've found.
The answer to your question is Yes and somehow NO. There is no Network Group class. Only a Method inside the Network Class.
If you were diving in with the Network Group. You wouldn't actually Make 4 Network Groups. You only need 1 if all GameObjects is the same, However you mentioned NPC so I assume you have Players, cause it is not a game if you don't have one.
So you make 1 NetworkGroup for NPC = Because they probably have the same components. 1 NetworkGroup for Players = The same Components.
Now I think, you are concern. To individual Players having a group. Well NetworkGroup is not something like, blue team, red team etc. It is just a Grouping Objects that works with the same Components.
For having a group in your game. You should just make a variable on what team they are on.
You could make a team using NetworkGroup but it is not really relevant for Game Logic. But you can make NetworkGroup for Chat so even if they are not on the same team as long as they're in the group. You can easily call or make a chat for that Group.
Related
I am modeling a warehouse yard where trucks arrive, get loaded/offloaded and leave the site. The complexity arises when modeling the drop trailers. Those vehicles consist of two parts: tractor and trailer. Tractor and trailer enter the yard as one entity and move to the parking lot. There, the tractor drops the trailer (turquoise colored rectangles in the picture below) and then then leaves the yard. After some time another tractor (pink colored in the picture below) comes to pick up one of those trailers. When there is no free space in the parking lot, model throws an error, because I use carMoveTo block to send it to the parkingLot. Therefore it requires additional space to move the tractor. How can I avoid this issue? In fact, I do not want that pink tractor to seize a free parking lot, but to pick up one of those trailers. I tried suppressing the error by using "on the way not found" option in the carMoveTo block, but I need to get a close-to-reality animation of the yard.
I would not advise mixing the road traffic library blocks with the Process Modelling Library (PML) Blocks, unless you really need to.
You can get near-perfect animation by making use of a network-type model and just the PML blocks. You will start by replacing your Car Move To block with just a MoveTo block
You can check the WholeSale Warehouse example in AnyLogic.
There they make use of a network diagram and PML blocks to simulation all the relative parking movements of trucks and trailers.
You can do something similar by creating the correct network and node points that indicate how a truck must move when it is parking a trailer and when it is picking up a trailer.
If this solution is not scalable and you cant draw lines, you can always simply just specify the X,Y, Z coordinates.
You might then need multiple MoveTo blocks for the entire movement or you can create some sort of loop where you give a truck a list of locations to move to, the truck will go through the loop and simply execute moving to the next location in the list, until it is done and then continue with the flow chart
I am trying to do a pedestrian modeling where individual pedestrian agent behavior needs to be controlled. Can I do that using the pedestrian agent's statechart?
Update: Sorry that my initial question wasn't clear enough
main
jaywalker (agent)statechart
runtime screenshot
jaywalker agent from padsource
In the first picture (main) I have a simple pedestrian model where jaywalker (pedestrian agent) moves through 2 road crossing. Initially all the jaywalker agents are in "walking" state & colored yellow (pic: 2), but whenever some agents are near another agent (near means within the triangular shown in jaywalker agent representation), they send the message "HI" to them & socialize. If someone is socialized, then they move from "walker" state to "socializing" state (and turn red) & send messages to others who are within his triangular range("field of vision" triangle). The first 11 socializing is done directly by a message from main (on model startup) & 11 jaywalker agents are receiving it & moving to "socializing" state. The problem is in my graph it's showing the first 11 socializing but during model runtime the agent's color is not changing. Secondly, after those 11 socializing, agents aren't socializing or sending any message to others who are within his triangle.
So, I am confused about how I can make my agents move from one statechart to another while modeling the movement behavior using the pedestrian library. Am I missing any step to connect the pedestrian library & agent statechart?
It looks like you did not tell PedSource to create your custom ped agents of type "JayWalker". Try this:
Delete your population, not needed
Make sure your JayWalker agent type is defined as pedestrians in its properties:
In your PedSource, make sure it creates "JayWalker" agents as below. (You should select JayWalker where my screen selects "MyPed")
Optionally, you can make the PedSource add the created "MyPed" agents to a custom population, but likely not necessary for you.
PS: Please understand that PedSource is creating agents, do not use your population for that. Read some more about PedSource and populations and do some tutorials to understand these basic concepts better :-)
In my model, car-agents sort in the correct lanes just a few car-length before the crossing when the traffic light is green. That way, the intersection gets unrealistically inefficient. What I can not find in the APIs is a way to determine the lane choice x meter before the intersection.
Is there a parameter, if not any idea, to set the lane choice of car-agents in front of a crossing?
Thankful for any thoughts.
I have found intermediate stop lines, which only cover certain lanes, can be used to give you more precise control. You can send a car to the intermediate stop line, and then send on to the final destination of choice.
the lane can only be chosen in the beginning when the car is created or through the enter/exit blocks... otherwise you have to just accept the randomness of the internal model and you have no control over it.
Edit: but amy in her answer is right that you can redirect cars to strategic intermediary stop lines in order to choose the lane or group of lanes the cars will choose whenever it's going to a certain destination.
I am working on Unity, using C# for a project that should be quite simple.
I am stuck to pathFinding .
I have Looked at Dikjstra's and A* for reference, but for some reason I still can't adopt them to work in my case. I guess my brain :=while(1);
Here is the Idea:
From a textfile I import a "map" where each "*" means Wall, and each " " walkarea. In the map there area randomly placed 2 objects: a bomb and an agent.
The agent must investigate the map (which forms a maze) and discover the bomb. The agent may move to his 8 neighbour tiles if they are NOT Wall. In my code , the agent class hold his own map. for every tile that he visits, he asks the "world map" for info, about his 8 neighbour tiles.
On his own map then he takes a note of the known tiles type(wall / walkpath) , and if it is a walkpath, he also notes, how many times he has visited it. The agent also has a "Prefered direction " list. This tells which tile to choose next to move to, if more than 1 have not been visited.
Up to this point, I have set it up all good and running, and if I let it run, he eventually finds the bomb. The Issue is that because he only runs on a Prefered direction according to the least visited tile , he has to re-visit some tiles too many times like a moron. So what
I must do is this:
If the agent reaches a tile for which, every nighbour is either wall or already visited, then he should investigate his own map, and the notes from the past to find an unvisited tile , and walk to there. Every walk direction has the same weight/cost, so we don't need to consider cost of path.
In my opinion, Dijkstra's is the closest to apply , but I still can't get it right .
Any Ideas or help would be much appreciated.
Thank You
Alex
Part of the issue is how much information you want to allow your agent. If you're willing to let him know where the target is, or at least its general direction in relation to himself, then you can use that to help influence the agent's decisions. This would allow you him to always favor moving in the direction that gets him closest to the goal while taking the least visited path.
Otherwise I'd keep track of each place he visited in a separate map, as well as the 8 neighboring tiles since he has "seen" them, with something like -1 indicating a wall that has been seen, -2 indicating an unseen location, and 0 indicating seen but unvisited. I'd then use A* or a variant on it that would move him to the closest unvisited point based on number of tiles traversed, breaking ties randomly. This would lead to a more trial and error rat in a maze approach.
I'm trying to figure out the best way to design Car and Road objects for a game design I'm working on.
The idea is for AI Cars (as well as the Player controlled car) to recognize when they traverse dotted lines or straight lines on the Roads.
I'd like to be able to build a Variable Lane Road for Unity3D with the appropriate flags and sub objects so that the Cars recognize where they are and when and how they traverse or take turns etc' etc'
For example, a Road can have a single direction or be in both directions.
For each direction there can be a number of lanes. Lanes allow cars to overtake each other (meaning a dotted line between the lanes).
If it's a bi directional road, then there's a line between the two lanes - optionally and ideally, if there's more than one lane on any of the directions, then the line that separates the directional lanes is straight.
By default, there should be a flag that draws the line according to an isOvertakingAllowed boolean flag.
The most important part is that the Car objects need to know what lane they are on or if they are on a lane separating line, and what type this separation is (overtaking allowed or not).
That's the hard part, to me.
Any help is appreciated.
I would recommend you implement a Lane, which have a direction of travel. Then implement a Road which has a collection of points, a path defining it's shape, and distance, and a collection of Lane objects that follow that path. Whether the road is one-way or two-way becomes a matter of which, and how many lanes they have.
In this case, a Car travels on a Road in a given direction, following the lane that it's in. It can only switch to other lanes that have compatible directions of travel (i.e. that are heading in the same direction as the car), unless the car turns around.
You might also have a special point in a Road called an Intersection which is a connection point for multiple Lanes, and somehow specify which Lanes a Car can transition to and from when it's at the Intersection.
That's a rough outline, but I think those are the basic relationships between the objects that you present, and should get you started.
There is an article on gamasutra with description of the model that was used for opencity, and how the different agents (standard car, racing car, pedestrian...) could use it. It may gives you some pointers or ideas.