Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Variants

Reply
 
Thread Tools Display Modes
Old November 29, 2012, 07:02   #11
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,918
Derakon is on a distinguished road
Quote:
Originally Posted by Patashu View Post
Using python's eval() may be a possible alternative, btw.
No, it isn't. Anything that treats data as code is a gaping security hole and has no place in a serious project. Which is unfortunate because it makes things very easy.
Derakon is offline   Reply With Quote
Old November 29, 2012, 07:30   #12
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by Patashu View Post
Ok, I copied how I did it from memory.

http://pastebin.com/GPTJVsvR
Given your evaluator, what is the result of "(8+5)*3"? Or "5+abs(5*abs(-5))"?

Your code looks hideously complicated since you're (it seems to me) combining parsing and evaluation. Those concerns should be separate -- if you separate them you'll get completely trivial code which is "obviosuly" correct.

EDIT: I also imagine that you'll want to be able to calculate different min, max and average(?) based on the expression for display purposes and that'll be easier to do cleanly if you've separated parsing from evaluation.

Quote:
Originally Posted by Patashu View Post
Probably still buggy, haven't had much chance to test yet. Will make sure everything works next time I sit down at a computer
You should add a "nose" test suite containing various simple and comlex evaluations along with their expected results. That way you can document that the code works and help *keep* it working.

Last edited by AnonymousHero; November 29, 2012 at 07:47.
AnonymousHero is offline   Reply With Quote
Old November 29, 2012, 12:04   #13
Patashu
Knight
 
Patashu's Avatar
 
Join Date: Jan 2008
Posts: 526
Patashu is on a distinguished road
Sit down at home, review Calculator.cs for C#, hammer out bug fixes for 2 hours \o/ (Most mistakes were from not being used to python, a few were forgetting important things like the lookaheads/lookbehinds on unary operators so 2V2 doesn't turn into 21.414etc, and getting order of operations right for operators of the same precedence)

EDIT: http://pastebin.com/H07vMSEf fixed 4-5*-5 and similar expressions

Everything not-completely-crazy should work now

Quote:
Given your evaluator, what is the result of "(8+5)*3"? Or "5+abs(5*abs(-5))"?
>>> calculatethis("(8+5)*3")
39.0
>>> calculatethis("5+abs(5*abs(-5))")
30.0
>>>
__________________
My Chiptune music, made in Famitracker: http://soundcloud.com/patashu

Last edited by Patashu; November 29, 2012 at 22:40.
Patashu is offline   Reply With Quote
Old November 29, 2012, 12:23   #14
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Patashu View Post
Sit down at home, review Calculator.cs for C#, hammer out bug fixes for 2 hours \o/ (Most mistakes were from not being used to python, a few were forgetting important things like the lookaheads/lookbehinds on unary operators so 2V2 doesn't turn into 21.414etc, and getting order of operations right for operators of the same precedence)

http://pastebin.com/20vCSF7Y

Everything not-completely-crazy should work now


>>> calculatethis("(8+5)*3")
39.0
>>> calculatethis("5+abs(5*abs(-5))")
30.0
>>>
Thanks Patashu - that is just fantastic, and perfect timing for me. After my discussion with Derakon I had moved to the point where I was just about to suggest using a 3rd-party library, but now we can try to avoid that.
__________________
"3.4 is much better than 3.1, 3.2 or 3.3. It still is easier than 3.0.9, but it is more convenient to play without being ridiculously easy, so it is my new favorite of the versions." - Timo Pietila
Magnate is offline   Reply With Quote
Old November 29, 2012, 12:25   #15
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Derakon View Post
I don't personally think this statement can be supported, but frankly it doesn't matter because we aren't locked into a single system. If you want to have spells that use hardcoded variations depending on the player's class, then you can do that. Just make a different set of procs for determining failure rate / spell cost, and, yes, include the class-specific values in the procs' definitions.
This is just brilliant.
Quote:
I daresay most spells can simply use the skill-based system instead and only a few exceptions, if any, will need the more specific approach.
I think I'd go so far as to say that our aim should be that the skill-based system should replicate V costs and expertise in the first instance. Variants can then use whichever system they like.

