Hal9000
As you may know, I am slowly/painfully writing an Elixir book.
There is a code example that I’ve written in Ruby – a simple
robot-type “capture the flag” game. (Not a real game, just a
coding exercise.)
I’m about to port the Ruby code to Elixir. If anyone wants to
look/comment/help, please feel free. (Those who contribute
will be mentioned in the acknowledgements fwiw.)
This repo will be public for at least two days:
https://github.com/Hal9000/vexil
Thanks,
Hal
Trending in Discussions
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
Hey folks,
I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
Hi there! :wave:
@frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
Hi everyone,
I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 27 to 18- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Eiji
It’s not a problem for me, but If it’s possible wrote about when you will have a time for this project, so I do not need wait and I can better manage my time.
My English is not good, but I will try answer your questions:
escript- read this tutorialrest is generated by
mix new vexilcommandIt’s predefined color name. See bunt dependency github project.
No, when I wrote this code I had
Gridstruct (so I found another name for this module), but after some changes this struct was not needed. But now I think it’s much more cleaner, becauseBattlegroundgenerategridand have methods for read and write to it. Of course I can send PR with changed module name if you wwant.AI as a separated Erlang process will decide what to do.
It will ask
Battlegroundmodule if it can do something and depends on results it will callBattlegroundto apply AI decision (for example because AI - here bot - see only cells in specific range, think aboutBattlegroundas game engine).Note: color should be unique for all teams.
Database naming convention for example in simple blog we have:
Postwithtitle,bodyandidCommentwithuser_name,bodyand post_id.So
Teamhascolor(likeid) andBothasteam_color(liketeam_id).I use
Agentto store game data. In previous (not pushed) version I don’t haveAgentand I was need to pass more arguments. For example see where I readmap_last_index. In previous version I need to pass it in lots of functions. I think it’s much more easier to read when we read game data fromAgent.What do you exactly mean?
I added code to make it configurable, so you can easily setup game rules, for example
Bottypes and their count.I think it’s much more easier to modify this code without completely rewrite “game engine”.
Do you know
M.U.G.E.N? It was really configurable. Anybody could add new characters, backgrounds, music and lots more. Lots of fans from lots of communities used this to create own games with for example: characters from other game.I think project like it (but much more simpler - your vexil) should be configurable too. You can add some exercises to implement new features without need to write new game.
Also I read your code in
Rubyand my configuration and it’s implementation is based onsetupmethod inRefereeclass.This method have statically selected data and I split it to configuration (config.exs) and implementation (Battlegroundand it’s utils). See how I place bots based on their number.Do you agree with me?
start_edgefromconfig.exsis based on yoursetupmethod.corneris fromTeamstruct and it’s randomly selected - see&Vexil.Battleground.TeamUtils.random_corner/1method.Note: in configuration I use “human” numbers (people count from 1) and translate it to
Listindex (computers count from 0). So whenstart_edgeis 5 I place bots on 4th index random cell (half on X edge and half on Y edge).Do you have any more questions?
Hal9000
Sorry, very busy week here.
So far:
In mix.exs - why escript, build_embedded, start_permanent ?
In config.exs - why “coral” etc.?
Any reason Battleground shouldn’t be just Grid?
Uncertain how ai will work.
Are you distinguishing between color and team_color? Why?
Does Agent really buy us much here?
I don’t understand what you’ve done in battleground.ex – is the complexity really needed?
I don’t understand all the “edge/corner” stuff in bot_utils and elsewhere.
Hal9000
I don’t understand it all yet. I will look at it tonight after I leave work
and will ask questions.
Eiji
Heh, finally my PR is accepted.
Before I begin work on AI I want to be sure:
Do you understand all from my code?
Whether the code is clear and intuitive for you?
I’m not sure how much implement AI could take for me, but I think I finish it by the end of next week.
Eiji
I added PR with merge commit and now there are no conflicts with your master branch.
Any questions for my code? Something is hard to interpreting?
Eiji
You can delete file that have conflict. In my commit this file is deleted.
Try:
and push changes in your shell and then try submit PR.
Hal9000
I had trouble merging somehow. Couldn’t figure out how to resolve conflict manually.
Not sure what state this is in now.
Eiji
Next example:
In next version AI needs to calculate where to move. To do this AI give question to
Battleground: “Can I move 3 times left and 1 time bottom?”. If true it responds: “Move bot from x,y 3 times left and 1 time bottom.” andBattlegroundshould calculate new position (x and y). Fetch item from grid, remove it (replace with nil) and “move” (replace nil with item - struct - in new coords).Hal9000
This seems reasonable. I will look at it further tonight. Thank you.
Eiji
The main module (to manage grid) is
Vexil.Battleground. It stores grid inVexil.Agentand have functions to manipulate this grid. For example to storeBotorFlagstructure. I wrote some function and split this module to some imports, so:Vexil.Battlegroundimports:Vexil.Battleground.TeamUtils. TeamUtils (like a normal team) importsVexil.Battleground.BotUtilsandVexil.Battleground.FlagUtilsand both of them importsVexil.Battleground.GridUtils.Note: in your Ruby code
FlagextendsBot, so it can move(!). I think it’s not a good to read your Ruby code, becauseFlagwill not move at all.In my code
FlagUtilsimports only functions for calculate position based on corner and spawn item. Ok, but why it’s all forBattleground? It’s simple.BotandFlagdo not need to calculate position from corner. I think my version is easiest to understand (if you know how import works).More, flag do not think and bot do not see full grid, so they should not calculate coords. I know it’s not a bug, but it’s not easy to read - am I wrong?