Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old November 17, 2014, 18:46   #1
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 923
Therem Harth is on a distinguished road
Idea: YAMLband

Monster, item, spell, etc. properties in YAML instead of the current custom format. More verbosity, better readability, and possibly more detailed specs. Each monster/item/whatever would be a separate "document" (within the same file as related ones).

Example:

Code:
---
name: Ancient Red Dragon
level: 41
rarity: 1
speed: 10
hitpoints: 880
armor: 90
experience: 2500
sight: 200
description: >
  A huge draconic form. Wisps of smoke steam from its nostrils and the extreme heat
  surrounding it makes you gasp for breath. 

flags: [evil, dragon, bashDoor, pushMonster, spawnAsleep]
resists: [fire, light, rockRemover, sleep, confusion]
breaths:
  - effect: fire
    damage: 300
    frequency: 0.2
spells:
  - effect: blind
    frequency: 0.1
  - effect: scare
    frequency: 0.1
  - effect: confuse
    frequency: 0.2
attacks:
  - type: claw
    damage: 4d9
  - type: claw
    damage: 4d9
  - type: bite
    damage: 7d9
    effect: fire
IMO having a better info format would go a long, long way towards making the game more hackable. The way things currently are, most of my Angband related projects have hit a brick wall of "Ugh, I don't want to edit any more info files."

... And yes, for the record I am volunteering my time for this, if anyone thinks it's a good idea.

Actually, I'm currently free on weekends, and itching for a project; adding a libyaml dependency to Angband, and moving stuff from C and text files into YAML, seems like a good possibility.

What do you people think? Any advice on what code base I should be using as a basis, etc. before I take the plunge?
Therem Harth is offline   Reply With Quote
Old November 17, 2014, 19:18   #2
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,941
Derakon is on a distinguished road
You might want to look at Pyrel, which uses JSON as its record storage system. For example, here's creature.txt. I'm not saying that you should necessarily use JSON instead of YAML (I went with JSON pretty much simply because Python has a built-in JSON library), just that it's bound to be a similar conversion process.

My initial approach involved writing small Python scripts to parse the info files and rewrite them in the new format. That got me bootstrapped; however, invariably I had to make file-wide tweaks later (e.g. when I converted monster resistances from a binary flag to a percentile stat modifier). I did this by having each file loader include a "dump this file to disk" method, which I could call after doing some modification to the in-memory version of the file. In pseudocode:

Code:
monster info = load("creature.txt");
for record in monster info:
    modify record;
write(monster info, "creature_modified.txt");
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.
Derakon is online now   Reply With Quote
Old November 17, 2014, 21:16   #3
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,860
Donated: $60
Nick will become famous soon enough
So here's the same monster as currently in the restruct branch:
Code:
name:444:Ancient red dragon
base:ancient dragon
color:r
info:120:880:20:108:80
power:41:1:1593840:226:2500
blow:CLAW:HURT:4d9
blow:CLAW:HURT:4d9
blow:BITE:FIRE:7d9
flags:HAS_LIGHT
flags:BASH_DOOR
flags:IM_FIRE
spell-freq:6
spells:BLIND | CONF | SCARE
spells:BR_FIRE
desc:A huge draconic form. Wisps of smoke steam from its nostrils and the
desc: extreme heat surrounding it makes you gasp for breath.
In terms of readability, the main difference is that yours explodes the info and power lines into individual speed, hitpoints, etc; I think we're heading in the same direction there.

I would be hesitant about adding another dependency unless there's a very good reason. Many, many of the bugs and difficulties we come up against are related to current dependencies (I've always thought the curses library is very well named). Every new dependency means checking it works for every platform we currently want to build on, or may want to in the future. Moreover, we currently have a very nicely written (ie not by me) parser which can handle everything we throw at it.

One of the big reasons for the current restructure is to make the game more hackable, so again we're going in the same direction.

