Skip to content

handle no valid moves more gracefully #4598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 23, 2020

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Oct 22, 2020

Proposed change(s)

Handle no valid moves more gracefully. Currently this will result in an exception being thrown from ActuatorDiscreteActionMask because all the actions for the branch will be masked off.

Ideally, the users should check for this state and change the board state before it happens. But we still need to more gracefully handle this since it's not a situation they're actively causing.

The changes in the PR are to:

  1. Don't mask the last action if it's invalid. This will result in an invalid action being passed to AbstractBoard.MakeMove, but that's easier to handle later.
  2. Fire an optional action callback, AbstractBoard.NoValidMoves. If that's not set, log a warning explaining what we're doing.

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

https://jira.unity3d.com/browse/MLA-1455

Types of change(s)

  • New feature

Checklist

  • Added tests that prove my fix is effective or that my feature works

Copy link
Contributor

@vincentpierre vincentpierre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me

/// An optional callback for when the all moves are invalid. Ideally, the game state should
/// be changed before this happens, but this is a way to get notified if not.
/// </summary>
public Action NoValidMoves;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public Action NoValidMoves;
public Action OnNoValidMovesAction;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@chriselion chriselion merged commit 5d91ccb into match3-example Oct 23, 2020
@delete-merged-branch delete-merged-branch bot deleted the match3-handle-no-valid-moves branch October 23, 2020 00:22
Hunter-Unity added a commit that referenced this pull request Nov 10, 2020
* first pass - matching and gravity work

* valid moves WIP

* move enumeration, simple checking

* move detection

* fix up/down directions

* actuator and heuristic

* sensor

* reset if no moves

* add masking, retrain

* cleanup

* config update

* optionally force heuristic mode

* compressed observations, reset board if no moves

* TFModel meta files

* WIP abstract

* random move heuristic

* rename Move fields, migrate IsValid logic

* comments

* reduce dependency on Match3Agent

* abstractBoard as monobehavior

* move actuator to extensions

* move sensor to extensions

* update components in scene

* undo accidental checkins

* drawing cleanup, custom maxMoves logic

* meta file

* prefab, use 8 agents

* different behaviors

* timers, early out

* unit tests

* docs

* Apply suggestions from code review

Co-authored-by: Vincent-Pierre BERGES <[email protected]>

* doc cleanup, swap to .nn file, add heuristic agents

* board iterator

* convert others to iterator, rename to Move.MoveIndex

* change observation type to enum

* fix flip for compressed obs

* save dimensions on sensor

* save dimension on actuator

* Match3 example - special pieces (#4575)

* WIP special pieces

* add special piece types to obs (need more from master first)

* update sensors and models

* docstrings

* more interesting scoring, smarter heuristic

* more steps

* longer trained models

* handle no valid moves more gracefully (#4598)

* handle no valid moves more gracefully

* rename callback

* cleanup heuristic logic

* more sensor and actuator tests

* update heuristic configs

* docstrings and add to environment docs

* sensor and actuator names

* compare compressed obs against saved PNGs

* review feedback, cleanup TODOs, comments

* docstrings, heuristic benchmarks

* kind of working

* added symbol gameobjects

* basic shapes & colors working

* cleanup and added background

* bug hunt. won't train

* merge master version

* update prefabs

* update prefabs

* add image to docs

* Update Match3.md

* rename some properties

* remove unneeded comments and some cleanup

Co-authored-by: Chris Elion <[email protected]>
Co-authored-by: Vincent-Pierre BERGES <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants