# How to Define Key Nodes & Evaluation Functions

## How to define key nodes

**Definition:** When there are multiple ways to complete a task, but no matter which method is used, it will go through a certain step(such as navigation to certain webpages or the performance of specific actions on web pages), we define it as a "key node".

The Dota 2 task in the previous section is an example. Reviewing this process:

* To accomplish the task, entering the Steam website is a necessary step. Thus it's the first key nodes.
* Searching for Dota 2 on Steam is not mandatory; I could also find Dota 2 through a Google search instead of Steam search.
* There are some operations that must be followed, such as entering the Dota 2 interface page.
  * The Dota 2 interface URL is: `https://store.steampowered.com/app/570/Dota_2/`&#x20;
  * Comparing with Steam's URL: `https://store.steampowered.com/`
  * We notice the differing part is: `app/570/Dota_2/`
  * Therefore, we add a URL include match: `app/570/Dota_2/` (how to choose this is explained in the last section).
* The third key node is pressing the "Add to Cart" button, for which we use path exact match.

> Q: Why not use an exact match?
>
> A: Because the main URL may not be `https://store.steampowered.com/`, it could be the non-http version `store.steampowered.com`, or `store.steampowered.us` with country domains like us, cn, jp, etc(of course, this URL may not exist). Therefore, when comparing the entire URL, try not to use URL exact match.

## How to define evaluation functions

### For all input operations on the page:

1. First, determine whether it is a necessary condition for task completion.
2. If it is a necessary condition, then judge whether the execution result can be reflected by the change of the URL. If so, simply take the state after execution as the key node and select the evaluation function as `URL exactly/included/semantic match`.
3. If it cannot be reflected by changes in the URL, it needs to be defined as a key node based on click or input operations. Select `element path exactly match` or `element value exactly/included/semantic match` for input operations (to determine whether the content of the input element matches).

### For all click operations on the page:

1. Firstly, determine whether it is a necessary condition for completing the task.
2. If it is a necessary condition, then judge whether the execution result can be reflected by the change of the URL. If so, simply take the state after execution as the key node and select the match rule as `URL exactly/included/semantic match`.
3. If it cannot be reflected by the change of url, each click operation should be defined as a key node, and the match can be selected as `element element path exactly match` or `element value/included/semantic match`

<figure><img src="https://127034098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ferav1ciJ1Zj7lRbkaCmD%2Fuploads%2Fw05yVWSMjelUYlb5hWp3%2Fimage.png?alt=media&#x26;token=3aefa944-a663-4e10-b0ce-3ac7ef338d52" alt=""><figcaption></figcaption></figure>
