This is a list of my take­aways from the excel­lent talk between Erik Mei­jer (of the LINQ and Rx fame), Carl Hewitt (cre­ator of the Actor model) and Clemens Szyper­ski, on the Actor model.

 

Dis­claimer : this con­ver­sa­tion revolves around the con­cep­tual model of an actor, as opposed to spe­cific imple­men­ta­tions of the Actor model.

 

What is an actor?

An actor is the fun­da­men­tal unit of com­pu­ta­tion which embod­ies the 3 things – pro­cess­ing, stor­age and com­mu­ni­ca­tions – that are essen­tial to computation.

One actor is no actor, they come in sys­tems, and they have to have addresses so that one actor can send mes­sages to another actor.

 

Beyond the high-level abstrac­tion, an actor has a num­ber of properties:

  • Every­thing is an actor
  • An actor has a mailbox

 

Since a mail­box is also an actor, it too will have a mail­box, and so the recur­sion begins! This recur­sion ends with axioms.

 

Axiom

When an actor receives a mes­sage it can:

  • Cre­ate new actors
  • Send mes­sages to actors it has addresses before
  • Des­ig­nate how to han­dle the next mes­sage it receives (e.g. state)

and that’s it!

“Con­cep­tu­ally, mes­sages are processed one at a time, but the imple­men­ta­tion can allow for con­cur­rent pro­cess­ing of mes­sages.” – Carl Hewitt

 

This is not the same as a con­tin­u­a­tion, which is the lambda expres­sion that you exe­cute after doing the cur­rent one and is a con­cept for sin­gle threaded processing.

 

Whilst con­cep­tu­ally mes­sages are processed one at a time, the imple­men­ta­tion can allow for con­cur­rent pro­cess­ing of mes­sages. For instance, a fac­to­r­ial actor which has no state and will process each mes­sage the same way can process an arbi­trary num­ber of mes­sages at the same time.

 

An actor can also send mes­sages to itself (i.e. recur­sion), and to avoid dead­locks we have the notion of a future.

The idea of a future is that you can cre­ate an actor with any result whilst it’s still being com­puted. For instance, you can cre­ate a future for fac­to­r­ial 100m, which will take a long time to com­pute, but you can have the future straight away and pass it around.

 

Addresses

The address of an actor is not the same as its iden­tity because:

  • One actor can have one address for many actors if you’re repli­cat­ing behind the scenes
  • One actor can have many addresses that for­ward to one another (via proxy actors)

hence there’s a many-to-many rela­tion­ship between actors and addresses.

 

With actors, all you have are addresses, which doesn’t tell you whether you have one or many actors behind those addresses. The same notion of addresses also applies to the web, e.g. whilst search­ing on google.com it’s not the same actor that are pro­cess­ing your requests every time.

 

Addresses are sim­i­lar to capa­bil­i­ties, but is a much clearer name for a capa­bil­ity because it tells you exactly what you are allowed to do – send­ing mes­sages to it, which is its only capability.

“If you can main­tain the integrity of addresses, you get capa­bil­i­ties for free” – Carl Hewitt

 

Mes­sages

Mes­sages are like ‘pack­ets’ in the inter­net, they obey the same rule as pack­ets for effi­ciency rea­sons – mes­sages are received in any order because it’s more expen­sive on the sys­tem to enforce the order­ing constraint.

 

Mes­sages are also deliv­ered on a best-efforts basis, which when cross­ing machines this means they are per­sisted on some stor­age and can be resent if receipt acknowl­edge­ment is not received. But if the source machine is ter­mi­nated before the resent hap­pens then the mes­sage is lost.

 

Mes­sages sent between actors are deliv­ered at most once, and may take a long time to arrive depend­ing on dis­tance and net­work latency between the actors (e.g. mes­sage in a bottle..).

 

Chan­nels

“There are no chan­nels” – Carl Hewitt

Instead, the actors talk directly to one another.

 

The prob­lem with a chan­nel is that if you’re try­ing to send a mes­sage to two recip­i­ents only one of them will receive the mes­sage, unless you go through with the over­head of a two-phase com­mit.

 

