Let's get programmy!
-
- Community Villain
Posts: 3588
-
- Community Hero
Posts: 4200
Re: Let's get programmy!
hey, at least it looks better than Dev-C++, which is what I used for C++ code.
Stupid IDE didn't even have code-folding.
Stupid IDE didn't even have code-folding.
- Callid
- Ratio vincit omnia.
Posts: 1433
Re: Let's get programmy!
Somehow, programming a Condition (yes, for checking whether a certain variable is larger/smaller/equal to a certain value) feels so redundant...
Also, I'm sure there's some kind of bug in there :x
Also, I'm sure there's some kind of bug in there :x
Code: Select all
public class Condition extends ConditionHolder {
Object loc;
Field attribute;
short comp;
/* 0: ==
* 1: !=
* 2: >
* 3: >=
* 4: value;
case 3:
return val >= value;
case 4:
return val < value;
case 5:
return val <= value;
case 7:
return val == Double.NaN;
default:
return false;
}
}
If
,
,
,
,
,
,
or
are attached, that paragraph may not be 100% serious. Seriously.
This link provides further information.
Callid Conia Pact - Petitions - Archive








This link provides further information.
Callid Conia Pact - Petitions - Archive
-
- Shounen Tantei Dan, Dai Seikou!
Posts: 1040
Re: Let's get programmy!
Huh? Why would anyone need something like this?Callid wrote: Somehow, programming a Condition (yes, for checking whether a certain variable is larger/smaller/equal to a certain value) feels so redundant...
Also, I'm sure there's some kind of bug in there :x



-
- Community Hero
Posts: 4200
Re: Let's get programmy!
Though I can't say what Callid's using it for, making classes/objects from conditionals could probably be useful for evaluating equations from a file / user input / what-have-you, depending on your implementation. In the past I've just had a master function which parses the input into tokens and then evaluates them, just a question of if the code lies inside or outside the tokens.
Though, if he is just trying to write an equation parser, it's probably been done before so I would say to google it before writing the whole thing
Though, if he is just trying to write an equation parser, it's probably been done before so I would say to google it before writing the whole thing

-
- Community Villain
Posts: 3588
Re: Let's get programmy!
Callid - you might have better luck going to like StackOverflow or something...I'm just far too lazy to do any more debugging during my free time, or reading someone else's code that isn't mine.

- Callid
- Ratio vincit omnia.
Posts: 1433
Re: Let's get programmy!
That's exactly the purpose. Basically, the idea was to store most of the initial world generation parameters in a .txt file so the user can easily change (or, heaven forbid, mod) it. However, I've come to believe that that'd be too much of a hassle in Java, especially as modding .jars is possible on its own. And in case I really need it later on for some reason, I can just create it at that timeAkonyl wrote: Though I can't say what Callid's using it for, making classes/objects from conditionals could probably be useful for evaluating equations from a file / user input / what-have-you, depending on your implementation.

To be precise, it was originally intended for magical items, i.e. an amulet or whatever that, for example, increases the wearer's skill in magical destruction if he has more than ten ranks in any heavy weapon related skill. However, the description for that amulet would be stored in the .txt, and therefore would the condition (skill.twohander>10||...||skill.waraxe>10) would need to be created while the program was running (there is another class (ConditionBranch extends ConditionHolder) that allows multiple conditions).
If
,
,
,
,
,
,
or
are attached, that paragraph may not be 100% serious. Seriously.
This link provides further information.
Callid Conia Pact - Petitions - Archive








This link provides further information.
Callid Conia Pact - Petitions - Archive
-
- Shounen Tantei Dan, Dai Seikou!
Posts: 1040
Re: Let's get programmy!
Have you considered xml? It's easily readable, editable and there are lots of parser libraries out there for it. Maybe you could do something like this:Callid wrote: To be precise, it was originally intended for magical items, i.e. an amulet or whatever that, for example, increases the wearer's skill in magical destruction if he has more than ten ranks in any heavy weapon related skill. However, the description for that amulet would be stored in the .txt, and therefore would the condition (skill.twohander>10||...||skill.waraxe>10) would need to be created while the program was running (there is another class (ConditionBranch extends ConditionHolder) that allows multiple conditions).
Code: Select all
<item>
<name>Amulet of Whatever</name>
<effect>
<skill_effect>
<name>Magical Destruction</name>
<abs_value_change>10<abs_value_change>
</skill_effect>
</effect>
<conditions>
<or>
<skill_condition>
<name>TwoHander</name>
<comparator>GreaterThan</comparator>
<value>10</value>
</skill_condition>
<skill_condition>
<name>WarAxe</name>
<comparator>GreaterThan</comparator>
<value>10</value>
</skill_condition>
</or>
</conditions>
</item>


- Callid
- Ratio vincit omnia.
Posts: 1433
Re: Let's get programmy!
Really? That works?c-square wrote:Have you considered xml? It's easily readable, editable and there are lots of parser libraries out there for it. Maybe you could do something like this:Callid wrote: To be precise, it was originally intended for magical items, i.e. an amulet or whatever that, for example, increases the wearer's skill in magical destruction if he has more than ten ranks in any heavy weapon related skill. However, the description for that amulet would be stored in the .txt, and therefore would the condition (skill.twohander>10||...||skill.waraxe>10) would need to be created while the program was running (there is another class (ConditionBranch extends ConditionHolder) that allows multiple conditions).
You can then get a parser to parse it into a set of objects so that you can then access the information.Code: Select all
<item> <name>Amulet of Whatever</name> <effect> <skill_effect> <name>Magical Destruction</name> <abs_value_change>10<abs_value_change> </skill_effect> </effect> <conditions> <or> <skill_condition> <name>TwoHander</name> <comparator>GreaterThan</comparator> <value>10</value> </skill_condition> <skill_condition> <name>WarAxe</name> <comparator>GreaterThan</comparator> <value>10</value> </skill_condition> </or> </conditions> </item>

Wait, how does the parser recognize skill_condition and WarAxe? I mean, the actual way to get the war axe skill is not simply skill.waraxe, but rather "skillDb.getTrueSkill(2,5)" (or ".getSkill(2,5)", depending on whether you want the modified or unmodified value), so it's not that obvious...
(Also, setting the magic skill would be "skillDb.modSkill(5,19,10)")
Last edited by Callid on February 28th, 2012, 10:41 pm, edited 1 time in total.
If
,
,
,
,
,
,
or
are attached, that paragraph may not be 100% serious. Seriously.
This link provides further information.
Callid Conia Pact - Petitions - Archive








This link provides further information.
Callid Conia Pact - Petitions - Archive
-
- Community Hero
Posts: 4200
Re: Let's get programmy!
depends on how the xml parser you use does things, but when I was using a JSON library (just another markup language like XML) in C++, to access it you would do something like
item.name["Amulet of Whatever"].conditions[0][0].name.asString()
would get you the value "TwoHander" and then you could shove that into your code however. Something like that at least, haven't used it for a while. :V
Either way, just google for java XML parsing examples
item.name["Amulet of Whatever"].conditions[0][0].name.asString()
would get you the value "TwoHander" and then you could shove that into your code however. Something like that at least, haven't used it for a while. :V
Either way, just google for java XML parsing examples

-
- Shounen Tantei Dan, Dai Seikou!
Posts: 1040
Re: Let's get programmy!
It'll recognize skill_condition because it's an xml element. Like Akonyl said, the parser will pickup and organize all the xml elements for you. It'll create an item object with a list or set of condition objects, each containing a list or set of skill_conditions (or whatever other conditions you set up). You'll be able to loop through the conditions to read them and get the information.Callid wrote: Really? That works?
Wait, how does the parser recognize skill_condition and WarAxe? I mean, the actual way to get the war axe skill is not simply skill.waraxe, but rather "skillDb.getTrueSkill(2,5)" (or ".getSkill(2,5)", depending on whether you want the modified or unmodified value), so it's not that obvious...
(Also, setting the magic skill would be "skillDb.modSkill(5,19,10)")
As for WarAxe, because it's an xml value and not an element, all the parser knows is that it's found a chunk of text, and will create a string object with "WarAxe" as its contents. It'll be up to you to figure out how to use that. Personally, I can see two ways of doing it. First, you could have a set of predefined strings for skill names. You then can use a map to internally translate those skill names to your numbering system. An alternative (and IMHO a better way to do it) would be to store the skill names in a reference table in the DB, and use joins to get and set the appropriate data. After all, skillDb.GetSkill("WarAxe") is much easier code to read and understand than skillDb.GetSkill(2,5).
EDIT: I was looking over my xml and I realized it was pretty sloppy. Here's an updated version:
Code: Select all
<items>
<item>
<name>Amulet of Whatever</name>
<effects>
<effect>
<name>MagicalDestruction</name>
<type>Skill</type>
<change>10<change>
<changeType>Absolute</changeType> <!--As compared to Percent -->
</effect>
</effects>
<conditions>
<operator>
<type>or</type>
<condition>
<name>TwoHander</name>
<type>Skill</type>
<comparator>GreaterThan</comparator>
<value>10</value>
</condition>
<condition>
<name>WarAxe</name>
<type>Skill</type>
<comparator>GreaterThan</comparator>
<value>10</value>
</condition>
</operator>
</conditions>
</item>
</items>
Last edited by c-square on February 29th, 2012, 12:38 am, edited 1 time in total.


-
- Community Hero
Posts: 4200
Re: Let's get programmy!
or at the very least, stop using magic numbers and use enums instead like skillDb.GetSkill(Skills.WarAxe)c-square wrote: After all, skillDb.GetSkill("WarAxe") is much easier code to read and understand than skillDb.GetSkill(2,5).

edit: The talk about parsing input expressions actually got me looking at a more elegant (but probly slower) solution to solving equations without having to parse them yourself (dynamic code compilation), buuut then I realized in my utility classes I apparently already wrote a string-expression evaluator :x
gogo almost-solving-the-same-problem-twice!
Last edited by Akonyl on March 2nd, 2012, 7:17 pm, edited 1 time in total.
-
- Community Revolutionary
Posts: 102
Re: Let's get programmy!
c-square wrote: WarAxe

'Che Guevara is an inspiration for every human being who loves freedom.'
-Nelson Mandela-
-Nelson Mandela-
-
- Community Villain
Posts: 3588
Re: Let's get programmy!
Cheesus! Sup dude.Cheesus wrote:c-square wrote: WarAxe![]()
Man, one of my friends is workin at TripAdvisor - SO MUCH MONEY. I might wanna gear my classes toward software in the future..semiconductor companies don't pay nearly enough

-
- Community Villain
Posts: 3588
Re: Let's get programmy!
To all the college grads and current undergrads. We've all done this.
Sign says " No food or drink allowed in Soda Hall"

Sign says " No food or drink allowed in Soda Hall"

