Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Village

I seem to be starting new projects every day now x.x
Village is an esoteric programming language. You are a very forgetful village chief, so you write down what you plan to do that day on a sheet of paper, which apparently has line numbers. I did all of this today, so don't expect too much.

Here's some example code:

Code:
Note: You a a super forgetful chief of a village, who wants to
Note: get things done and writes things down in the order you
Note: want them to happen. These are your notes for today:

Call for the villager named Alan.
Call for the villager named Bertrand.
Call for the villager named Charles.
Call for the villager named Dennis.

Tell Alan to make a blueprint for a structure that requires 10 wood and 5 stone.
Tell Charles to gather 10 wood.
Tell Dennis to mine 6 stone.

Note: This doesn't count as a command, it's a comment, and neither do
Note: blank lines. Note that the "Note:"'s are case insensitive.

Note: While we are waiting, here's a hello world program.
Call for the villager named Edsger.
Tell Edsger to write the text "Hello, world!" on his scroll.
Tell Edsger to post his scroll to the Community Message Board.

Tell Bertrand to build a structure using Alan's blueprint, Charles's wood, and Dennis's stone.

Tell Dennis to mine 5 stone.

Note: Also, if you call villagers using the wrong pronoun,
Note: you will have problems.
Note: this errors, because Edsger is male and prefers the use of "his".
Tell Edsger to write the text "example" on her scroll.

Note: If you think I'm being an jerk because of this,
Note: 1, this is a freaking programming language, and 2,
Note: check the comment here: https://github.com/Legend-of-iPhoenix/Village/blob/a8d53ad79a76b9bb129c75165c4a5ad67179e25d/main.js#L89


Here's the interpreter. You can copy the code above and execute it directly. The program, it's super crappy, but I'm super excited about this.

There isn't any documentation yet, but the program above and the source code here should help.
This is pretty awesome!!!!!!!!!!!!
Pieman7373 wrote:
This is pretty awesome!!!!!!!!!!!!


Thanks! I love this project because there is so much for me to explore in it. I'm trying to simultaneously create a game and a programming language, not because it's not necessarily unique, but because it's different, and loads of fun. Totally my kind of game, too. I've been doing command block stuff in Minecraft since 1.6.2

If anyone has ideas for where I should go with this, please tell me! I have a todo list on GitHub, too. Tomorrow, I think I'm going to focus on making it more of a programming language, with conditionals and/or printing variables. It's a delicate balance between the fact that it is supposed to be both an open-ended game and a programming language. The implementation for the conditionals has to be really good.

As always, I am totally, 100% open to people writing my documentation for me.

If anyone somehow didn't notice the pattern in my slightly uncommon villager names, I'm naming them after famous computer scientists or people whose inventions had a significant impact on modern programming languages. If I can't find anyone enough, we default to mathematicians, then to scientists. The names also have to be sound relatively English or be pretty close (Sorry, Ramanujan). (Alan Turing, Bertrand Russell, Charles Babbage, Dennis Ritchie, Edsger Dijkstra,<suggestion needed>, George Boole, etc)

There will also be a collection of female names for gender equality and all that. I call BS, but I wrote all this code using pronouns,

I need suggestions for names an professions of villagers.

Do note that villagers do have predefined occupations, they can't just do anything, and my implementation of occupation selection is not backwards-compatible, if I add more occupations, then they will change. I cannot fix this because I want all of the occupations to be spread out equally, so I want to add as many occupations as possible.

For the curious, a list of current villager names is available by getting the variable "maleVillagers" (eventually a list "femaleVillagers" will be added) in the JavaScript console. You can also get the occupation of a villager by running the JavaScript function "getOccupation(<villager name>)", where "<villager name>" is the name of a villager in the "maleVillagers" array.
Wow, that's quite the program! Stop making these cool projects, you make me look like a chump. Razz
You could probably teach someone the concepts of programming if you developed this right!
I think "TheLastMillennial" is pretty good English scientist name. Razz
No, SM84CE is a better scientist name, and I even have glasses!
***SM84CE hides

I haven't checked it out yet, but based off of the sample you posted, I think I get the basics...
I did it! I implemented conditionals. Here's how they work.

Syntax: Ask [villager name] if [he/she] has [quantity] [item type].

That's a little weird, so here's an example: (Oh yeah, I added a female villager, Ada, named after Ada Lovelace)


Code:
Call for the villager named Ada.

Ask Ada if she has any stone.
 - If she doesn't:
 - Tell Ada to write the text "I do not have stone" on her scroll.
 - If she does:
 - Tell Ada to write the text "I have stone" on her scroll.
