Comments (6)
- yes, my code has been missing some reorganization. I think all of our data structuring could use a rethink to avoid hassle, coupling, and redundancy.
- I agree in principle but i think that the board does not contain extranous information, maybe if it changes from its current definition.
- i think that should be possible right now quite easily, i can try it out next fine i code.
- i think both are valid but mutability should only be for performance. it certainly looks like a monadic pattern
from flixball.
Here's my current thought on GameState etc.
GameState currently has
states: Map[PlayerId, (Int32, Map[String, String])]
positions: Map[PlayerId, Position]
board: Board
And Board
contains Tile
s which contain Player
s which contain MoveLogic
I think we should essentially get rid of Player
and instead store the relevant data in the maps.
So GameState
becomes (states, positions, logics, board)
. And things dealing with Player
instead deal with PlayerId
.
Then we separate GameState into PublicState
and PrivateState
. This way we keep the states and logic of all the AIs separate from each other. So the getMove
function for AIs has the signature: (Int32, Map[String, String]) -> PublicState -> ((Int32, Map[String, String]), Move)
from flixball.
I agree generally.
- I still think the MoveLogic should be regioned, which removes the Int32, Map... and States map which simplifies things.
- Our running of the board has become stateful but with the above change, why is it stateful? the positions map is just there for performance right? it can be computed from the board
from flixball.
* I still think the MoveLogic should be regioned, which removes the Int32, Map... and States map which simplifies things.
Yes, I agree if it can be made to work, but I am not yet convinced it can work :)
* Our running of the board has become stateful but with the above change, why is it stateful? the positions map is just there for performance right? it can be computed from the board
Positions is indeed redundant. I don't totally understand what you mean by stateful though. Here I'm mostly just rearranging where the data is located.
from flixball.
I've run into a problem with the Impure to Pure MoveLogic function.
type alias MutMoveLogic[m: Region -> Type, r: Region] =
(GameState, PlayerId, m[r]) -> Move \ r
def toMoveLogic(logic: MutMoveLogic[m, r]): MoveLogic with State[a] = {
def f(gs, id, state) = region reg {
// call logic() with conversions
}
}
The issue is that here, we want the r
of MutMoveLogic[m, r]
to unify with reg
. But r
is already bound by the function. For example we could call toMoveLogic
with logic: MutMoveLogic[T, Static]
which would never unify with reg
.
What we really need is a rank-2 type, so MutMoveLogic
is instead MutMoveLogic[m: Region -> Type] = forall r, (GameState, PlayerId, m[r]) -> Move \ r
. But Flix doesn't have rank-2 types, so we need some kind of workaround.
from flixball.
I've run into a problem with the Impure to Pure MoveLogic function.
type alias MutMoveLogic[m: Region -> Type, r: Region] = (GameState, PlayerId, m[r]) -> Move \ r def toMoveLogic(logic: MutMoveLogic[m, r]): MoveLogic with State[a] = { def f(gs, id, state) = region reg { // call logic() with conversions } }The issue is that here, we want the
r
ofMutMoveLogic[m, r]
to unify withreg
. Butr
is already bound by the function. For example we could calltoMoveLogic
withlogic: MutMoveLogic[T, Static]
which would never unify withreg
.What we really need is a rank-2 type, so
MutMoveLogic
is insteadMutMoveLogic[m: Region -> Type] = forall r, (GameState, PlayerId, m[r]) -> Move \ r
. But Flix doesn't have rank-2 types, so we need some kind of workaround.
yea I had this problem too. difficult to solve. In my attempt, I added a region argument to toMoveLogic such that the caller, which hopefully can instantiate the region type parameter, can make them have the same region.
from flixball.
Related Issues (20)
- `Board.players` and `Board.playerMap` should be merged
- pull `runBoard` out of `Display` HOT 1
- implement smart search and destroy HOT 3
- Game modes HOT 3
- The shape of AiState HOT 5
- Add rotation dimension to pathfinding
- Basic game mode
- Command line options HOT 1
- refactor: separate GameState and the AIs HOT 10
- JSON management
- refactor: add a Core folder HOT 1
- doc: create `style.md` HOT 1
- docs: create `innovation.md`
- Expand CONVENTIONS.md HOT 1
- Make tests for config parsing
- More precise error messages for config
- Decide on edge-of-board rules HOT 1
- AI / map specification HOT 1
- Use "reasonable excuse" idea for unsafe functions.
- CI use scripts from flix-action-templates
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flixball.