Giter VIP home page Giter VIP logo

programminglanguagesclub / elemental-magicks Goto Github PK

View Code? Open in Web Editor NEW
16.0 13.0 0.0 11.67 MB

Idris + Ur/Web development of a perfect information, fair, deterministic turn based strategy game, built with dependent types!

C 0.32% Idris 33.48% Shell 0.19% UrWeb 10.13% Makefile 0.01% HTML 9.87% CSS 9.97% C++ 0.02% Coq 0.02% JavaScript 28.27% Logos 0.76% Yacc 1.57% Haskell 5.40%
strategy-game idris game card-game strategy

elemental-magicks's Introduction

elemental-magicks

Idris + Ur/Web development of a perfect information, fair, deterministic turn based strategy game, built with dependent types!

Intro

Elemental Magicks is a card battle game and the first game to be entirely skill based :

In no case could a player benefit from playing a move which is sub-optimal in the mini-max sense.

https://en.wikipedia.org/wiki/Minimax

The only exceptions are cases where the player is factoring in both future errors they expect themselves to make, and future errors they expect from the opponent.

It is thus more pure as a strategy game even than chess, and much more than other games of its genre.

An equivalently pure game to Elemental Magicks would be a version of chess where draws and ties are impossible (each game ends, and a game ending results in a player winning), and the players play two rounds (one with white, and one with black). Unfortunately chess is not designed to admit this modification without destroying much of the strategy.

Our Goal

Having successfully prototyped this game in Java (about 100,000 line development), we seek to build a beautiful, concise, and robust version using the best programming languages currently available. That means development in Ur/Web and Idris.

List of Contributors

This list will continue to evolve as people help us. It also currently does not include the large number of artists who are helping.

Please send me a message if you want to be added to our team (i.e. need write access).

Game Design : Raleigh Foster

Programming : Rob Sap, Raleigh Foster, Matt Almenshad, Andy Hampton

Our GitHub Page

https://github.com/programminglanguagesclub

We're the programming languages club from the University of Oregon.

We have weekly meetings where we discuss design patterns and type systems.

We also work on group projects, designed to give us experience in powerful languages, and provide examples of powerful languages in action.

This card game is our first group project.

Tasks to Work On

https://github.com/programminglanguagesclub/elemental-magicks/issues

You can view the currently outstanding tasks via the above link.

Anything with the label "Help wanted" is up for grabs. Please let me know you want the task and I'll assign it to you.

Anything with the "High Priority" label is currently blocking other tasks. These are the highest value tasks to solve.

Anything with the "Hard" or "Easy" label is respectively hard or easy, but don't let that scare or fool you. Hard tasks can be quite doable, and easy tasks can be challenging, but typically have more limited scope.

Our Facebook Page

https://www.facebook.com/groups/UOProgrammingLanguagesClub/

Recent Group Messages and Updates

https://www.facebook.com/groups/UOProgrammingLanguagesClub/986712538043434/?notif_t=group_activity

Our Events Page

https://www.facebook.com/groups/UOProgrammingLanguagesClub/events/

Installing Ubuntu on Virtual Box

Due to Ur/Web not working on Mac and Windows, we are using Ubuntu to work with it. If you don't have Ubuntu on your computer, you can use Virtual box. We set up a guide on installing Virtual box and Ubuntu.
http://bootupcorner.blogspot.com/2016/05/installing-ubuntu-on-virtual-box.html

Installing Idris

on Mac: brew update
brew install idris

OR View the link for addition install options
http://www.idris-lang.org/download/

Installing Ur/Web

Ur/Web currently does not work well on Mac (due to an issue with the MLTON compiler). Ur/Web runs best with Ubuntu (which also works well with Idris).

To install Ur/Web, visit http://www.impredicative.com/ur/ and follow the steps in the reference manual.

elemental-magicks's People

Contributors

awhampton avatar raleigh-foster avatar robsap avatar vino4 avatar

Stargazers

 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  avatar  avatar  avatar  avatar

elemental-magicks's Issues

Create Debugging Code for Idris

Code should be callable from Idris functions and use the C FFI to print out logging information.

If we had a serializer for somewhat arbitrary Idris types, it would be better, but primitive types is fine.

Add Browser Notifications

The browser should notify important messages such as when the opponent made a move. We also probably want one for game started, in addition to the users being required to confirm after an opponent is found, to start a game.

Design Game Clock

This is not a graphic design task;

This is a programming task in Ur/Web.

This game will have a clock that will function much like clocks do in chess.

In Ur/Web, maintain the current time for each player.
On the front end, display the current time for each player.
When the server sends a message to the client, it includes a message about how much time they have left as follows:

(ideally)

The server includes a timestamp of how much time each player has at a particular Unix time.

The client then checks the time and updates its clocks accordingly.

In this way sync is preserved between client and server.

If ever a player runs out of time, they lose the round.

In implementing, remember that updates can be received by a player which is not currently
on-move, but you may assume that every time a request is received,
Ur/Web has the player on-move cached (ultimately from interactions with the backend)

Create Rating Systems

Use Elo, although it is true there are other systems.

This should be built in Ur/Web.
Assume we know the players and the result, and need to update the rating.
Ratings will be stored in the database.

Connect Ur/Web to JavaScript code.

