{"action":"created","issue":{"url":"https://api.github.com/repos/pickten/Conquest/issues/1","repository_url":"https://api.github.com/repos/pickten/Conquest","labels_url":"https://api.github.com/repos/pickten/Conquest/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/pickten/Conquest/issues/1/comments","events_url":"https://api.github.com/repos/pickten/Conquest/issues/1/events","html_url":"https://github.com/pickten/Conquest/issues/1","id":190883536,"number":1,"title":"Implementation details","user":{"login":"pickten","id":6465870,"avatar_url":"https://avatars.githubusercontent.com/u/6465870?v=3","gravatar_id":"","url":"https://api.github.com/users/pickten","html_url":"https://github.com/pickten","followers_url":"https://api.github.com/users/pickten/followers","following_url":"https://api.github.com/users/pickten/following{/other_user}","gists_url":"https://api.github.com/users/pickten/gists{/gist_id}","starred_url":"https://api.github.com/users/pickten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pickten/subscriptions","organizations_url":"https://api.github.com/users/pickten/orgs","repos_url":"https://api.github.com/users/pickten/repos","events_url":"https://api.github.com/users/pickten/events{/privacy}","received_events_url":"https://api.github.com/users/pickten/received_events","type":"User","site_admin":false},"labels":[{"id":486224932,"url":"https://api.github.com/repos/pickten/Conquest/labels/feature","name":"feature","color":"84b6eb","default":false},{"id":486224934,"url":"https://api.github.com/repos/pickten/Conquest/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true},{"id":486224937,"url":"https://api.github.com/repos/pickten/Conquest/labels/question","name":"question","color":"cc317c","default":true},{"id":486267067,"url":"https://api.github.com/repos/pickten/Conquest/labels/rules","name":"rules","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-22T01:27:26Z","updated_at":"2016-11-22T16:53:27Z","closed_at":null,"body":"Let's use this issue to talk implementation & git setup. For now, players and graphics is irrelevant, so to hell with that.\r\n\r\nI've created a branch `pieces` for the work I'm doing on pieces; @PlatyPrograms should do similar for `map`; use `git branch map; git checkout map; git pull origin map; [WORK]; git push origin map` to use it (as opposed to `git pull origin` and `git push origin`), and the github to view (or you could switch back & forth but github is good/easier for visualization). We can merge the branches to master when they are closer done. Also, btw, you should click \"Watch\" at the top right of the page to watch the repo and get notifs of most changes.\r\n\r\nIn terms of implementation details, `C` lacks generics, so we'll not have much overlap AFAIK.\r\n\r\nSO FAR, I'm assuming the existence of a generic `nodeType` to match `pieceType` that I'm using. Should be trivial to add.\r\n\r\nLoosely, `piece`s have moves left and what they carry; `pieceType`s have max allowed moves and a bunch of `pieceAction`s and `nodeAction`s that represent whether they can by default do a particular action (e.g. travel to a given `nodeType`, carry a given `pieceType`), and all relevant exceptions (currently as an array, but soon an RB tree). Also some `intPieceAction`s, which have extra int data for each.\r\n\r\nI'm going to guess the map will be similarly `node`s containing structural and game info, each containing a `nodeType` representing land/sea/space/other types. Ports will actually be simple, as they are just `Land` nodes linked to `Water` nodes.\r\n\r\nUp to now, things should be reasonable, but there's two crucial things left: getting all this stuff from a file (sidenote: Haskell's parsing is great, and FFI should be simple to set up, so that's viable if this turns out to be complex) and figuring out what the allowable actions should be.\r\n\r\nHere's what I have for actions ATM. Is anything missing or whatnot? One that ocurred to me is multimount (mounting a mounted unit). Worth adding?\r\n\r\n| action | node/piece | notes |\r\n| ------- |-------------- | ------ |\r\n| kill | piece | kill the piece |\r\n| carry | int+piece | carry the piece (max & weight of each piece)\\* |\r\n| combo | piece | max moves resets when killing this piece modulo recapture |\r\n| recapture | int+piece | when killing this, can be recaptured (and delay) |\r\n| travel | node | travel to the node |\r\n| mountKill | piece | can kill the piece and mount it (e.g. land vs ship capturing in Conquest) |\r\n| dismountKill | piece | can kill the piece when dismounting |\r\n\r\n\\* I could probably split this up into an array of \"carry types\" each with `intPieceAction`s, but that's probably stupid"},"comment":{"url":"https://api.github.com/repos/pickten/Conquest/issues/comments/262297057","html_url":"https://github.com/pickten/Conquest/issues/1#issuecomment-262297057","issue_url":"https://api.github.com/repos/pickten/Conquest/issues/1","id":262297057,"user":{"login":"pickten","id":6465870,"avatar_url":"https://avatars.githubusercontent.com/u/6465870?v=3","gravatar_id":"","url":"https://api.github.com/users/pickten","html_url":"https://github.com/pickten","followers_url":"https://api.github.com/users/pickten/followers","following_url":"https://api.github.com/users/pickten/following{/other_user}","gists_url":"https://api.github.com/users/pickten/gists{/gist_id}","starred_url":"https://api.github.com/users/pickten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pickten/subscriptions","organizations_url":"https://api.github.com/users/pickten/orgs","repos_url":"https://api.github.com/users/pickten/repos","events_url":"https://api.github.com/users/pickten/events{/privacy}","received_events_url":"https://api.github.com/users/pickten/received_events","type":"User","site_admin":false},"created_at":"2016-11-22T16:53:27Z","updated_at":"2016-11-22T16:53:27Z","body":"Some random data structure talk:\r\n---\r\n\r\nSo I'm working on three general data structure files (`rbtrees`, `stack`, and `linkedlist`) which will be generic (handled via macros) implementations of red-black trees, stacks, and linked lists; the former requires `struct RBTREE_TYPE` to contain an `int id`, the latter two a `struct STACK_TYPE` and `struct LINKED_TYPE` with no restrictions (both default to a placeholder with `int id` if needbe and `void* item`).\r\n\r\n`stack` and `linkedlist` are pretty much finished, so I'll commit them to `pieces` soon; `rbtrees` is pretty messy so not for now; I'm steadily going through the wikipedia implementation to see what I can adapt. It's possible I'll have to give nodes  `parent` pointers, but I'd really rather avoid it and use a stack-based implementation because it makes the trees a bit simpler to create. This *should* be doable, but I've also not used rb-trees so who knows.\r\n\r\nOne pain point worth watching out for is that they have guards against multi-inclusion for each type input, but the relevant flags need to be changed at the call site. Thankfully, `stack` knows that it's called in `rbtrees` generically, and will apply the flag in `rbtrees` and likewise for `linkedlist` and `stack` and `rbtrees`. There may be a better approach, but I don't know of any ATM. In any case, we can feel free to rely on them but know that we'll have to do, e.g. `#define LINKED_H_player 1` when we set up the `player` linked list. Basically, what's going on is that the usual `#ifndef ... #define ... #endif` pattern fails since you'd need to expand macros before checking `#ifndef` etc, but this is impossible. So instead, there's a bit of jankiness and we use `#if NDEF(AFFIX(...)) ... #endif`, where `NDEF` and `AFFIX` are some custom macros (in a file `genericmacros` that I'll also commit) exclusively useful for this. This works since `#if` takes any expression it can evaluate at compile time (thus allowing macros), but also means you can't rely on `defined` (which is how `#ifndef` works) and need a custom way to tell if stuff is defined. Now, apparently if the flag isn't defined it'll evaluate to `0`, so `NDEF` is just checks `== 0`.\r\n\r\nIn summary, to hell with generics, macros and especially `#ifndef`; to create data structures and core functions for a type, you need to do, e.g. \r\n\r\n```c\r\n#ifndef LINKED_H_player /* this is still ok since it's not generic */\r\n#define LINKED_TYPE player\r\n#include \"linkedlist.h\"\r\n#undef LINKED_TYPE\r\n#define LINKED_H_player 1\r\n#endif\r\n```\r\n\r\nand no, I literally cannot make a macro to do that."}}
{"actor":{"display_login":"pickten"}}