Next unit cycling should avoid bouncing around map

Brainstorm ideas of possible additions to the game in here. But, before you post, read this!

Moderators: Forum Moderators, Developers

Forum rules
State in your first post whether your idea is for Mainline or UMC. Also include in the topic of your thread (UMC) if it is destined for such. Otherwise your idea will be taken for proposed inclusion to mainline.

Before posting a new idea, you must read the following:

The wiki article regarding Wesnoth's development philosophy is also recommended.

Next unit cycling should avoid bouncing around map

Postby rrenaud » February 21st, 2007, 6:52 am

Sometimes I have two separate groups of units fighting at about the same vertical position on the map. When I cycle through units with the n key, the focus bounches violently through the map repeatedly to and from each cluster, and it's a bit disorienting.

The game should not neccesarily scroll left to right and then top to bottom all the time. Ideally, the game would do something like a travelling salesman approximation to figure out how to scroll through units minimizing the total scrolled distance. But simply picking the ordering by minimizing the difference from both left to right, up to down or up to down, left to right would probably almost completely avoid the bouncing effect and would be (I assume...) fairly straight forward to implement.

Does this seem like something that would be accepted if I coded up the patch? I want some revenge on my failed patch at https://gna.org/patch/?589
rrenaud
 
Posts: 34
Joined: February 8th, 2006, 5:43 am

Postby commanderkeen » February 21st, 2007, 7:05 am

Why not? If you make your own patch I don't see how people wouldn't accept it. Sure, it's not something most people care about, but your idea does sound better, and since you have done the code...

I think it sounds good, less scrolling, especially during healing before your turn, would be good.
commanderkeen
 
Posts: 183
Joined: November 16th, 2006, 6:41 am
Location: In your browser cache!

Postby Ken_Oh » February 21st, 2007, 8:50 am

I wouldn't like it. When I press "n", I more often than not want to see the unit's whole movement range. I could see this leading to a lot of useless scrolling to see where a unit could move, simply because it's near another unit.

I don't find jumping around disorienting at all, though I think this would be nice as an option for those that do.
User avatar
Ken_Oh
Moderator
 
Posts: 2177
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Postby irrevenant » February 21st, 2007, 11:14 am

Ken Oh wrote:I wouldn't like it. When I press "n", I more often than not want to see the unit's whole movement range. I could see this leading to a lot of useless scrolling to see where a unit could move, simply because it's near another unit.

I believe rrenaud meant that the screen would still 'jump to' (ie. autocentre on) the newly selected unit, just that the algorithm would select the nearest unit to jump to, rather than the next one to the right. You would still have the best possible view of where a unit can move.

I'm not sure how such an algorithm would work (eg. what would stop the algorithm from leaping back and forth between the same few units) but it sounds pretty handy.
Last edited by irrevenant on February 23rd, 2007, 11:41 pm, edited 1 time in total.
User avatar
irrevenant
Moderator Emeritus
 
Posts: 3689
Joined: August 15th, 2005, 7:57 am
Location: I'm all around you.

Postby Ken_Oh » February 21st, 2007, 1:24 pm

My bad entirely.
User avatar
Ken_Oh
Moderator
 
Posts: 2177
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Postby Darth Fool » February 21st, 2007, 1:38 pm

It sounds like a good idea if you can find a reasonably quick and good algorithm for approximating a traveling salesman solution. Whether it gets accepted will, of course, depend on the details and how well it works.
Darth Fool
Retired Developer
 
Posts: 2632
Joined: March 22nd, 2004, 11:22 pm
Location: An Earl's Roadstead

Re: Next unit cycling should avoid bouncing around map

Postby Eleazar » February 21st, 2007, 2:08 pm

rrenaud wrote:Ideally, the game would do something like a travelling salesman approximation to figure out how to scroll through units minimizing the total scrolled distance. But simply picking the ordering by minimizing the difference from both left to right, up to down or up to down, left to right would probably almost completely avoid the bouncing effect and would be (I assume...) fairly straight forward to implement.

Does this seem like something that would be accepted if I coded up the patch? I want some revenge on my failed patch at https://gna.org/patch/?589

