Anylogic: How to change the color of Rail Car using code - simulation

I have an AnyLogic Rail Yard simulation, and I'm trying to use one rail car type but have it be different colors depending on some code. I was thinking I could use a database table with the number of cars of a particular color that need to be produced, and maybe a parameter that would draw the color from that database table? I've researched this and I can't find anyone doing something similar, so any help is much appreciated. Thanks!

Related

Best Practice to display local markers and a wider area of points of interest markers?

I've created a base layer and 6 different overlay (Points of Interest) layers for a leaflet map.
The base layer of markers can appear on the map almost anywhere in the world, but I want the POI layers to appear only if they are in the same area (mapBounds) of the base layer. Probably the screen size.
All the data is pulled from a MySQL database and using Ajax I create the various sets of markers from two different tables, base and poi. This much is all done and working, you can see it at https://net-control.us/map2.php. The green and blue markers are from the base table, other markers are currently selected for view by clicking on the appropriate icon in the lower right. The only one active at the moment is 'Fire Station'. But if you zoom out far enough you will see additional fire stations in the Kansas City area, and in Florida. Those sets are not needed.
After the query runs I create a fitBounds variable of the base layer and another poiBounds for the poi layer. But I'm not sure I need the poiBounds. The number of base markers is generally less than 50 for the base query, but if all the poi markers are pulled world wide that number could be very large.
So I'm hoping someone can help me determine a best practice for this kind of scenario and maybe offer up an example of how it should be done. Should I...
1) Download all POIs and not worry about them appearing outside the base bounds layer? Should I inhibit them from showing in the javascript or in the SQL? How?
2) If I inhibit the unwanted points from SQL do I test one POI at a time to see if its included in the base bounds? How? Are there MySQL functions perhaps to work with this kind of data?
I'm fairly new at leaflet maps and would appreciate examples if appropriate.
2) If I inhibit the unwanted points from SQL do I test one POI at a time to see if its included in the base bounds? How? Are there MySQL functions perhaps to work with this kind of data?
You probably want a column of type POINT, a spatial index on such column (which internally is likely to be implemented as an R-Tree), and spatial relation functions on your SQL query to make use of that index.
Start by reading https://dev.mysql.com/doc/refman/8.0/en/spatial-types.html. Take your time, as spatial databases, spatial data types and spatial indices work a bit differently than their non-spatial equivalents.

Can you do pathfinding based on the pixelgrid of a .png file in Unity?

TL;DR: Can someone please help with pathfinding with no obstacles, fixed and known starting points, and edges based on transparency of the pixel grid of a .png file.
I'm trying to make a simple app for my students to teach them the correct stroke order and direction of the Chinese strokes.
So far I have achieved this by layering "start" and "end" game objects with CircleCollider2D components on top of the PolygonCollider2D generated by the sprite to check if they started the stroke, stayed within the stroke, and exited it correctly.
It does the job, yes, but it doesn't animate the fill in process like you'd expect from such an app, not to mention that I need to manually add "start" and "end" points myself.
Ideally I could just provide the stroke sprite, tell it which way I want the stroke to go (left to right, right to left etc.) and let the program create the ends based on the first/last 10% of the pixels, and of course animate it to fill in once completed correctly.
But baby steps!
First, I'd be grateful if someone could please tell me how to even get the pixel grid to begin with so I can perhaps attempt an A* approach.
Thank you!
This is the same case for validating AI racers if they are in racing in the correct way. You will have to indicate some sort of waypoint system that has is ordered by the way of strokes you want.
Imagine you're teaching them to write the number 2. You will have to create an array of nodes starting from the upper left most of the number until you get to the other end. You can validate the strokes if their fingers pass through the correct order or not.
No need for a complicated A* algorithm.
However, this won't do if you want to automate everything. This will require you to do some sort of image processing, editor tool, and loads of validations. I wouldn't suggest the automated one though.

How to define the size (dimension) of an agent on a conveyor

I am quite new with Anylogic.
I am trying to model a simple conveyor system.
I would like my conveyor to accumulate until the conveyed objects touch each other.
I have set the "gap" parameter of the conveyor to zero, but the objects accumulate with a pitch of (apparently) one meter ?
Am I missing something ?
Please have a look to the model:
https://cloud.anylogic.com/model/3af9fc14-8677-4171-9191-52614703bef6?mode=SETTINGS
If you have a custom agent, you can set it to type Material Item (1). You can then set the dimensions at the class level (2), and AnyLogic gives you this nice visual aid to see how big your item is (3). This visual is nice, because then you can draw your shapes for animation purposes to match the size.
This approach would be for components that do not change in size, like pallets or consistent parts in a manufacturing environment. For material items that have varying sizes, like boxes in a DC, I would probably use the source solution Ben suggested.
You can set the size of your agents in several places. Best one for you is likely in the Sourceblock when you create your object agents. Tick the "change dimension" tickbox as below:
In your conveyor, you can override/adjust the length again if you like:

How to design multi level highway intersection

So I am trying to design a multi-level highway system with the Road Traffic library in Anylogic. The highways have multiple levels and I am having trouble with depicting the difference in the levels of the roads in my model.
I looked at the help content related to RTL specifically Library Reference Guides and Tutorials but they don't mention adding grades/inclination to a road to get a multi level system.
I apologize in advance if I missed documentation related to this. But I would like to know how to do this in Anylogic.
Also, there is a Highway Junction model available in the sample models that comes with the installation and implements an increase in the z-value of the roads but I am not sure how to do that when designing the road.
When You draw road Object in RTL, in points section of the drawn road properties panel, you can set the Z value of each point of your road. So you should use more than two points to draw your road, even if it is a straight one. This way you can easily set z value of different points of your road, and build up needed levels, grades or slope of the road.
Hope this helps you.

Creating a non Rectangle UI in Unity?

So what I want to do is basically create a graph based off four numbers I get during runtime to create something like a personality chart. The user takes a quiz and based on which answer they give, I increase a running total for that attribute. At the end, based off of the numbers calculated turn each of the four numbers into vertices of a RectTransform in perhaps a panel or maybe something else entirely.
For each of the four categories there is a total of 10 possible points. The overall shape of the background panel is a diamond(i.e. rotated square), with each of the four corners representing an attribute.
I've tried messing with the RectTransforms and such but the shape always turns out a rectangle(Duh! its a RectTransform). But The problem is that I need it to not be a rectangle. Is there a way to do this in Unity or through any other means?
The black polygon would be an example of the type of shape I would want to create.
After doing some more research on the topic I found a script that does exactly what I want and more, which is really nice. I'll leave a link to it below.
https://github.com/CiaccoDavide/Unity-UI-Polygon/blob/master/UIPolygon.cs