If you're looking for a project, we've got a fairly big one going on right now. Feel free to have a look around the current state of things - any help and suggestions are welcome
__________________
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, 00:34   #4
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Just to second Nick (I think?): YAML sounds great on the surface, but it is in fact hideously complex when you get into the nitty-gritty of it because of layout and encoding rules (IIRC). As it turns out YAML just appears great initially because us humans don't tend to think of all the ways parsing can go wrong because we think whitespace is just fab. Nowadays, every time I'm forced to write YAML I cringe because I can never be sure exactly what the computer is going to think of my... scribblings. And it scares me.
AnonymousHero is offline   Reply With Quote
Old November 18, 2014, 01:55   #5
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 923
Therem Harth is on a distinguished road
... And as it happens I've been looking into Ansible for configuration management at work. Guess what Ansible uses for manifest files?

Puts a whole new spin on things, that does.

Thanks.

Therem Harth is offline   Reply With Quote
Old November 18, 2014, 12:14   #6
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by Therem Harth View Post
... And as it happens I've been looking into Ansible for configuration management at work. Guess what Ansible uses for manifest files?

Puts a whole new spin on things, that does.

Thanks.

Heh! We're using Ansible too. Of course there are a myriad ways you can break things using Ansible that have nothing to do with syntax, so I'm always careful to review diffs extremely carefully before running changed playbooks
AnonymousHero is offline   Reply With Quote
Old November 18, 2014, 14:31   #7
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 923
Therem Harth is on a distinguished road
Awesome. I thought part of the point of having declarative languages for config management was making it harder to break things.

(Right now we're actually using shell scripts and SSH, like in the olden days. I think it's possible to do this in a sensible way, but we definitely aren't.)
Therem Harth is offline   Reply With Quote
Old November 18, 2014, 14:36   #8
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by Therem Harth View Post
Awesome. I thought part of the point of having declarative languages for config management was making it harder to break things.

(Right now we're actually using shell scripts and SSH, like in the olden days. I think it's possible to do this in a sensible way, but we definitely aren't.)
Don't get me wrong, Ansible is way better than manual configuration management. The "danger" part just comes with the territory once you start to automate stuff like updating machines, installing/uninstalling packages, etc. Rolling out configuration changes automatically just means it's hard to notice if you've done anything stupid before the change hits every machine . (Ansible can do "partial" rollouts to make this kind of thing safer, but what you only have a handful of non-identical machines, it's not really possible to do partial rollouts sensibly.)

EDIT: ...aaaaanyway, this is probably getting too far off-topic.
AnonymousHero is offline   Reply With Quote
Old November 18, 2014, 14:43   #9
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 923
Therem Harth is on a distinguished road
Ah, gotcha. I was thinking more of provisioning and initial configuration, rather than maintaining a baseline.

No problem re going OT, configuring servers is fun.

Edit: anyway what other formats do you think would be more... robust than YAML in terms of parsing, with decent parsing libraries available?

Last edited by Therem Harth; November 18, 2014 at 14:53.
Therem Harth is offline   Reply With Quote
Old November 18, 2014, 15:05   #10
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 923
Therem Harth is on a distinguished road
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). e.g.

Code:
<monster name="Ancient Red Dragon"
  level="41"
  rarity="1"
  speed="10"
  hitpoints="880"
  armor="90"
  experience="2500"
  sight="200">
  <description>
A huge draconic form. Wisps of smoke steam from its nostrils and the extreme heat surrounding it
makes you gasp for breath. 
  </description>
  <flags>evil dragon bash-door push-monster spawn-asleep</flags>
  <resists>fire light rock-remover confusion sleep</resists>
  <spells frequency="0.16">
    blind
    scare
    confuse
    breath-fire
  </spells>
  <attacks>
    <claw damage="4d9"/>
    <claw damage="4d9"/>
    <bite damage="7d9" effect="burn"/>
  </attacks>
</monster>
Therem Harth 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 02:29.


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