The JS FFI is giving me a lot of trouble. The ultimate goal is to not only have the JS FFI working, but to be able to pass Ur/Web callback functions to JavaScript, or otherwise be able to handle three.js events.

Create C glue between Ur/Web and Idris

We previously got something working using global pipes.
We now wish to get a version working that is robust to large messages, high throughput, race conditions, etc.

Create Hello World version of Full Stack

The stack of our project works like this: Two players connect via an HTML interface to an Ur/Web server, which communicates to an Idris backend. Idris will keep persistent state, and Ur/Web will also have access to a database to store more boring values (like account details, etc).

Build a hello world version of this.

Add more information to Idris types

Ideally, we want to be adding lots of information to the types in Idris. Sometimes there will be ways to add more information into the types than is currently provided, which correspond to stronger guarantees and simpler programs.

Create Architectural Documentation

Among other things, this should provide a detailed description of the architecture being used for the minimum viable product, as pertains to the card/skill DSL, as well as the database, and also planned refactorings.

It should detail everything else as well, ideally well enough that new programmers can quickly join the project.

Create Compiler for Card List & Skill DSL

I want to use names and operators in the DSL (such as := etc) that already exist in the rest of the code.
For some reason, Idris doesn't seem to like this at all.
Thankfully, other than the name collision problem, Idris makes it very pleasant to build a DSL.

Thus the only task that remains is to write a program that will take a text file and perform a set of textual substitutions from the syntax we want to the actual syntax of the DSL in Idris. There is no structural analysis, etc. One only has to change some keywords.

I do not have a complete list of keywords at the moment, and it may change,
so the program should be capable of arbitrarily performing substitutions.

Create Basic Version of Backend Logic

Implement the core game in Idris.
This is without yet adding any cards.
Just the core functionality needed to play a basic game.
Perhaps a couple cards could be added for test purposed.

Create Token System

We need a system to manage connection of users in Ur/Web now that we have migrated away from Google Accounts.

Create Replay System

People should be able to view games, to try different moves (and take them back, etc), to add annotations (commentary), etc. This should be able to run in the browser and also have a nice notation for players to read.

Determine if it is beneficial to write the front-end in HTML 5

The following are important:

The game should automatically resize the canvas to be the maximum size it can be given the current size of the browser window. It must do it seemlessly, and not have any weird rendering issues if the browser window is resized.

It must be able therefore to also resize a representation of text.
The HTML 4 has some issues with this as well, so if there are some hiccups it's okay.

It could make the interface significantly nicer if we could user HTML 5, but it must satisfy these requirements. This could be difficult: It took me a long time to get this working in HTML 4.

Refactor existing code

This applies to all code. We want cleaner, more easily understood, more efficient, etc.

Create JSON serializer / deserializer for Idris

Note that there are already JSON serializers and deserializers which exist,
but we need to be able to marshal the JSON into the appropriate Idris type.

Essentially, we need something like Google Gson but for Idris.

Alternatively, propose an different method of building the interface to the backend.

Design Database

We need a system to manage accounts now that we have migrated away from Google Accounts.

Create Spectator System

People should be able to watch existing games. They should also be able to analyze the game with the functionality of the replay system

Create clean scripts. Create Separate build scripts for Idris, UrWeb components.

Clean script should handle removing all of the .ibc, etc files.
We should still have a build script, but should have separate scripts to just build the Ur/Web or Idris part.
I guess we also want one for the C part.
The build script can then call all of these.
Additionally, should probably add a script to typecheck the Idris code but not compile (I think that's possible).

Create Client-side MVC with Animation Manager in TypeScript

When updates are delivered to the client, they often will trigger a list of animations.
The user should be able to step through these animations as they desire, skip ahead, go back, etc.
They should also be able to speed up or slow down animations, etc.

This should be implemented together with a system for managing the client-side state of the game.

Design HTML Front-end

Can be based on existing HTML front-end. Doesn't have to be too awesome for now.
This is mostly a task of integrating an existing mess into Ur/Web.

Represent Hitpoints, Max Hitpoints.

We already have a representation of bounded numbers:
A number p if of type Bounded n m if n <= p <= m.

This isn't quite enough to represent Hitpoints, however. Hitpoints are bounded, but they're bounded above by Max Hitpoints, which is in term bounded from above and below.

It's possible this isn't too hard if you can create an instance of the Ord (and possibly Eq) typeclass
for Bounded, but it's slightly tricky as Bounded isn't a type but rather a family of types.

Alternatively, there may be another way of doing this.
Perhaps we should require a proof to be passed that hp <= max hp?

Try to find a nice way to do this, and then define transform functions for hp and max hp,
similar to what exists for other stats in the code.

Note: All that is required for this task is to create a type (or family of types) that is useful,
and transform functions to operate on them.

Design System for storing and serving database of cards

Because there are so many cards in the game, we have to decide how to store them. Should they all be stored in Idris and loaded into the game? Should they be stored as text in a database and loaded into the game when the player picks them? Also, what sorts of animations exist, and which are specific to particular skills? Are any? If any are, then we need to think about when to serve this data to the client.

One additional bit of information is that this database should be searchable. If we intend to put everything in Postgresql for searching, then we might want to only have it there to avoid duplication of data.

On the other hand, if it's in Postgresql, then we need to think about how to verify the stats of the cards using Idris.

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.