Giter VIP home page Giter VIP logo

boardgame's People

Contributors

andygeorge avatar jkomoros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

boardgame's Issues

Notion of PlayerMoves and MetaMoves in Game

PlayerMoves is the set of all moves that Players can ever propose. MetaMoves is all other moves--things like FixUps. This makes it easier for e.g. cli to enumerate only the moves that the user likely wants to apply, while still allowing them to propose the other moves if they really want to.

Question: is every MetaMove a FixUp move? Do FixUp moves make sense to apply IFF their Legal() returns true for a given state?

Originally captured in #45

Consider if PropertyReader is necessary

It's not actually used anywhere. And if it were, we'd likely just use reflection (which would require the fields to be public... or would it? Looks like you might be able to read).

It's theoretically useful in the Logic Engine to be able to read property values, but maybe we just do a State.ReadProperty(...name string) interface{}, which can just use reflection.

It's a lot of (weird) overhead to have until we actually need it...

At the worst we can probably remove it and then add it back in if really necessary.

Move.DefaultsForState(Payload)

Sets the defaults for a move based on the current state. For example, it might set TargetPlayerIndex = state.game.currenPlayerIndex

Add a IsGameFinished method

Likely on delegate. This is a method that will check to see if based on the state, the game is over. And if so, who won.

Add a way for moves to get fields set during Apply()

Like precisely which card was actually drawn--the information necessary to actually have enough information to apply the move clientside.

Will need to keep this separate somehow from information necessary to PROPOSE a move. Maybe with struct tags (ick!) or with a Complete() method that returns true when all of the required fields to propose a move are complete. Or a sub-struct that has state after its been set?

Add SizedStack

Currently called FixedLengthStack in the explainer.

A normal stack, except that the length is always the same, and -1s are included in spots that aren't filled.

An ASCII Image buffer

That's basically just a two dimensional array of termbox.SetCell calls.

Would have to be in a separate package so that everyone could include it

Would have NewTermboxBuffer(width, height), a Size(), and SetCell.

Then a Render(x, y) which would render into TermBox.

This would allow more dynamic rendering in CLI render mode.

Handle long state strings

If it's too long to fit, figure out how wide the longest string printed so far is, give a few spaces of padding, draw a | line, and then render the rest. Repeat.

A PlayerIndex property type for States

A top-level expected type. That would allow us to understand the intent, and verify that it's never out of bounds (except for maybe -1 if it's no one's turn)

Create a DefaultDelegate

That just has no-ops for all methods. That way you can easily embed it in your struct and just override the methods you want.

Introduce the notion of Modes in cli

That install the various key bindings when the mode is entered. This will help rationalize the keybinding logic, which currently is very ad hoc...

Necessary to fix #26 (without going crazy, at least)

Rename State.Payload

The first thing is actually more the StateWrapper, and the inner thing is actually the State.

Because win state is not in State, hard to write logic around

For example, if you want to do a Renderer func, you can't print if the game is won or not, because the state object doesn't know. And legal methods on a move can't know if the game is already over.

It's probably OK to have it be special--renderer funcs can't show it, and legal can't know it, but the cli can render winning state itself, and ApplyMove will always do a check for the game being won anyway.

Associate Moves with a Game

We want a way for Game or CLI to be able to enumerate moves, ideally with a description, and create a new one.

One way is to have all Moves have a Copy(). So we keep a list of instainiated base moves of all of the types, and when seeing which ones are legal, we go through and Copy() them. Then they can all have a Description() and Name() field, and InitalizeWithState(payload) on them.

Another approach is to have game just have a list of functions that take a state payload and return an initialized move or nil if the game state doesn't permit one to exist. Moves could still have Description() and Name(), and then we'd only be able to list ones that were at least vaguely plausible at that state in the game.

The latter seems cleaner, although there are definitely some instances when I want to enumerate all of the moves in the game, even if I can't do anything with them right now.

So maybe it's Move.Copy()InitForState(state) error. Where if it returns error that means it's not even conceivable right now (let alone legal).

... Is there a distinct concept of "Conceivable at this game state" and "Legal at this game state"? The former is only useful to the extent the move is not yet filled in with all of its fields yet, but otherwise is basically the same. Conceivable seems like it could be an albatross, because it's basically a bespoke version of Legal(), which will be finicky logic.

OK, so it's a list of instantiated Moves(). We can enumerate them for Name() And Description(). If we find one we like, we call Copy().DefaultsForState(state), which always does the best it can to set the properties it can default reasonably. (like TargetPlayerIndex == CurrentPlayer)

Necessary to fix #26

Consider a code-gen approach

Write now we have some interfaces that do things and at various point library users need to cast back and forth and do some weird implementations. Which things are structs and which things are interfaces is seemingly random, which makes everything seem pretty messy.

Another approach would be to do a code-gen approach with marked-up structs, like in https://github.com/go-reform/reform . This is very hard to get working and test, and seems like it could be very finicky. But it's worth considering an option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.