accuracy vs. monster EV


Questions, Explanations, Howtos

Slime Squisher

Posts: 363

Joined: Monday, 15th August 2011, 16:31

Location: Frankfurt

Post Sunday, 6th September 2015, 12:12

accuracy vs. monster EV

That debate about displaying exact numbers got me interested in exact numbers. So, I finally started code diving. I need a little help though with regard to melee attacks. I find the overall structure of melee_attack.cc hard to grasp.

What interests me right now is: after player accuracy is calculated, how is that number used vs. monster EV to determine whether a hit connects?

I have found
  Code:
attack::calc_to_hit
and
  Code:
melee_attack::calc_to_hit
. But even with grep I couldn't find where their results are actually used.

Any pointers?
"... while we / Unburden'd crawl toward death." -- King Lear I,1

Spider Stomper

Posts: 220

Joined: Sunday, 26th July 2015, 15:38

Post Sunday, 6th September 2015, 17:05

Re: accuracy vs. monster EV

Not sure, but personally I would not use grep, that guideline is pretty old and I would only use something like that for a script. Download sublime text editor, do open folder on the source code, and then you can cntrl(or command)-shift-f to get every case of the phrase, with about a paragraph of context. Might help, might not. Cntrl-p fuzzy searching files is also a godsend for wading through all the mon-X etc.

Dungeon Master

Posts: 555

Joined: Sunday, 9th June 2013, 17:13

Post Sunday, 6th September 2015, 17:41

Re: accuracy vs. monster EV

You can use grep just fine since our codebase is pretty flat, with most relevant files directly in the source directory, but it can be better to use a tool like git grep, which will search any file in the tree automatically and knows how to do things like search for a context function. Here's what git grep shows if you use -p to show the preceding function:

  Code:
$ git grep -p calc_to_hit
attack.cc=bool attack::handle_phase_end()
attack.cc:int attack::calc_to_hit(bool random)
attack.cc=void attack::init_attack(skill_type unarmed_skill, int attack_number)
attack.cc:    to_hit          = calc_to_hit(true);
attack.h=public:
attack.h:    virtual int calc_to_hit(bool random);
melee_attack.cc=void melee_attack::apply_staff_damage()
melee_attack.cc:int melee_attack::calc_to_hit(bool random)
melee_attack.cc:    int mhit = attack::calc_to_hit(random);
melee_attack.h=public:
melee_attack.h:    int calc_to_hit(bool random = true);
player.cc=static void _display_tohit()
player.cc:    const int to_hit = attk.calc_to_hit(false);
ranged_attack.cc=ranged_attack::ranged_attack(actor *attk, actor *defn, item_de*p
roj,                                                                           
ranged_attack.cc:int ranged_attack::calc_to_hit(bool random)
ranged_attack.cc:    orig_to_hit = attack::calc_to_hit(random);
ranged_attack.h=public:
ranged_attack.h:    int calc_to_hit(bool random);

The relevant function is attack::init_attack(), since you see:
  Code:
attack.cc=void attack::init_attack(skill_type unarmed_skill, int attack_number)
attack.cc:    to_hit          = calc_to_hit(true);


You should see the basic output you need if you did grep on *.cc and *.h files, and notice that second line in the output above. Once you have the file you need, it's often best to just open it and search for the relevant terms. You can use -n to print line numbers in grep or git grep output.

So attack::to_hit is where the resulting value is stored, and you'll want to look in attack.cc and melee_attack.cc for instances of to_hit to get further details on how to-hit is actually used. There are instances in both files, but melee_attack.cc will have most of the uses you're interested in.

For this message the author gammafunk has received thanks:
Utis
User avatar

Dungeon Master

Posts: 502

Joined: Wednesday, 7th March 2012, 13:25

Location: Lexington, KY, US

Post Sunday, 6th September 2015, 20:49

Re: accuracy vs. monster EV

As far as how to_hit is used, you might in particular want to look for attack::test_hit; and for melee_attack::attack and ranged_attack::attack, which call it.

For this message the author neil has received thanks:
Utis

Slime Squisher

Posts: 363

Joined: Monday, 15th August 2011, 16:31

Location: Frankfurt

Post Monday, 7th September 2015, 11:54

Re: accuracy vs. monster EV

Interesting. What I'm reading is that monster EV is doubled for EV rolls and that the average of two rolls is taken. So if the bot lists 10 EV for a monster, the roll is actually 2d9. Unfortunately, what with the way player to_hit is calculated, I forgot too much about stochastics to be able to calculate the average for a given player and monster, which is what actually interested me.

Anyways, thank you!

(Actually I didn't use grep directly, but M-x grep-find from within Emacs. I saw to_hit in init_attack, but I couldn't trace it, basically because I don't now how OO in C++ works. I try do make do with what I remember of plain C.)
"... while we / Unburden'd crawl toward death." -- King Lear I,1

Vestibule Violator

Posts: 1538

Joined: Tuesday, 13th March 2012, 02:48

Post Friday, 20th May 2016, 00:32

Re: accuracy vs. monster EV

Utis wrote:I forgot too much about stochastics to be able to calculate the average for a given player and monster, which is what actually interested me.


http://anydice.com/

For this message the author Rast has received thanks:
ximxim

Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.