I just realised how easy it will be to reimplement Sangband in Pyrel ....
__________________
"3.4 is much better than 3.1, 3.2 or 3.3. It still is easier than 3.0.9, but it is more convenient to play without being ridiculously easy, so it is my new favorite of the versions." - Timo Pietila
Magnate is offline   Reply With Quote
Old November 29, 2012, 12:35   #16
Mikko Lehtinen
Veteran
 
Join Date: Sep 2010
Posts: 1,246
Mikko Lehtinen is on a distinguished road
Skill-based magic sounds really cool.

In Halls of Mist I'm going to have about the simplest possible skill-based spellcasting system. Learn spells by reading books. True spellcasting classes gain random bonus spells (from either Arcane or Divine list) on certain character levels. To cast any spell you have learned, roll 1d100 <= Spellcasting skill. All spells have a "mastery" level. When you reach that character level, you get to reroll a failed check once.

The exact same system is used for Magic Devices.

Last edited by Mikko Lehtinen; November 29, 2012 at 12:44.
Mikko Lehtinen is offline   Reply With Quote
Old November 29, 2012, 14:35   #17
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 3,002
fizzix is on a distinguished road
I will reserve my objections, but I will not pursue it further until I have a chance to see how everything works in actuality. Sounds fair?
fizzix is offline   Reply With Quote
Old November 29, 2012, 16:17   #18
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,918
Derakon is on a distinguished road
Quote:
Originally Posted by fizzix View Post
I will reserve my objections, but I will not pursue it further until I have a chance to see how everything works in actuality. Sounds fair?
Absolutely. And if I turn out to have been wrong, feel free to say "I told you so."

Quote:
Originally Posted by Magnate
I think I'd go so far as to say that our aim should be that the skill-based system should replicate V costs and expertise in the first instance. Variants can then use whichever system they like.
Yes, of course. Though I doubt that Vanilla's spell costs and failure rates will match a skill system, at least not one with a simple cost algorithm. We should at least be able to get close though.
Derakon is offline   Reply With Quote
Old November 29, 2012, 17:01   #19
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Derakon View Post
Yes, of course. Though I doubt that Vanilla's spell costs and failure rates will match a skill system, at least not one with a simple cost algorithm. We should at least be able to get close though.
My guess is that where the skill-based algorithm doesn't match the V costs/fail rates, it will be those cases which are already known as anomalous - like the duplicate CMW etc. IOW I don't think we have to match V exactly, warts 'n' all.
__________________
"3.4 is much better than 3.1, 3.2 or 3.3. It still is easier than 3.0.9, but it is more convenient to play without being ridiculously easy, so it is my new favorite of the versions." - Timo Pietila
Magnate is offline   Reply With Quote
Old November 29, 2012, 17:34   #20
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by Patashu View Post
EDIT: http://pastebin.com/VJihZXQG fixed 4-5*-5 and similar expressions

Everything not-completely-crazy should work now
Let's try some more crazy things (I'd suggest adding all the current examples to a little nose test suite -- have I suggested this before? :

Code:
+5 => ?
*3 => ?
--7=> ?
sin(10) + abs(5) => ?
sin => ?
sin(sin(sin(sin(3)))) => ?
(Some of these are obviously malformed.)

I still think it's a mistake to conflate evaluation and parsing, but as long as you add a relatively complete test suite (did I mention that already?) any implementation complexity issues or mistakes should be fixable at a later time. Seriously, it's completely trivial to add a few tests.
AnonymousHero 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
Pyrel dungeon generation fizzix Variants 50 December 7, 2012 01:32
Pyrel dev log, part 3 Derakon Variants 108 November 12, 2012 23:30
Affixes in Pyrel Magnate Development 0 October 13, 2012 13:53
Pyrel dev log, part 2 Derakon Variants 126 September 11, 2012 23:03
Pyrel dev log Derakon Variants 64 June 8, 2012 11:58


All times are GMT +1. The time now is 11:44.


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