Pelita

Screenshot.

A first fight: ‘The SmartRandomPlayers’ v ‘The FoodEatingPlayers’

class SmartRandomPlayer(AbstractPlayer):
    def get_move(self):
        dangerous_enemy_pos = [bot.current_pos
            for bot in self.enemy_bots if bot.is_destroyer]
        killable_enemy_pos = [bot.current_pos
            for bot in self.enemy_bots if bot.is_harvester]

        smart_moves = []
        for move, new_pos in list(self.legal_moves.items()):
            if (move == stop or
                new_pos in dangerous_enemy_pos):
                continue # bad idea
            elif (new_pos in killable_enemy_pos or
                  new_pos in self.enemy_food):
                return move # get it!
            else:
                smart_moves.append(move)

        if smart_moves:
            return self.rnd.choice(smart_moves)
        else:
            # we ran out of smart moves
            return stop

Pelita is Actor-based Toolkit for Interactive Language Education in Python.

Description of the Game

Two teams, of one or more bots, compete in a maze that is filled with food. The maze is split into two parts, the left and the right half, where each team owns one half of the maze. Each bot can have one of two states, depending on its position in the maze. In its own half, the bot is a destroyer. In the enemy half, the bot is a harvester. As a destroyer, a bot can destroy enemy harvesters in its own half. As a harvester, a bot can eat food that belongs to the enemy. The ultimate goal is to eat all the enemy’s food.

Your task as user is to implement one or more players to control bots. Your players must implement the intelligence to navigate your bots successfully through the maze, destroy the enemy’s harvesters, and eat the enemy’s food.

Quick Start

First clone the source code repository:

$ git clone https://github.com/ASPP/pelita.git

And launch the command-line interface:

$ ~/pelita/pelitagame

This will start a demo game using the TkInter interface on a random maze with some predefined players.

Continue reading: Writing a Player.

Contents

Indices and tables