Giter Site home page Giter Site logo

davidjpfeiffer / game-engine Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 638 KB

A two-player turn-based strategy game engine

License: GNU General Public License v3.0

C++ 98.83% C 1.09% Batchfile 0.08%
game-engine game-development algorithm player humans strategy-game

game-engine's Introduction

Game Engine

This project was originally written for the 2016 Southeast Missouri State Hackathon. It has since been refactored and improved. The program was written to better understand how game engines work and to gain experience designing interfaces for relational objects within a complex system.

The command line interface program allows two players to play against each other in any given two-player, turn-based strategy game. The games are defined by implementing the abstract base class Game, which defines the rules for the game. The players implement the abstract base class Player, which requires them to implement a get move method that is used by the game engine to get the players move given a game state. The game engine takes care of the details necessary to play the game, while the game and players define the logic for the game itself and how it is played.

How It Works

There are two components of the game engine: the base components that provide the structure and interfaces necessary for the game engine to play games, and the implementation of these interfaces which includes the games and players themselves. The game engine is responsible for facilitating the playing of games and using the game class to verify players moves. The players themselves implement a single method that returns a move given a game state.

To use the game engine, you need only include the gameEngine.h file and call the start() method as illustrated in the main.cpp file. This prompts the user to enter their desired game, the number of games to be played, and the first and second player. The available games are retrieved from the Game Registry class, which is just a class that contains a list of all available games. Similarly, each of the games has a Player Registry which is used by the game engine to retrieve the available players for any given game. If you add a new game or player, you should update the registry accordingly.

Games

  • Tic Tac Toe
  • Connect Four

Features

  • Parallel processing support for multiple games
  • Custom exceptions and elegant exception handling
  • Display visual game state one move at a time
  • Display summary statistics for multiple games

License

GNU GENERAL PUBLIC LICENSE

ALL RIGHTS RESERVED

game-engine's People

Contributors

davidjpfeiffer avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

game-engine's Issues

Rename project to game engine

This project should not be specific to a single game but should work for any two-player turn-based strategy board game.

After the project it renamed a second game should be added in addition to Tic Tac Toe.

Create GUI for game engine

The project should have a GUI that allows the user to select a game, two players, and the number of games to be played (n). The game engine should then play the game n times and display the output on the screen by either drawing the board or displaying the multiple games summary statistics.

Add Trust game

The game has many names, but the general idea is that players develop algorithms to try and optimize their own personal reward. Both players win if they both trust each other. If only one player lies then that player gets an even bigger reward, at the expense of the other player. If both players lie then both players loose.

This website has built a fully functioning version of the game, but if it is added to the game engine new algorithms can be built to play against each other in tournaments.

Additional starting options and parameters

The program should accept the starting options as command line parameters. If none are provided, the program should prompt the user for the options as it currently does.

We should time the execution of the games and include this information in the game statistics.

The program should have an additional starting option, which lets the user enter explicitly state whether or not they would like the games to be printed. If this parameter is set to true then the number of games parameter is optional and defaults to one. The default value of this parameter is to display statistics. When we display statistics we do not include player stats for one game, but we always show the average execution time per game.

Make board value enum a class

This class should have two properties:

  • enum for value (x, o, or empty)
  • enum for player (one or two)

It should also have certain methods, like a method to get the board value as a char.

Refactor utilities to Game class

Refactor all game specific login into a game class that is used in all other classes. The utilities file should only contain helper methods that know nothing about the game object.

Extract interfaces for game related classes

We should extract an interface (abstract class in c++) from all game related classes and have the game engine use these interfaces instead of a classes related to a specific game.

This will make the game engine reusable for other two player board games.

Board should be a class not a typedef

The board is currently a typedef of a vector of type vector of type board value. The board should instead be refactored into a separate class with utility methods that interact with the board array.

Add Chess Game

Chess should be added as a Game in addition to Connect Four and Tic Tac Toe. Because this game is much more advanced it will show the true strength of the Game Engine. We might also add optimizations to the game engine to handle the stress for this game.

Better abstractions

We should improve abstractions within the game engine to take more abstract objects when possible.

For example, the isValidMove method should take a Player, not a PlayerValue.

Change Game Definition

On Game Definition class:

SetGameDefinition method should be changed to GetGameDefinition to avoid pointer confusion.

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.