Code Monkey home page Code Monkey logo

pelita's Introduction

Pelita

Build Status

Description

Pelita is a programmable game that lets you play against your opponent by writing code in Python.

Website

Current, up-to-date documentation and templates for your own code can be found on: https://github.com/ASPP/pelita_template

Development

Pelita uses GitHub for development and bug tracking. Feel encouraged to open an issue or create a pull request.

pelita's People

Contributors

achabuda avatar ageorgou avatar btel avatar carlos-echeverria avatar debilski avatar dorimg avatar esc avatar fmaussion avatar francescalted avatar jakobj avatar keszybz avatar lschwetlick avatar monfort314 avatar nchiapol avatar otizonaizit avatar pberkes avatar plodocus avatar pransito avatar pv avatar sappelhoff avatar sasza avatar steigies avatar venthur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pelita's Issues

Client implementation example with subpackage

Write a client implementation example where studens define their own subpackages and use absolute imports to avoid name clashes during tournament or local games. Something like:

student_git/my_player.py
student_git/utils/ _ _ init _ _ .py
student_git/utils/utils.py
etc...

where my_player.py is the file that you have to run to start a game.

cross-platform tests

pelita should be regularly tested on (at least) WindowsXP, Windows Vista, Windows 7, MacOSX (Snow Leopard and Lion?), Linux (Debian unstable).

exposed noise parameters

Expose the noise parameters of the UniverseNoiser class, noise_radius and sight_distance. One idea is to add them as keyword arguments to the GameMaster.

default poll time for TkApplication is too long

Right now TkApplication.read_queue has a poll timeout of 50ms: this effectively makes the tk viewer much slower than it could be. setting it to 10 or even 5 ms makes the visualization much faster. Best would be to have it configurable has maximum_framerate, so that you can dinamically set it.

An ActorReference should check on serialisation before sending

Currently, all serialisation checks are done immediately before sending the message.
As the sending of messages is done in a separate thread, there is no way to inform the sending thread that something did not work.
Serialisation should therefore be checked inside ActorReference before the sending of objects (and maybe we should even convert them already there, and restrict the messages which are handled by JsonSocketConnection to strings).

Investigate running client’s get_move in a separate thread each turn

This is probably very complicated and may not be worth the time invested. But one possible solution to the timeout problem[*] would be to run every get_move in it’s own thread, having some kind of advanced data structure in the background to deal with synchronisation and sharing issues. If a thread does not return in time, it is simply abandoned (not killed) and a new thread is started and relevant information copied.

[*] The timeout problem occurs when a client does not want to return in time and still runs even when the next round should have been started.

notification of timeout

we need to inform the user that a player has caused a timeout. Perhaps by writing big red letters onto the screen.

layout description in the docs is confusing

in spite of being correct, the layout descriptions in the user docs are way too detailed. thre's no need for the user to know that the layouts are stored in __layouts.py and in which way we autogenerate the names. there's not even need for them to know that we have text files ase input. They can get all layouts with get_available_layouts, that should be anough of an explanation. The section where it is exlained how to manually create a layout in a sting or in a text file is ok.
it would be a pity to throw away this documentation, which I think belongs somehow in the developers documentation, which we don't have right now.

Some python versions choke on unicode keywords

def f(a): pass
f(**{u'a': 1})
TypeError: f() keywords must be strings

Happens at least on the Python 2.6.1 default on Snow Leopard. The above construct is unfortunately needed quite often with the json serialisation code.

announce layout name

the tk interafce should display the name of the layout, for example the file name or the variable name

Document timeout mechanism

The timeout mechanism for players must be documented. How long do they have to compute, what happens if they go over that time and how to detect if that happens.

Compress JSON

like this base64.b64encode(zlib.compress(json.dumps(obj, default=self.encode)))
factor 25 for a maze 20x5.

display maze name or origin in viewers

The maze name or origin (file, string?) should be displayed in the viewers. In the TKViewer preferably in the lower left window, opposite the turn/round info.

Polish Tk code

Tk code is not nice and might have some performance issues as well. Needs more polishing and cleanup of unused parts and a better handling of canvas items.

Ctrl-C does not work on Windows

Got SIGINT. Exit!
Got SIGINT. Exit!
Traceback (most recent call last):
File "./run_game.py", line 19, in
server.run_tk()
File "C:\cygwin\home\berkes\pyschool\pelita\pelita\simplesetup.py", line 205,
in run_tk
self._run_save(main)
File "C:\cygwin\home\berkes\pyschool\pelita\pelita\simplesetup.py", line 172,
in _run_save
self.server.join(3)
File "C:\cygwin\home\berkes\pyschool\pelita\pelita\messaging\actor.py", line 3
47, in join
return self._actor._thread.join(timeout)
File "C:\Python26\lib\threading.py", line 655, in join
self.__block.wait(delay)
File "C:\Python26\lib\threading.py", line 258, in wait
_sleep(delay)
File "C:\cygwin\home\berkes\pyschool\pelita\pelita\utils\signal_handlers.py",
line 33, in keyboard_interrupt_handler
exit_handler()
File "C:\cygwin\home\berkes\pyschool\pelita\pelita\utils\signal_handlers.py",
line 29, in exit_handler
os.killpg(os.getpgrp(), signal.SIGTERM)
AttributeError: 'module' object has no attribute 'killpg'

