Skip to content
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

[MLA-1584] Match3 variable board size #5189

Merged
merged 19 commits into from
Apr 1, 2021
Merged

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Mar 25, 2021

image

Proposed change(s)

  • Allow the Match3 integration to change the board size (as long as it's smaller than the maximum size). Things like checking for valid moves or getting the cell type will ignore cells outside of the current rows/columns (although they still take up space in the sensor and the action space).
  • Refactored AbstractBoard to have a GetMaxBoardSize and GetCurrentBoardSize abstract methods. This replaces the Rows/Columns/NumCellTypes/NumSpecialTypes fields that were there before.

TODO: will update the documentation and migration on this PR soon, but I wanted feedback on the AbstractBoard changes first.

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

https://jira.unity3d.com/browse/MLA-1584
https://docs.google.com/drawings/d/1pDlPgWyesTU8rFX1KiarsFaD5Ypwopr0pIr1I-NV_X8/edit (match3 move enumeration cheatsheet)

Types of change(s)

  • New feature
  • Code refactor
  • Breaking change

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

/// <summary>
/// Representation of the AbstractBoard size and number of cell and special types.
/// </summary>
public struct BoardSize
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like review/feedback on this interface before I update the documentation/migration/changelog.

/// </summary>
/// <returns></returns>
public IEnumerable<Move> InvalidMoves()
Copy link
Contributor Author

@chriselion chriselion Mar 29, 2021

Choose a reason for hiding this comment

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

The diff here is messy. InvalidMoves() was removed (previously it was used for action masking, but not anymore).

@chriselion chriselion marked this pull request as ready for review March 29, 2021 18:55
writer[offset] = (i == val) ? 1.0f : 0.0f;
offset++;
}
writer.WriteOneHot(offset, r, c, val, m_OneHotSize, isVisual);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this new? I haven't seen it. cool!

/// </summary>
/// <param name="boardSize"></param>
/// <returns></returns>
public bool IsValidForBoardSize(BoardSize boardSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like since a move is considered valid or invalid only in the context of a board, this check should go in the board.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I agree with this, sounds more natural to have Board.IsValidMove(Move move)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked to @surfnerd offline, we agreed on InRangeForBoard. I wanted to separate moved that we know are "invalid" because they go off the current board size, vs. moves that are invalid due to specific game logic.


m_CurrentBoardSize = new BoardSize
Copy link
Contributor

Choose a reason for hiding this comment

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

sounds a bit weird that BoardSize has attributes like NumCellTypes and NumSpecialTypes. BoardConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what I was hoping for feedback on. BoardSpec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, maybe it's convoluted logic, but the NumCellTypes and NumSpecialTypes define the "depth" of the board observations.

Copy link
Contributor

Choose a reason for hiding this comment

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

yea BoardSpec sounds good, so that you can say MaxBoardSpec for max size.

But you convinced me with the "depth" logic. I'm okay with both, leaning towards BoardSpec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I convinced myself too :) I'm leaning towards BoardSize; I think it makes a more sense to talk about "maximum" for board sizes, but not for specs.

@@ -3,38 +3,65 @@
<img src="images/match3.png" align="center" width="3000"/>

## Overview
One of the main feedback we get is to illustrate more real game examples using ML-Agents. We are excited to provide an example implementation of Match-3 using ML-Agents and additional utilities to integrate ML-Agents with Match-3 games.
One of the main feedback we get is to illustrate more real game examples using ML-Agents. We are excited to provide an
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly line breaks here.

@chriselion chriselion merged commit d17b735 into main Apr 1, 2021
@delete-merged-branch delete-merged-branch bot deleted the MLA-1584-variable-board-size branch April 1, 2021 01:00
@chriselion chriselion mentioned this pull request Apr 1, 2021
4 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2022
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.

3 participants