Tell Ada to post her scroll to the Community Message Board.


As you can tell, there are a few things going on here.
Call for the villager named Ada. makes Ada available for us to use. Because of my current crappy occupation-selecting script, she is an architect, but that doesn't really matter in this script.

Ask Ada if she has any stone.
This is the conditional statement. Of course, Ada does not have any stone. Only quarrymen can have stone.
The keyword any means more than one. You can also put a number in that conditional, and it will mean "greater than or equal to <number>".

Eventually, I will add the ability to use the word "exactly" before the number, but you can achieve this anyways with clever programming.

Because this is a conditional, we have to increase the indent level.

- If she doesn't:
- Tell Ada to write the text "I do not have stone" on her scroll.
- If she does:
- Tell Ada to write the text "I have stone" on her scroll.

This section of code is the conditional statement "body". The code in here is executed based on how the conditional happened.

I see a rage coming from many programmers in here about what I am going to say in this section, but if you think about if statements in, say, JavaScript, the initial '{' can be viewed as a label to jump to, as can the '{' after the else.

- If she doesn't: and - If she does:
Indent levels in village work like this:

Code:
 -
  +
   *
    -
     +
      *
(and so on)


You don't need to memorize the pattern. If you get it wrong, the interpreter will kindly tell you which one to use.

The " -" before our command indicates that this is the first indent level. The space after the dash is a stylistic thing, it can be omitted.

The If she does: and If she doesn't: are labels that are jumped to if the condition is true or false, respectively. They can occur in any order. If there is only one of them in the conditional statement "body" and it doesn't apply, the entire conditional will be skipped.

If you run the code above, you will notice that only the text "I do not have stone" shows up on the output ("Community Message Board"). The other code beneath the If she does: label was skipped because it did not apply.

The end of any body section is always signified by a decrease in indentation.

This is pretty intuitive stuff, but it's pretty hard to explain in words.

I also added the ability to tell villagers to write down on their scroll how much of an item they have. This allows you to do fun things like this:


Code:
Call for the villager named John.
Tell John to mine 10 stone.
Note: The next three lines are just dummy things, because we need to wait for John to mine his stone.
Call for the villager named Ada.
Tell Ada to write the text " " on her scroll.
Tell Ada to write the text " " on her scroll.
Note: John is done mining stone now!
Tell John to write the text "I have " on his scroll.
Tell John to write the amount of stone he has on his scroll.
Tell John to write the text " stone" on his scroll.
Tell John to post his scroll to the Community Message Board.
Note: Outputs "I have 10 stone"


