Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Giant snake (not a priority)  (Read 1258 times)

TiagoTiago

  • Bay Watcher
    • View Profile
Giant snake (not a priority)
« on: March 27, 2010, 01:04:17 am »

as the title says, this is not a priority, it's jsut somthing i think would be fun (potentially "Fun" too)


The idea is to have a snake several tiles long (dunno, i guess somthing like 7 would be a minimum), it would not be able to move backward (or would do it only when there is no other choice), the head would be able to change to any of the remaining 7 directions, plus up and down if there is access. When the head moves the body tile right after the head would move to it's last position, the body tile after the first tile would move to the first tile's previous position and so on. If it needs to go backward, the tail would behave like the head in regards to movement, but on the opposite end of the body. If it won't eat too much processing power, limit how many times the snake can occupy a single tile to avoid it coiling itself too much, and also have a maximum amount for multiple tiles over the same X and Y coordinate contiguously, if there is space above, parts of the snake can go to the Z level above. The how much of the snake is on a given tile should influence the path generation for the snake so it will tend to not go over itself, while still being allowed to if it's worth it, but still avoiding if it won't fit. Snakes should be capable of dropping significant heights even without ramps, i've seen snakes with less than a third of it's body held on a branch and the rest of the body hanging as it tried to reach somewhere down bellow.
Logged
---
Notification emails don't always reach me, please let me know if you think it has happened (like if i don't reply a thread i'm expected to reply for more than a week)

Safe-Keeper

  • Bay Watcher
  • "Situation normal; all ****ed up"
    • View Profile
    • FS Mod tester
Re: Giant snake (not a priority)
« Reply #1 on: March 27, 2010, 01:20:01 am »

Multi-tile creatures are apparently very complex to code, but they're something Toady really wants to add. Or, at least, it's something we want him to really want to add.
Logged
"Sieging humans brought some war polar bears, and one of them started a camp fire. Highly trained!" --Today One accidentally introduces the panserbjørn into Dwarf Fortress lore

TiagoTiago

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #2 on: March 27, 2010, 01:22:19 am »

it's not only mult-tile but also flexible while still connected (not swarm like)
Logged
---
Notification emails don't always reach me, please let me know if you think it has happened (like if i don't reply a thread i'm expected to reply for more than a week)

immibis

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #3 on: March 27, 2010, 03:08:11 am »

Multi-tile creatures are apparently very complex to code, but they're something Toady really wants to add. Or, at least, it's something we want him to really want to add.
If it couldn't move backward, it wouldn't be that hard to code if all the segments counted as separate creatures. The head moves forward, then all the other segments move to the position of the next segment.
Logged
If I wanted ramps I would've designated ramps, dammit!

TiagoTiago

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #4 on: March 27, 2010, 03:14:27 am »

Moving backward would be needed to avoid it getting stuck, either by having head and tail switch movement roles or by allowing the head to move to where the first body tile is (switching places with it, getting on top of the second body tile). As for moving as a bunch of separated elements, would it still update the whole body before the next graphics frame is rendered or would there be risk that it would break apart from time to time?
Logged
---
Notification emails don't always reach me, please let me know if you think it has happened (like if i don't reply a thread i'm expected to reply for more than a week)

immibis

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #5 on: March 27, 2010, 03:44:06 am »

Moving backward would be needed to avoid it getting stuck, either by having head and tail switch movement roles or by allowing the head to move to where the first body tile is (switching places with it, getting on top of the second body tile). As for moving as a bunch of separated elements, would it still update the whole body before the next graphics frame is rendered or would there be risk that it would break apart from time to time?

Add a new rule: If the head can't move, have it switch places between the head and the tail the next the next time it would try to move (the delay is useful so it won't keep alternating and waste CPU time if it's stuck)
Logged
If I wanted ramps I would've designated ramps, dammit!

TiagoTiago

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #6 on: March 27, 2010, 03:49:49 am »

since all body tiles would probably look the same, perhaps when making the snake go backward you just make them not update while telling the head and tail to go to the "moving backward" state, then on the next update even if the current order of the body tiles is incorrect, they should all remain connected, and will adjust while moving...hm, no, then the head will jump to the middle of them until the body tiles rearrange... :/

Would it be too resource intensive to change the targets of all the body tiles to adjust to moving following a different target when changing from going fwd to backward?
« Last Edit: March 27, 2010, 03:58:56 am by TiagoTiago »
Logged
---
Notification emails don't always reach me, please let me know if you think it has happened (like if i don't reply a thread i'm expected to reply for more than a week)

TiagoTiago

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #7 on: March 27, 2010, 04:17:54 am »

