Skip to content

An Avalon (Resistance) engine for simulating, replaying, or scripting games

Notifications You must be signed in to change notification settings

TokenGnome/Amalon

Repository files navigation

Amalon

An Avalon (Resistance) engine for simulating, replaying, or scripting games

Current use case

Right now the engine can be used to run a non-interactive game using custom deciders (bots).

AvalonGameController *c = [AvalonGameController new];
c.engine = [AvalonEngine engine];
c.engine.delegate = c;
c.bot = [JavaScriptDecider deciderWithScript:BundledScript(@"simple_bot")];

AvalonGame *g = [AvalonGame gameWithVariant:AvalonVariantDefault];
for (int i = 1; i <= 10; i++) {
    AvalonPlayer *p = [AvalonPlayer playerWithId:[NSString stringWithFormat:@"BOT %d", i]];
    [g addPlayer:p];
}
while (! [g isFinished]) {
    [c.engine step:g];
}

BOOL goodWin = (g.passedQuestCount > g.failedQuestCount) && (g.assassinatedPlayer.role.type != AvalonRoleMerlin);

Creating deciders

Native Deciders

All deciders must implement the AvalonDecider protocol:

@protocol AvalonDecider <NSObject>

- (NSArray *)questProposalForGameState:(AvalonGame *)state;

- (BOOL)acceptProposalForGameState:(AvalonGame *)state;

- (BOOL)passQuestForGameState:(AvalonGame *)state;

- (NSString *)playerIdToAssassinateForGameState:(AvalonGame *)state;

@end

See the AbstractDecider class for an example implementation.

JavaScript Deciders

Deciders can also be implemented in javascript using a similar interface:

var proposeQuest = function(state) { /* array of player id strings */ };

var acceptProposal = function(state) { /* boolean for vote */ };

var passQuest = function(state) { /* boolean for pass */ };

var assassinatePlayer = function(state) { /* player id string to assassinate */ };

See the wiki page

Example of iOS version

Update, getting prettier:

Amalon2

Very crude example now included!

Amalon

About

An Avalon (Resistance) engine for simulating, replaying, or scripting games

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published