As an imple­men­ta­tion detail, you can imple­ment a chan­nel (which will be another actor in the sys­tem) if you want, but it’s not part of the con­cep­tual model.

 

Non­de­ter­min­ism vs Indeterminism

A quick recap on tur­ing machines, which is the­o­ret­i­cal machine that defines com­putabil­ity. It can be thought of as a sim­ple com­puter that reads and writes sym­bols one at a time on an infi­nitely long tape by fol­low­ing a set of rules. It deter­mines what to do next accord­ing to an inter­nal state and what sym­bol it cur­rently sees on the tape.

In a deter­min­is­tic tur­ing machine, given the cur­rent state and sym­bol it spec­i­fies only one action to be per­formed. For exam­ple, “if you are in state 2 and you see an ‘A’, write a ‘B’ and move left”.

In a non­de­ter­min­is­tic tur­ing machine (NTM), given the cur­rent state and sym­bol it may spec­ify more than one action to be per­formed. For exam­ple, “if you are in state 2 and you see an ‘A’, write a ‘B’, move right and switch to state 5”.

 

In a NTM, the state of the com­pu­ta­tion is fixed, and can be proved that a state machine model of com­pu­ta­tion has to have a bounded non­de­ter­min­ism (i.e. it halts after a bounded num­ber of steps, hence has a bounded num­ber of pos­si­ble configurations).

With the Actor model, you have a configuration-based model of com­pu­ta­tion (based on mes­sages that are received, which are dynamic as opposed to fixed), which is more pow­er­ful because it incor­po­rates com­mu­ni­ca­tion. This configuration-based model gives you inde­ter­min­ism, which is what hap­pens when things work them­selves out.

 

Con­trary to pop­u­lar believes, tur­ing machine is not the only thing that defines com­putabil­ity, and inter­ac­tions with an open envi­ron­ment cer­tainly changes what com­pu­ta­tion means and is the dif­fer­ence between non­de­ter­min­ism and indeterminism.

 

Syn­chro­niza­tion

Syn­chro­niza­tion is built into the Actor model because mes­sages can be received one at a time by an actor.

In a check-in account exam­ple where many par­ties can cash-in or with­draw from the account, sup­pose the cur­rent bal­ance is £2, and one per­son tries to with­draw £7 whilst another tries to cash-in £8, the out­come is inde­ter­mi­nant based on the order in which the mes­sages are received by the actor.

This is where the arbiters come in.

 

Arbiter

“The arbiter decides, and there’s noth­ing before the arbiter decides” – Carl Hewitt

Given an arbiter, you can have mul­ti­ple inputs (e.g. I0 and I1) into the arbiter at the same time, but only one of the pos­si­ble out­comes (e.g. O0 or O1) will come out on the other end.

image

The arbiter is what gives us inde­ter­min­ism, it can take an arbi­trary amount of time (with the prob­a­bil­ity of inde­ci­sion decreas­ing expo­nen­tially over time) to come to a deci­sion but it must decide.

 

Imple­men­ta­tion

There’s an art to the imple­men­ta­tion of the Actor model in pro­gram­ming lan­guages and there are many ways you can make mis­takes in the imple­men­ta­tion – by vio­lat­ing some of the fun­da­men­tal prin­ci­ples or by not tak­ing them seriously.

 

The Actor model is not the same as tail recur­sive calls (because it can change the state for the next mes­sage received) or event loops (because of the optimizations).

 

 

I hope I’ve done the talk jus­tice with these short notes I’ve taken and that you find them use­ful as you no doubt watch the talk over and over as I had, and before we go I’d like to leave you with yet another great quoteSmile

“We don’t know much, and some of it is wrong” – Carl Hewitt

Share

This is so good I keep going back to it, so to save myself and you the has­sle of search­ing for it every time I thought I’d share it here on my blog, enjoy! Smile

Share

Another Thurs­day had gone by and yet another slot has been added to Jack­potJoy Slots, this time it’s a griz­zly themed 50-line slot called Bear Cubs!

image

The main slots game is pretty straight for­ward, albeit being 50-lines instead of the typ­i­cal 25, where things really become inter­est­ing is the bonus fea­ture. When you land 3, 4 or 5 bonus sym­bols on the reels you’ll trig­ger the Golden Cub Spins bonus game with 5, 8 or 12 free spins respectively.

