Topic: the boat transport still needs working on
einstein13 |
Posted at: 2015-07-25, 17:15
What is wrong with my first algorithm? Everything there is computer logic: simple table and one patch to current port working. If you can't see there a computer logic, look here:
Is it understandable for Widelands? Is something missing? If you want to know how it works:
For creating routes I need few more minutes... It is a bit more complicated (more methods needed). einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-07-25, 18:09
Good for me, this "level" of logic is doable and I was thinking exactly about something like this. But still it is not fail-proof. In theory a ship can shuttle between two ports and never visit third one. Top Quote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 |
Posted at: 2015-07-25, 18:19
Yes, but this situation is also possible with current algorithm. (I can think about only one situation where with both algorithms we will have this problem). This algorithm doesn't affect current situation so much. It only optimize current situation. einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-07-25, 18:41
Also this algorithm will make difference only when ship is not able to load all wares in port. If your ideal is to have 1-2 items in a ship, there will be no difference whatsoever. Top Quote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 |
Posted at: 2015-07-25, 18:46
Yes, you are right. But I remember lots of situations where this patch would help. Especially on big seafaring maps. Also this is very basic step to make more intelligent way of putting wares into ships. For example waiting for the next ship while it (the second ship) will go to the correct direction. einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 |
Posted at: 2015-07-25, 19:10
How to create good logic for creating new routes? A bit more complex. I've added "return 0" where no return is necessary.
Edited: 2015-07-25, 19:13
einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-07-25, 20:46
uh, it looks difficult at least some explanation would help. But my understanding is:
Edited: 2015-07-25, 20:53
Top Quote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 |
Posted at: 2015-07-25, 22:31
Let's start from the beggining: destination_list is basic list which is the most important for the ship. The wares are not conuted. They are the basic of the route (the ship can't go to the port C while none of the wares wants to get there). recalculation of destination_list is every time when port is reached. It is made 2 times: when the port is reached (and the wares are unloaded) and when the wares from the port are uploaded. reading from destination_list is twice:
some additional comments:
If the condition never happened, it puts the new coordinates to the end of the list.
Port is reached
Ship starts new route
And yes, wares aren't counting in calculations. They only tells new destinations needed to be added to destination list. They can be added simply in core by refactoring "1.2" into different value like 1.5 or 2.0. Comparing old and my algorithm there is only one signifficant change: in old algorithm the destinations were in order of wares uploading to the ship (first go, first out). My algorithm allows the ship go to the ports not in the order, but only when it is worth it (1.2 factor means "we can spend 20% more time to deliver the ware quicker"). You have an idea of delivering wares with reagrds to their amount (10 wares to A, 1 ware to B). That is possible to do: just redefine the factor. It can be additional method. My algorithm PROHIBIT going only between two very close ports while are other wares to other ports. Maybe I will provide one more example (not only this from old PDF):
STEPS of "simulation":1) initial situationPorts and wares:
Ship
2) Ship loaded wares from A1:Port
Ship New wares: B1, C1, A2, B2, C2
3) Recalculating routeShip
New wares: B1, C1, A2, B2, C2
New wares: C1, A2, B2, C2
New wares: A2, B2, C2
New wares: B2, C2
New wares: C2
THE SHIP IS GOING TO PORT B1 4. Port B1Ports and wares:
Ship: B1 unloaded
Next port: B2 5. Port B2Ports and wares:
Ship: New wares: B1, A1
Algorithm prohibit comparing the route with control number > 0 at the beggining. So the only place is C1->A2. Results are:
Next destination: B2 and C2, after that: C1 6. Port C1 (B2 & C2 are already ahead)Ports and wares:
Ship: New wares: C2, B2
Result:
7. end of simulationthe rest is known: as destination list ROUTE: A1 -> B1 -> B2 -> C2 -> C1 -> A1 -> A2 -> B2 -> B1 -> C2 As you can see first ware (and its destination) in the list is always the most important. To solve the problem of "A2" ware here (it goes through all the port before it came to the correct one) we can put it in the first position in port. That will not affect infinite route between only 2 ports. It will affect only empty ships. Also if you dock in port nearby another destination, it is hard to go there. That is most problematic, because we don't want to see a ship going between two ports and no other directions. This example was a bit complex. Simple situation with "linear" (river) situation with ports A, B & C will provide route A -> B -> C -> B -> A -> B -> C -> ... (wares produced all the time). einstein13 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tibor |
Posted at: 2015-07-26, 06:41
OK, I understand entire algorithm - but it is overcomplicated for a game I think.... Also, I can not see any selection of wares that are to be loaded on the ship in a port based on actual route... It is unbalanced, if you pay so much attention to a route, why dont you pay any attention to selection of wares? Because it is very important. Unless you have only one ship... I have to think about it... Top Quote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
einstein13 |
Posted at: 2015-07-26, 09:27
I don't understand. What is complicated here? Where is complication? You asked code-like algorithm and I've provided it to you. You asked (before) any algorithm and I've provided that over a year ago. You asked of explanation and I've provided to you now. What is complicated? If a human can produce such an algorithm it isn't too complicated. And what algorithm do you tink is "not overcomplicated for game"? What is "overcomplicated"?! I don't understand you Also I don't think that this algorithm is very complicated. Some of the methods there are just basic work on lists. You can make it better in C++. I don't know the language well, only basics. So I've created multiple functions doing only one thing each (I've tried to do that). For me A* (A star) algorithm is complicated. I don't know how it works (exactly, not basicly). But I know that to solve complex problem we need that. Here we have similar problem: find the best path. This problem is very close to Travelling salesman problem and there is no universal solution. In our case it is even more complicated because we have all-the-time changes. In basic problem we have static situation: find the fastest route. I don't know what you've changed already in your branch, but it solves only bugs. The wrong behaviour of ships is still there. My algorithm will solve most problems. If it works (if it will be coded), I can polish it even more. There are few places that are very simple and none of algorithm is used there.
I will show it again: https://wl.widelands.org/forum/topic/1762/?page=5#post-14225 And I will tell you AGAIN: there is number of places where I can polish my algorithm. Now it is the simpliest way you can imagine. First step. It will work imperfect, but it will work better than now. I don't know exactly what I can do for "calling more ships to the port", "upload only few products into the ship", and so on. That will take more time to code. Not everything at once.
I pay attention, but it is more complicated than this part here (selection of wares in port, I understand). If you are talking about selection of wares onboard, it is not more important than the route. Why? Because for whole economy time is more important. My algorithm prevents of taking never-ending-route and all wares will finally reach the destination. Also it will be (almost) the fastest route for EVERY ware. If you have close ports A1 and A2 and far port B1 (0.5 hour trip), according to number of wares the ship will take A1 -> B1 -> A2 long trip and because of that half of economy stops (I've noticed that in current ship-route model) for 1 hour and the rest of economy will stop for 0.5 hour. With fastest route first half will never stop amd the second half is stopeed for 0.51 hour. So the difference is 1 hour less in first half and 0.01 hour more for the second half. That is why I think that routing is more important. (But wares are important too!)
Aks if you have ANY question- I will answer it. If you want to provide different solution- I am open to it. If you will find much better algorithm or way to solve the route problem, I will go for it. Better means: ship will deliver all resources faster than in my algorithm. And faster in real game, not only here, in the forum posts . Edited: 2015-07-26, 10:35
einstein13 |