![]() |
#1 |
Apprentice
Join Date: May 2007
Posts: 56
![]() |
Looking through the code
Sorry but some of the things in there really needs to be replaced with mathematical functions. For example look at line 795 in monster1.c. Surely you could construct a function to generate indices to access the string data in an array?
I'm doing that right now, but felt necessary to ask if there is an interest in rewriting code to simplify some constructs like the one mentioned? |
![]() |
![]() |
![]() |
#2 |
Adept
Join Date: Jun 2007
Location: North of England.
Posts: 211
![]() |
Don't forget that many, many coders haved hacked on Angband over the years, and the projects have generally favoured readability / ease of modification over 1337 and speedy code.
I've tried not to delve into the source too much yet myself, as I don't want to soak up too much internal workings - I'm still enjoying playing it like a closed box; however it seems to me like you might be thinking about hardcoding string data from the text files directly into arrays in the source? If so it's worth remembering that at one point all the those hard coded tables and messy constructs were pulled out into files / rewritten so that coders and non-coders alike would have a much easier time modifying the game... its a big part of why there are so many variants. On the other hand, if you genuinely found some way to speed up the code without detracting from clarity then go for it... I'm certain that many maintainers would integrate such patches into their own projects.
__________________
You sold a Broken Sword (1d2) (-2,-4) {average} (j) for 1 gold. The shopkeeper howls in agony! You say "Dude, the clue is in the name...". |
![]() |
![]() |
![]() |
#3 | |
Veteran
Join Date: Apr 2007
Posts: 1,951
Donated: $40
![]() |
No need to be, especially not in the first post in a thread.
![]() Quote:
FWIW, this is the latest version of that code in the development version: http://dev.rephial.org/trac/browser/...onster1.c#L689 Are you suggestion turning it into e.g. Code:
{ 200, "prefers to ignore" }, { 95, "pays very little attention to" }, BTW, suggestions on how to improve the code's clarity and patches to do the same are almost always welcome. |
|
![]() |
![]() |
![]() |
#4 |
Apprentice
Join Date: May 2007
Posts: 56
![]() |
You're definitely right, the logical construct would be much faster but my idea is:
Code:
arr[] = {"string1", "string2", "string3"} unsigned int idx = FourierFunction() sz = arr[idx] I've actually looked at the problem now, common sense suggests that maybe placing the conditional statement within it's own function would also achieve the exact same thing. I'm just looking for an excuse to use mathematics. Last edited by K.I.L.E.R; July 11, 2007 at 03:51. |
![]() |
![]() |
![]() |
#5 |
Adept
|
I guess you didn't read this -
http://developers.slashdot.org/artic.../07/08/0547234 or don't agree. ![]() |
![]() |
![]() |
![]() |
#6 |
Apprentice
Join Date: May 2007
Posts: 56
![]() |
That article was just making a point. Personally I've become more interested in mathematics because coupled with computing knowledge you can bring down complex models into compting and mathematical representations, (aka data structures and equations).
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
The safe_setuid code | CJNyfalt | Vanilla | 11 | June 26, 2007 03:25 |