At the start of the bonus game the player has to choose one of the three griz­zlies as his golden cub, and over the course of the bonus game any time a Wild sym­bol or the golden cub’s sym­bol lands on the reels they’ll be locked in place for the reminder of the bonus game and act as Wilds.

The video below will hope­fully give you a pretty good idea of how the bonus game works and as you can see, it’s pos­si­ble to amass a mas­sive win from the bonus game, even on a small wager!

Share

In F# you can write an exten­sion method like this:

image

Whilst this will work per­fectly fine in your F# code, the exten­sion method will not be vis­i­ble to any C# code using the File­Info type because F# and C# com­piles exten­sion meth­ods differently.

To make C#-compatible exten­sion meth­ods in F#, here’s what you need to do instead:

image

That’s it, just fol­low these 3 sim­ple steps and you’re done:

  1. wrap the exten­sion meth­ods inside a class dec­o­rated with the [<Exten­sion>] attribute
  2. write the exten­sion meth­ods as sta­tic mem­bers where the first argu­ment is of the type which should be extended (like how you would write an exten­sion method in C#)
  3. mark the exten­sion meth­ods with the [<Exten­sion>] attribute
Share

It has been in the works for a long time but we’re excited to announce that Here Be Mon­sters is now offi­cial open for beta!

image

The best way I can think of to describe Here Be Mon­ster (HBM) is a genre-bending soft-core MMORPG. It com­bines ele­ments from many pop­u­lar gen­res of social games and gives you a world, based on our own, where you can explore, talk to oth­ers, for­age for food and build traps to catch bad-ass monsters!

Story

Set in medieval time, in a par­al­lel uni­verse where local folk­lores and mon­sters are real (oh yeah, big­foot and were­wolves are real alright!) and live peace­fully with the native inhab­i­tants of the land, that is, until the star­i­ums started falling from the sky..

These warm, pul­sat­ing mete­orites have caused plants to mutate, and mon­sters to become cor­rupted, turn­ing them against those they once lived with peacefully..

image

image

Nobody knows the ori­gin of these star­i­ums and why they started falling, sev­eral rumours are cir­cu­lat­ing amongst the con­spir­acy the­o­rists that the ‘star­ium fall’ sym­bol­ises the rise of a dark power..

For the time being though, the Min­istry of Mon­sters are not tak­ing these rumours too seri­ously and instead, focus­ing on the cap­tur­ing and cur­ing of cor­rupted mon­sters to return them back to their for­mer state of mind.

Badly out­num­bered and under-resourced, the Min­istry is look­ing for new recruits to join their ranks to help trap way­ward monsters.

This is where you come in, as a fresh recruit, you’ll undergo stren­u­ous (don’t worry, it’s not that not bad Winking smile) trap­per train­ings to quickly get you up to speed and equipped with all the knowl­edge and tools you need to start trapping!

Explor­ing

If you room into the world map, you’ll see that it’s full of places (spots and towns) rom the real world where you can travel to.

Some of these are sim­ple spots where you can go and for­age fruit trees, catch but­ter­flies, do a bit of fish­ing or place down your trap to catch what­ever mon­sters that are around the area.

Whilst for­ag­ing fruit trees, occa­sion­ally you might also find seeds which you can take back home and grow in your home­stead so that you can start pro­duc­ing fruits from the com­fort of your own backyard!

All the items that you find in your travel can be used in other ways, e.g. man­gos for­aged from a mango tree can be squeezed into Mango Juice or com­bined with 2 x Chicken Egg and 1 x Sugar into a Mango Bucket which, whilst tastes dis­gust­ing.. is a pow­er­ful bait for Ahool, a giant bat-monkey from the islands of Java.

image image image

There are also a num­ber of towns dot­ted around the world (e.g. Lon­don, Nan­Jing, Musumba, etc.) which are hubs where you can find lots of NPCs (non-playable char­ac­ters) who will give you quests and errands to per­form and occa­sion­ally they will also tell you inter­est­ing back­sto­ries about them­selves and how the star­i­ums have affected their local area.

For now though, only Lon­don is open for visit dur­ing the early Beta, but we’ll open up the other cities and their respec­tive quest lines in the very near future, so stay tuned on our offi­cial fan page for updates!

Farm­ing

Unlike other games which focuses on the farm­ing and resource man­age­ment aspect, the pur­pose of farm­ing in HBM goes far beyond the sim­ple loop of plant –> sell pro­duce –> buy new seeds –> plant. In HBM, the goods that your crops pro­duce is part of a big­ger ecosys­tem where they can be com­bined with other items in the game to make baits for mon­sters, a nice cake for you to eat, or sim­ply sold for some coins.

For any­one who’s famil­iar with games such as Far­mVille or Har­vest Moon, the farm­ing aspect of HBM will look imme­di­ately familiar:

  • there are farm plots for you to plant seeds and grow crops for har­vest­ing after some time
  • you can have ani­mals who pro­duce resources (wool, milk, etc.) periodically
  • there are trees and fruit trees you can chop or har­vest respectively
  • there are rocks which you can mine for stones and rare gems
  • you can build spe­cial resource-producing build­ings (well, bee-hive, etc.) which you can har­vest periodically

Cook­ing

Cook­ing is closely tied to farm­ing and other activ­i­ties in the game, the pro­duce from your crops often act as ingre­di­ents for cook­ing recipes. E.g. to make a BBQ Beef, you first need to grow and har­vest Olives in order to make Olive Oil, but you also need a por­tion of Raw Beef which (unfor­tu­nately..) you only get by grind­ing a Cow in your workshop:

image image image

As another exam­ple, here’s a short video that shows how you can make a Roast Mut­ton in the game:

All and all, the cook­ing mini-game is fun and engag­ing, and depend­ing on the recipe can be chal­leng­ing and require plenty of plan­ning to acquire all the nec­es­sary ingredients!

Trap­ping

Trap­ping is a key part of the game and is closely aligned with the rich sto­ry­line that runs through­out the game.

There are essen­tially three aspects to trapping:

  1. Mon­sters, there are 95 mon­sters in the game right now and as we expand the game there will be many more to come! All the mon­sters are based on local legions and folklores.
  2. Traps
  3. Baits, in order to catch a mon­ster you first need to lure it to your trap, and dif­fer­ent mon­sters have dif­fer­ent pref­er­ences (e.g. gnomes like potato) so whilst you can use just about any­thing as bait you’ll have the most suc­cess attract­ing the mon­ster you’re after when using one of its pre­ferred baits.

Each mon­ster has a set of stats which tells you how pow­er­ful this mon­ster is, each trap also has a set of stats and is usu­ally strong against one or more types of mon­sters (air, land or water).

image image image

Take my hunt for Veg­etable Lamb for instance, one of the most hor­ri­fy­ing mon­sters in exis­tence, I decided to use Fox­gloved Mut­ton as bait in my Tar Pit trap which is very strong against the Veg­etable Lamb.

image image

So first, I cooked some Fox­gloved Mut­ton using Mut­ton Chops (from my poor lit­tle lamb..) and some Fox­glove which I had painstak­ingly col­lected from all over Europe. Once I had some bait handy, I tele­ported to where I had placed my trap, set my bait and hoped lady luck is smil­ing at me today!

As you can see from the video, I failed at my first attempt, a Shishi had shown up at my trap, which is ill-equipped to deal with it, and took a bite of the bait I had placed for the Veg­etable Lamb…

Such is the life of a trap­per, you do every­thing right and then the wrong mon­ster shows up at your trap! But worry not my friends, it took a cou­ple of attempts but even­tu­ally I was able to lure my tar­get into my trap and cap­ture it!

image

I won’t go into too much details in this post but there is much more that goes on behind the scene for trap­ping in terms of the dif­fer­ent types of mon­sters and the rel­a­tive strengths and weak­nesses of each trap, not to men­tion the whole craft­ing aspect of the game which is nec­es­sary to acquire stronger, more pow­er­ful traps that are capa­ble of cap­tur­ing the strongest of monsters.

With that, I hope you’ve enjoyed my intro­duc­tion to Here Be Mon­sters, and I look for­ward to see­ing you in the game!

image

Share