I would like to see something like this. Such "intelligent" scrolling would also be nice during the healing phase, if you have a few healers.
The unnecessary bouncing around annoys me too.
User avatar
Eleazar
Terrain Art Director
 
Posts: 2303
Joined: July 16th, 2004, 1:47 am
Location: US Midwest

Postby tsr » February 21st, 2007, 2:15 pm

I'd say that the traveling salesman is an extreme overkill to accomplish that.

It would be enough to:
1. get all units with actions left in a two dimensional array
2. pick the first one in the list and focus on that and mark it as already focused
3. for the next one cycle through the array
3.1 award each unit (that is not marked as already focused) points according to how far it is from the current unit and keep a pointer for the unit with fewest points (where 1 point is for each difference in x and y)
3.2 if a unit is reasonably within reach (say 4 points) pick that and continue from 3 otherwise pick the unit with least points and continue from 3.
4. if there are no units left to focus on clear the already focused flag on all units and do it all again.

There is no need to find the path with least total movement. What we are trying to do is for the units that are close to each other to get selected before units that are far away do.

/tsr
tsr
WML Pioneer
 
Posts: 797
Joined: May 24th, 2006, 1:05 pm

Postby Jetrel » February 23rd, 2007, 7:22 am

And it should be noted that it's okay if on very rare occasions, the code fails on certain corner cases, and flies across the map to a distant unit, because that's no worse than what we have now.
User avatar
Jetrel
Art Director
 
Posts: 6937
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Postby RCG Tiburon » February 23rd, 2007, 6:21 pm

can we also have some sort of transition? I know when I hit 'n' it takes me a second to figure out my position relative to the previous one. maybe scrolling at double speed or something like that.
RCG Tiburon
 
Posts: 55
Joined: February 10th, 2007, 2:31 am

Postby Eleazar » February 23rd, 2007, 7:41 pm

RCG Tiburon wrote:maybe scrolling at double speed or something like that.

i think scrolling would be good
User avatar
Eleazar
Terrain Art Director
 
Posts: 2303
Joined: July 16th, 2004, 1:47 am
Location: US Midwest

Postby irrevenant » February 23rd, 2007, 11:50 pm

Thought:

We don't necessarily want to move to the strictly nearest unit, we just want to handle things in sensible clusters.

I can think of two ways to do that:

1. Just divide the map up into sectors (where a sector ~= 1 screen) , scroll through all the units in sector 1, then all the units in sector 2, etc. in a left->right, up->down pattern.

2. Get a bit more fancy and figure out where the clusters of units are, and work through the clusters in a left->right, up->down pattern. I dunno the math, I guess there's probably statistical functions that'd work this out...
User avatar
irrevenant
Moderator Emeritus
 
Posts: 3689
Joined: August 15th, 2005, 7:57 am
Location: I'm all around you.

Postby MSchmahl » March 16th, 2007, 8:32 pm

Why wouldn't this simple algorithm work?

1. Select an arbitrary unit to start the unit list (possibly the leftmost, or uppermost, or the leader).
2. While there are units left to be added to the list:
2.1. Find the unit, that is not in the list, closest to the last unit added.
2.2. Add that unit to the list.

I believe this is called the "nearest-neighbor" algorithm.
MSchmahl
Code & WML Contributor
 
Posts: 18
Joined: December 28th, 2006, 12:06 pm
Location: To the west and north

Postby rrenaud » March 16th, 2007, 10:19 pm

Yeah, I will implement nearest neighbors, once I get some free time.

From

http://en.wikipedia.org/wiki/Travelling ... an_problem

"In 2D Euclidean TSP, NN algorithm result in a length about 1.26*(optimal length)."
rrenaud
 
Posts: 34
Joined: February 8th, 2006, 5:43 am

Postby JW » March 16th, 2007, 10:25 pm

Yes, please do this. Scrolling would also be nice, but just this would be an improvement. Even just scrolling would be better, but let's jump 1 hurdle at a time. (Unless you're great at jumping over coding hurdles and can do both at once!)
User avatar
JW
 
Posts: 5025
Joined: November 10th, 2005, 7:06 am
Location: Chicago-ish, Illinois

Next

Return to Ideas

Who is online

Users browsing this forum: Google Feedfetcher and 0 guests