Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old November 18, 2014, 15:07   #11
debo
Veteran
 
debo's Avatar
 
Join Date: Oct 2011
Location: Toronto, Canada
Posts: 2,364
debo is on a distinguished road
Quote:
Originally Posted by Derakon View Post
EDIT: while I support the idea of making the monster spellcasting behaviors more detailed, I suggest your first pass focus solely on replicating the existing data within the new format, and that you save tweaks and changes to game logic for later.
I'm sure we don't have any maintainers in attendance who would be tempted to make gameplay tweaks while undergoing major restructures....
__________________
Glaurung, Father of the Dragons says, 'You cannot avoid the ballyhack.'
debo is offline   Reply With Quote
Old November 18, 2014, 15:55   #12
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,929
Derakon is on a distinguished road
Quote:
Originally Posted by Therem Harth View Post
I was thinking that XML with extensive use of attributes would also be acceptable (as opposed to just tags, which would be far far too verbose).
Honestly, if you're going to go down that route, then I would recommend using JSON instead. In exchange for every key having to be a string (and thus enclosed in quotation marks), every value can be considerably more polymorphic, and in particular you can have numbers in the attributes instead of having to enclose each number in a tag.

XML is the Java of markup languages -- it can get the job done, but it's painfully verbose and there's almost certainly a better option that's aimed more specifically at your niche. And I'm saying this as someone whose job currently involves a lot of Java development.
Derakon is offline   Reply With Quote
Old November 18, 2014, 16:28   #13
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 921
Therem Harth is on a distinguished road
Hmm, thanks. I'm not a programmer by profession so I don't know this stuff very well.

JSON looks readable enough... The use of both brackets and braces is a bit confusing, not too bad though.

There seem to be quite a lot of JSON libraries for C. AH used Jansson for ToME 2... I'm thinking I could do the same, but might want to embed it.

Re Nick's new format, something CSV-ish like that would also be good. I feel like it would be nice to remove monster indexes entirely though, and use the name string as the unique reference.

(IMO if you have multiple instances of the same monster name, that's a design problem!)
Therem Harth is offline   Reply With Quote
Old November 18, 2014, 17:10   #14
Tarrant
Rookie
 
Join Date: Dec 2013
Posts: 9
Tarrant is on a distinguished road
In the context of Angband design, that's probably true. I think that monster index number is an example of general good practice programming, though. Ask anybody who has ever done database work- do you REALLY want the person's name to be the unique identifier, or are you worried that another Ben Jones is going to come along and overwrite the entry accidentally?

Having a numerical unique index also makes selecting a random entry less complicated, although I haven't done enough Angband code-diving to know if they take advantage of that.
Tarrant is offline   Reply With Quote
Old November 18, 2014, 17:39   #15
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Re Nick's new format, something CSV-ish like that would also be good. I feel like it would be nice to remove monster indexes entirely though, and use the name string as the unique reference.

(IMO if you have multiple instances of the same monster name, that's a design problem!)
I think we're getting close to that, actually. The only reason there is an index still is because we need something to save in the savefile, and saving a string for each monster is wasteful. (Or at least, that's what my 1990s sense of storage capacity is telling me...)

The real advantage of the current format is its compactness. It's nice to be able to fit multiple monster entries on the screen at once.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old November 18, 2014, 17:54   #16
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,929
Derakon is on a distinguished road
For what it's worth, Pyrel still has the monster indices in the data files, but it doesn't actually use them for anything, and monsters are looked up by name. It's pretty rare that you need a random monster, any monster, unique or not, from any depth -- usually you want to constrain your search somehow, which means you have to scan through the monster list to find applicable entries.

I really should start working on Pyrel again...

EDIT: the index is still helpful in Angband as a convenient way to index into the list of monster data structures, but this is more a side-effect of Angband being written in a language that doesn't have convenient hashmaps or other object-oriented features. Being able to index into a list is helpful in C; it's less vital in a higher-level language like Python which has more options for how to store information.

Last edited by Derakon; November 18, 2014 at 18:05.
Derakon is offline   Reply With Quote
Old November 18, 2014, 18:19   #17
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 921
Therem Harth is on a distinguished road
Yay data structures! I'd forgotten about that side of things.

Any reason not to implement a hashmap in Angband though? It's not like we'd need something complicated/high performance.

Edit:

Quote:
Originally Posted by takkaria
The real advantage of the current format is its compactness. It's nice to be able to fit multiple monster entries on the screen at once.
This is a good point, especially when comparing different monster entries. Personally though I think it would be better for that purpose to give the fields memorable names.
Therem Harth is offline   Reply With Quote
Old November 18, 2014, 19:07   #18
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by takkaria View Post
I think we're getting close to that, actually. The only reason there is an index still is because we need something to save in the savefile, and saving a string for each monster is wasteful. (Or at least, that's what my 1990s sense of storage capacity is telling me...)
Heh, though I'll bet just applying a gzip/deflate pass would yield much greater gains .
AnonymousHero is offline   Reply With Quote
Old November 18, 2014, 21:40   #19
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,849
Donated: $60
Nick will become famous soon enough
The thing about monster (and object and terrain) indices is that they don't hurt; they possibly make things slightly easier for parsing; and they provide a slight check against copy/paste errors in the edit files.

I did consider removing them, and decided there just wasn't any point.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old November 18, 2014, 22:01   #20
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,929
Derakon is on a distinguished road
Quote:
Originally Posted by Therem Harth View Post
Yay data structures! I'd forgotten about that side of things.

Any reason not to implement a hashmap in Angband though? It's not like we'd need something complicated/high performance.
As a general rule, if you're thinking of implementing the kind of data structure you learn about in introductory CS courses, then someone else has already implemented and tested and optimized it for you, somewhere.

But also, what are you trying to solve? If you have a specific monster's "key" and want to look up information on that monster, it doesn't really matter if the key is an index into a list, or a string into a hashmap -- you'll get the same result in roughly the same amount of time (big-O sense) either way.
Derakon is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Squelch idea Qyx v4 0 December 11, 2012 03:38
Tell me it's a dumb idea Antoine Variants 14 June 17, 2012 13:58
An idea for some later version... Therem Harth Development 11 January 5, 2011 20:19
Paladin idea for V Antoine Vanilla 11 April 7, 2010 18:53
Variant Idea Narvius Variants 5 February 27, 2008 21:24


All times are GMT +1. The time now is 20:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.