Pressing ^C hangs the game

zbyszek@ameba ~/python/pelita (git)-[develop] % python demo.py
No handlers could be found for logger "pelita.threading"
Trying to establish a connection with local actor 'pelita-main'...
Starting actor 'pelita-main'
Trying to establish a connection with local actor 'pelita-main'... ok
ok
^C
Server received CTRL+C. Exiting.

Pressing ^C again has no effect.

Kill $PID works.

player rounds not exposed to player

The number of rounds, i.e. the game time is not exposed to the players. We should refactor this so that it is stored in the universe instead.

Messages should be deepcopied before sending

To avoid changing the items in the actor queue, we must deepcopy (or serialise) every item before placing it there so that there are no references to it which may change the queue.

Currently, there is a problem when applying deepcopy on a socket connection. The connection is copied all right but there is a problem with closing it afterwards. This needs to be investigated before.

remove maze.has_at

The maze.has_at method is deprecated in favour of Free in maze[0,1]. Refactor the tests and rest of the code to use this api instead and remove has_at.

update UML diagrams

update UML diagrams (sequence and class) to refelct the actual implementation

commit-doc.sh VS. commit-doc-tree.sh and documentation

There are two scripts to commit docs to the gh-pages branch on github: commit-doc.sh and commit-doc-tree.sh. I suggest to delete commit-doc.sh and rename commit-doc-tree.sh to commit-doc.sh. The tree one is much more elegant. Also the tree script will need at least a string about what it does.

The documentation about this should move from README.md to Sphinx.

on_left_side property

property that returns True when the agent starts on left side of maze:
useful for example in:

    forbidden = west if self.on_left_side else east
    if self.maze_nodes[pos] in self.border_nodes and action == forbidden:
        return stop

make 'game over' text look better

Currently the 'Game Over' text is just printed onto the canvas. This looks a bit unprofessional. Ideally we want a white outline, 3-D or a faded background. At least something that looks a bit better.

Tournament script

The torunament should be able to run in fully automatic mode. We'll probably need to write a python script (and not a shell script), so that we can leverage import semantics. Think about client isolation (each client on a separate process) and client crash (server should not be affected).

references to pacman jargon in the docs

we have to remove references to pacman-specific terms in the docs. For example, in the start page we have:
"In its own half the bot is a destroyer (equivalent to a ghost). In the enemy half, the bot is a harvester (equivalent to a pacman)."
There's no need to say that a destroyer is "equivalent" to a ghost. What does it mean "equivalent"? Most users will not know where we are coming from.

Maze API

In our first design (look at feature/bottleneck branch first commit SHA: 3e747b2), every position in the 2-D Maze would contain a TypeAwareList of instances of MazeComponents (Food, Free, Wall). While this gives extreme flexibility, it also turned out to severely slow down the deepcopying of the Maze, which is needed when we send the universe to the players. The game was basically not playable on a realisticly sized layout. We didn't notice that before because we were always testing on small layouts.

Just using strings instead of objects as an internal representation (SHA: 185d7ed) already makes the game something like 30-times faster. Using a multicharacter string instead of a list (SHA:???) gives another 2/3-fold speed increase.

This is all good, but the Maze now has an inconsistent API, that coudl lead to confusion. On the one hand, you access the MazeComponents with a OO interface (Maze.pos_of, Maze.get_at, Maze.remove_at, Maze.has_at). On the other hand, just accessing Maze values, like in Maze[0,1], would return the string representation of the MazeComponents.

We agreed that the string representation should remain an internal implementation detail of the Maze class, and that access to the Maze should be mediated by an OO API. The question is what API?

refactor end of game string

The end of game string (draw or win) has two issues that need to be resolved:

  • The font is hardcoded, this should perhaps be a function of the window size
  • The string is always displayed in full length. This should be reformatted to [...] depending on how many characters fit on the screen.

define concept of manhattan distance

in the docs, we need to define what manhattan distance means ( I personally prefer either "l1 distance" or city block distance) and make clear (maybe with a smal cartoon?) the difference with the distance on the maze (which takes into account walls and other obstacles).

What to do with unknown JSON?

Currently, unknown json of the form

{"__id__": "pelita.json.someclass", "__value__": some_serialised_value}

is left unparsed, i.e. it is returned as a plain dict. This may lead to subtle bugs. On the other hand, blocking on wrong "id" values may lead to false negatives.

destroyer shape -> ghost

The tk interface currently has destroyers animated as pacman with yellow eyes. A ghost character would be better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.