Oh, btw, i was imagining that the algorithm for when moving backward  would be somthing simpler since the snake is not seeing where it's going, no pathfinding, just move backward in a straight line if there is a obstacle, try to move to diagonals backward, if  that is not possible, try to the sides, and if that is not possible, try diagonals to the front, then if that is not possible, try up and down, then if no way, give up and roll up on itself going over it's own body.
Logged
---
Notification emails don't always reach me, please let me know if you think it has happened (like if i don't reply a thread i'm expected to reply for more than a week)

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Giant snake (not a priority)
« Reply #8 on: March 27, 2010, 02:37:36 pm »

Moving backward would be needed to avoid it getting stuck, either by having head and tail switch movement roles or by allowing the head to move to where the first body tile is (switching places with it, getting on top of the second body tile). As for moving as a bunch of separated elements, would it still update the whole body before the next graphics frame is rendered or would there be risk that it would break apart from time to time?

You know, snakes can't really move backwards that very well... At least, not the very large ones, as they have a different pattern of movement than the smaller ones that do the side-to-side slithering.  (Larger ones have more complex musculature as well as enough mass to give them a good grip, so they do something more similar to the movement pattern of a caterpillar, just more subtly and quickly.)

Of course, realistically, it's not like a snake can't just twist itself completely around and do a 180 turn, anyway, so just make it so that the head can flip around and slither over other parts of its own body.  Which is to say, just don't make parts of its body restrict its own movement, and you're done.

It'd also be nice if such a snake could coil and actually jump in this game, as well, so that something could pass over a 1-tile-wide trench, or maybe scale a 1-z-level wall.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

TiagoTiago

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #9 on: March 27, 2010, 05:47:10 pm »

Are there any non-skeleton elephants? those would probably be the giant snake favorite meal (and it could leave a trail of skeleton elephants after a sizeable meal, or perhaps even barf some half-decomposed ones when attacked to be able to move faster (snakes do that IRL, at least the big ones)

Regarding them turning back on themselves, that would be kinda weird, i would think that they would at least try to unstuck themselves before doing such extreme contortionisms.
Logged
---
Notification emails don't always reach me, please let me know if you think it has happened (like if i don't reply a thread i'm expected to reply for more than a week)

Aquillion

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #10 on: March 28, 2010, 12:38:56 am »

At one point in ancient prehistory Crawl had a multi-tile giant worm, I think.  But it was horribly crashy and got removed.

Multi-tile things are very tough to do in general, when the game wasn't designed from the ground up with them in mind.
Logged
We don't want another cheap fantasy universe, we want a cheap fantasy universe generator. --Toady One

TiagoTiago

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #11 on: March 28, 2010, 01:26:23 am »

i can only begin to imagine the tangled mess that the underlying code must be (i've read there was a crash caused by vermin getting caught by a cobweb!), but things like short range path finding, and running some simple rules on a couple of tiles per creature per frame doesn't sound like things that should be crashy to start with (but then again, neither should vermin getting caught by cobwebs...)
Logged
---
Notification emails don't always reach me, please let me know if you think it has happened (like if i don't reply a thread i'm expected to reply for more than a week)

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Giant snake (not a priority)
« Reply #12 on: March 28, 2010, 08:50:37 am »

Some bugs are caused by an unforseen confluence of parameters, like having vermin and non-vermin creatures have different pathing coding which could hypothetically make the "stop moving" effect of a web generate an error in not finding the right kind of code to flag.

... as for snakes flipping back over on themselves being "extreme contortions"... maybe you should look at a few more snakes, because "extreme contortions" are pretty much what snakes are all about.  They can pretty easily bend themselves around 180 degrees in a fairly narrow space. 
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

winner

  • Bay Watcher
    • View Profile
Re: Giant snake (not a priority)
« Reply #13 on: March 28, 2010, 09:31:18 pm »

Some bugs are caused by an unforseen confluence of parameters, like having vermin and non-vermin creatures have different pathing coding which could hypothetically make the "stop moving" effect of a web generate an error in not finding the right kind of code to flag.

... as for snakes flipping back over on themselves being "extreme contortions"... maybe you should look at a few more snakes, because "extreme contortions" are pretty much what snakes are all about.  They can pretty easily bend themselves around 180 degrees in a fairly narrow space. 
My girlfriend's snake got stuck in a pipe once, the pipe was plenty big enough for it to go all the way through but when she go to the middle she decided to turn around.
Logged
The great game of Warlocks!

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Giant snake (not a priority)
« Reply #14 on: March 30, 2010, 12:20:15 am »

My girlfriend's snake got stuck in a pipe once, the pipe was plenty big enough for it to go all the way through but when she go to the middle she decided to turn around.

... Which is an argument against both turning completely around AND being able to put its gearbox into "reverse"...

Simply making a snake capable of slithering over its own body is simpler, and no less realistic than throwing the whole thing into reverse.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare
Pages: [1] 2