I also noticed a bug relating to writing text on a scroll (You can't use periods), but this is an easy fix. I need to change literally one line of code, but I can't be bothered because I've been doing this all day and I need to do other things x.x

Fixed! I changed one of the regular expressions I was using. This was one of the few times I wanted to use a greedy operator!
Today, I added conditionals based on text in scrolls and jumps ("Skips").

You can ask a villager if their scroll starts with, ends with, or contains a given text. This conditional works pretty much the same way as the other conditional.

I also added jumps, and as a result, loops.

Use the syntax Skip to step <step>, where <step> is a line number in the program. You can use "line" instead of "step", if that floats your boat, but I like to think of it as a list of instructions that the chief follows going through the day.

Here's a demo program showing off jumps, loops, and scroll conditionals:

Code:
Call for the villager named Ada.
Call for the villager named Charles.

Tell Charles to harvest 1 wood.
Note: Wait the required three commands.
Tell Ada to write the text "a" on her scroll.
Tell Ada to write the text "b" on her scroll.
Tell Ada to write the text "c" on her scroll.
Ask Charles if he has 10 wood.
 - If he doesn't:
 - Tell Charles to write the text "0" on his scroll.
 - Note: I do this to pad the single-digit numbers so they are all the same length.
Tell Charles to write the amount of wood he has on his scroll.
Ask Charles if his scroll ends with "16".
 - If it doesn't:
 - Tell Charles to write the text " " on his scroll.
 - Skip to line 4.
Note: if he does, it assumes you wanted to continue running the program

Tell Charles to post his scroll to the Community Message Board.
Note: Outputs:
Note: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16


I also added primitive infinite loop protection, which prevents you from getting stuck in an infinite loop. It limits the amount of time (in total lines of code read) allowed for code execution. I'm going to make the limit customizable.

As always, you can check the new changes out on the Village Interpreter!
Now that I'm done with my break, I can get back to working on Village!

I think I've fixed the problem with predefined villager occupations. You now have to "teach" a villager their occupation.

I'm also instituting a villager limit, which starts at four. Four is exactly enough to build a structure that will increase the villager limit (architect, lumberjack, quarryman, builder).

I also added a new occupation, the farmer. It's not too interesting (all it can do is grow wheat), yet, but I'm thinking of things it could do.

All previous Village programs are INCOMPATIBLE with this new version of village.

Use the command Teach <villager> how to <skill>., where skill is something like mining stone, harvesting wood, growing wheat, drafting blueprints. I'm writing documentation for all of this, but here's some example code. You should get the gist of it from reading it.


Code:
Call for the villager named Ada.
Call for the villager named Alan.
Call for the villager named Ken.
Call for the villager named John.

Note: This errors, because there is not enough space!
Call for the villager named Linus.

Teach Ada how to harvest wood.
Tell Ada to harvest 10 wood.

Teach Alan how to mine stone.
Tell Alan to mine 5 stone.

Teach Ken how to draft blueprints.
Tell Ken to draft a blueprint for a structure requiring 10 wood and 5 stone.

Teach John how to build structures.
Note: now we play the waiting game, for Ken's blueprint...
Tell Ada to write the text "1" on her scroll.
Tell Ada to write the text "2" on her scroll.
Tell John to build a structure using Ken's blueprint, Ada's wood, and Alan's stone.

Note: this is just dummy code, if you were writing an actual program you would be doing stuff here.
Tell Alan to write the text "I have " on his scroll.
Ask Alan if he has any stone.
 - If he doesn't:
 - Tell Alan to write the text "no" on his scroll.
 - If he does:
 - Tell Alan to write the amount of stone he has on his scroll.
Tell Alan to write the text " stone." on his scroll.
Tell Alan to post his scroll to the Community Message Board.

Note: John has finished his structure, so let's try to add another villager.
Note: This doesn't error; we have enough housing.
Call for the villager named Linus.


As always, feel free to test it out here, on the interpreter!
I like this! I do have a question, though. The "Teach" arguments have to be part a specific set, right? It should be obvious, but what of it could learn anything? Evil or Very Mad

Also, when you tell someone to write something on their scroll, and tell the same person to write something different, will they be combined, concatenated or replaced?
I actually haven't tried making any new code or running it because I have other things to do. 0_0 I'll definitely try it out when I get time to though!
jcgter777 wrote:
I like this! I do have a question, though. The "Teach" arguments have to be part a specific set, right? It should be obvious, but what of it could learn anything? Evil or Very Mad

Also, when you tell someone to write something on their scroll, and tell the same person to write something different, will they be combined, concatenated or replaced?
I actually haven't tried making any new code or running it because I have other things to do. 0_0 I'll definitely try it out when I get time to though!


Yeah, it has to be part of a set. You can find the set in occupationTasks in the JS console. Be warned that these are regexes, so yeah.
I added a bunch of fun new commands.

Using these new commands, I wrote a demo program that multiplies two numbers: (note, if you input numbers that are to large, the program will stop because it thinks there is an infinite loop. In the future you will be able to adjust maximum execution time)

Code:
Note: We'll need to expand our capacity before we can do anything.
Call for the villager named Ken.
Teach Ken how to draft blueprints.
Tell Ken to make a blueprint for a structure requiring 30 wood and 15 stone.
Note: The blueprint will increase our capacity by 3, even though we really only need it increased by one. It doesn't affect time, though.

Call for the villager named Alan.
Teach Alan how to harvest wood.
Tell Alan to harvest 30 wood.

Call for the villager named Ada.
Teach Ada how to mine stone.
Tell Ada to mine 15 stone.

Call for the villager named John.
Teach John how to build structures.
Tell Alan to write the text '...' on his scroll.
Tell John to build a structure using Ken's blueprint, Alan's wood, and Ada's stone.

Note: +------------------------------+
Note: |Change these numbers as input.|
Note: +------------------------------+
Tell Ada to mine 10 stone.
Tell Alan to harvest 5 wood.

Note: Now we do some init stuff while we wait for the extra capacity.

Tell Ken to clear his inventory.
Note: To decrement (decrease by one) Alan's wood, we'll create a blueprint requiring 1 wood.
Tell Ken to make a blueprint for a structure requiring 1 wood and 0 stone.
Note: When we build a structure using this blueprint, it will use one of his wood.

Note: We need one more command until the housing limit increases but we can't do anything until it does, so I waste a command.
Tell Alan to write the text '...' on his scroll.
Note: The housing limit just increased, so more init can happen.

Note: This is the "accumulator". He'll hold our result.
Call for the villager named George.
Teach George how to mine stone.

Note: Init over, starting the actual multiplication routine.

Note: this will decrement Alan's wood, and will leave Ada's stone unaffected.
Tell John to build a structure using Ken's blueprint, Alan's wood, and Ada's stone.

Tell Ada to double her stone.
Tell Alan to write the text '1' on his scroll.
Tell Alan to write the text '2' on his scroll.
Tell Alan to write the text '3' on his scroll.
Tell Ada to give George half of her stone.

Ask Alan if he has any wood.
 - If he does:
 - Skip to step 43.

Note: Output!
Tell George to write the amount of stone he has on his scroll.
Tell George to post his scroll to the community message board.


This is a very large program, but it's super simple. Ported to TI-BASIC, it looks like this: (comments show what parts of the program correspond to that particular line of TI-BASIC.)

Code:
10->A //"Tell Ada to mine 10 stone."
5->B // "Tell Alan to harvest 5 wood."
0->G // "Call for the villager named George."  "Teach George how to mine stone."

While B
B-1->B //"Tell John to build a structure using Ken's blueprint, Alan's wood, and Ada's stone."
2*A->A // "Tell Ada to double her stone"
C+A/2->G:A-A/2->A // "Tell Ada to give half of her stone to George"
End // "Ask Alan if he has any wood." "If he does: Skip to step 43."

Disp G // "Tell George to write the amount of stone he has on his scroll." "Tell George to post his scroll to the Community Message Board"


Of course, this is very bad TI-BASIC code (it can be optimized to Disp AB), but it is designed to show how the Village program works.

Village is supposed to be a language where everything is a workaround. I'm trying to set up as many obstacles as I can while still making it possible to do anything. I think that the majority of the fun for anyone programming in Village will come from overcoming these obstacles. At least, that's the fun for me Smile

To expedite my documentation writing, I'll be using these syntax conventions (it comes from this):
<foo>: Mandatory argument.
{foo|bar|baz}: Choose exactly one of foo, bar, or baz.
[foo]: Optional argument.

Here are the commands I added:

Tell <villager> to {triple|double} {his|her} <item type>.[
Pretty self-explanatory.

Tell <villager> to give <other villager> {half|a third|one third|all} of {his|her} <item type>.
The amount gifted is rounded down (ex. 9/2 = 4). The villagers have to be of the same occupation.

Tell <villager> to {empty|clear|dispose of} {his|her} inventory.
Clears that villager's inventory. Useful when you want to reuse architects.

Ask <villager> if {he|she} has {more|less} <item type> than <other villager>.
If the item type does not apply to a villager's occupation (ex. Ask <lumberjack> if he has more stone than <quarryman>), then the villager automatically has zero. (The above example would always fail. A lumberjack will have 0 stone so he will never have more than a quarryman.)
Never compare the inventories of builders or you are having a bad problem and you will not go to space today.

I implemented some of these commands yesterday two days ago (this just shows you how on top of things I am x.x), and I did a timelapse of me adding them.
https://www.youtube.com/watch?v=nv3cI06p6Vk
This is really cool! I tried it out the other day and it seems to be a cross between an RTS or a Turn-based Strategy and a programming language. Definitely really cool stuff. I always admire the brainpower used when creating and writing in esoteric languages, especially because I couldn't do any of that stuff myself. Great job!
Thanks! With esolangs, the design is usually the majority of the work. Unless your idea is super crazy, it isn't too hard to implement a basic interpreter. I say usually because some of my previous expidentures into esolangs required very little thought. Heck, there's a whole category of languages that are just Brainf*, but with chars substituted.

I want to implement some form of input, as I stated on IRC, but I'm not sure how I will do it. 123outerme suggested a "Decide" statement, which is a great idea, but I fear this will only be good for Boolean input. Because I am constantly thinking back to my fellow code golfers, (some code golf competitions require input to be taken in a certain way) I deem this insufficient.

In order for this language to work, you have to be able to take input and tell a villager to mine/harvest/collect that many of that item type. But I'm not sure how to make this fit in with my "plot".


I've started work on my documentation. I have a lot of the commands done, but not nearly enough to be complete. You can see the current state of the documentation for each command here
This is pretty cool!
mets11rap wrote:
This is pretty cool!


Thanks! Though I have begun to work on other projects, this is still in the back of my head. I'm sure that if I find the time or I get a cool idea, it'll be added right away!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement