Even more cleanup and removal of legacy code
This commit is contained in:
parent
157e6285eb
commit
5a56a400c5
8 changed files with 40 additions and 182 deletions
56
README.md
56
README.md
|
@ -1,55 +1,17 @@
|
||||||
# TTRTS
|
# TTRTS
|
||||||
*The Tiny Terminal RTS where the players write their AIs*
|
*The Tiny Terminal RTS where the players write their AIs*
|
||||||
|
|
||||||
------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
## Introduction
|
## Introduction
|
||||||
We aim to create a simple terminal based rts where a user can program an AI to control their army
|
A simple terminal based RTS game that uses txt files to communicate game state and unit commands. TTRTS was
|
||||||
|
|
||||||
------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
## Gameplay
|
## Gameplay
|
||||||
1. ttrts clients are run from the command line
|
1. The ttrts client is run from the command line with initial parameters
|
||||||
2. ttrts-server is launched from the command line
|
2. The client outputs a gamestate text file
|
||||||
3. clients will connect to server and confirm initial board state
|
3. A player, program or cat reads the state and outputs instructions for their units.
|
||||||
1. clients output a text file with game data for this turn
|
4. The client reads in instructions and processes the turn
|
||||||
2. a player, or program, reads the game data file and outputs an instructions file
|
5. If no winner is reached, skip back to step 2
|
||||||
3. clients read the instructions file, simulates the turn
|
6. The game client outputs a final summary file with the winner
|
||||||
4. game state is verified between clients and server
|
|
||||||
5. repeat until an end state is reached
|
|
||||||
4. once game is finished, host and clients disconnect and a winner is notified
|
|
||||||
|
|
||||||
*see [game](game) for full game rules*
|
*see [game](game) for full game rules*
|
||||||
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
## Source
|
|
||||||
|
|
||||||
|
|
||||||
### Targets
|
|
||||||
##### ttrts
|
|
||||||
Main TTRTS executable , runs from the command line and acts as client
|
|
||||||
|
|
||||||
##### ttrts-server
|
|
||||||
TTRTS server executable, runs from the command line acting as server
|
|
||||||
|
|
||||||
##### player
|
|
||||||
Custom player AI code, this should contain examples and test code to help newcomers begin their journey
|
|
||||||
|
|
||||||
##### ttrts-test
|
|
||||||
Test executable, to be compiled and run to test various functionality
|
|
||||||
|
|
||||||
### Libraries
|
|
||||||
##### game
|
|
||||||
Implementation of the RTS rules and simulation. [game](game) has full information on it's implementation.
|
|
||||||
|
|
||||||
##### net
|
|
||||||
Net code for hosting the server and communicating with clients
|
|
||||||
|
|
||||||
##### ui
|
|
||||||
Wrapper for user interface for the terminal, this only really needs three stages
|
|
||||||
* Initialise the game with settings and connect the clients
|
|
||||||
* Run the game simulation to it's conclusion
|
|
||||||
* Display the game result
|
|
||||||
* ASCII Colour wrapper for separate teams
|
|
||||||
|
|
||||||
##### maths
|
|
||||||
simple maths library for 2D calculations and types
|
|
||||||
|
|
||||||
|
|
27
source/README.md
Normal file
27
source/README.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Targets
|
||||||
|
### ttrts
|
||||||
|
Main TTRTS executable , runs from the command line and acts as client
|
||||||
|
|
||||||
|
### ttrts-test
|
||||||
|
Test executable, to be compiled and run to test various functionality
|
||||||
|
|
||||||
|
### ttrts-gen
|
||||||
|
Binary to generate map example map files
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
### game
|
||||||
|
Implementation of the RTS rules and simulation. [game](game) has full information on it's implementation.
|
||||||
|
|
||||||
|
### net
|
||||||
|
Net code for hosting the server and communicating with clients
|
||||||
|
|
||||||
|
### ui
|
||||||
|
Wrapper for user interface for the terminal, this only really needs three stages
|
||||||
|
* Initialise the game with settings and connect the clients
|
||||||
|
* Run the game simulation to it's conclusion
|
||||||
|
* Display the game result
|
||||||
|
* ASCII Colour wrapper for separate teams
|
||||||
|
|
||||||
|
### maths
|
||||||
|
simple maths library for 2D calculations and types
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Game Design
|
TTRTS Gameplay
|
||||||
=================
|
=================
|
||||||
|
|
||||||
The game takes place in a series of simultaneous turns on an arbitrarily sized 2D board.
|
The game takes place in a series of simultaneous turns on an arbitrarily sized 2D board.
|
||||||
|
@ -11,22 +11,7 @@ The engine then takes all commands, evaluates all movement first simultaneously,
|
||||||
|
|
||||||
All attempted movement to the same square by two or more units will fail.
|
All attempted movement to the same square by two or more units will fail.
|
||||||
|
|
||||||
Friendly fire is enabled by default
|
Friendly fire is enabled by default.
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
|
|
||||||
Units
|
|
||||||
-----
|
|
||||||
|
|
||||||
Currently only one unit, this will be expanded in the future.
|
|
||||||
|
|
||||||
Units have a set of properties, and commands than can be issued.
|
|
||||||
|
|
||||||
All units take one hit to kill.
|
|
||||||
|
|
||||||
##### properties
|
|
||||||
See [the unit header](unit.h) for full details on unit properties
|
|
||||||
|
|
||||||
##### orders
|
|
||||||
Commands take the form of a single char literal.
|
|
||||||
See [the order header](order.h) for details on the orders
|
|
||||||
|
|
|
@ -54,4 +54,4 @@
|
||||||
L/R - Rotate unit left or right
|
L/R - Rotate unit left or right
|
||||||
A - Attack row in front of unit
|
A - Attack row in front of unit
|
||||||
|
|
||||||
`$ cat usage.md | sed 's/^#* //g' | sed 's/\t/\\t/g' | sed ':a;N;$!ba;s/\n/\\n\n/g' | sed 's/^/"/' | sed 's/$/"/' | sed '$ d' > usage.h # To convert this file to c++`
|
`$ cat README.md | sed 's/^#* //g' | sed 's/\t/\\t/g' | sed ':a;N;$!ba;s/\n/\\n\n/g' | sed 's/^/"/' | sed 's/$/"/' | sed '$ d' > usage.h # To convert this file to c++`
|
|
@ -1,19 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.8.7)
|
|
||||||
|
|
||||||
# game project
|
|
||||||
project( ui )
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
../maths
|
|
||||||
../game
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set to use c++11, because we're cool like that
|
|
||||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11" )
|
|
||||||
|
|
||||||
# Add the sources
|
|
||||||
set( SOURCES
|
|
||||||
board.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library( ui ${SOURCES} )
|
|
|
@ -1,43 +0,0 @@
|
||||||
#include "board.h"
|
|
||||||
|
|
||||||
// ----------------------------------------------
|
|
||||||
|
|
||||||
// Default constructor for the board
|
|
||||||
CBoard::CBoard( unsigned int c, unsigned int r )
|
|
||||||
: cols ( c )
|
|
||||||
, rows ( r )
|
|
||||||
, total ( rows * cols )
|
|
||||||
{
|
|
||||||
board.resize(total,square_empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
CBoard::CBoard( unsigned int c, unsigned int r, vunitVis_c&& b )
|
|
||||||
: cols ( c )
|
|
||||||
, rows ( r )
|
|
||||||
, total ( rows * cols )
|
|
||||||
, board ( std::move(b) )
|
|
||||||
{
|
|
||||||
board.resize(total,square_empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// print get a slot on the board
|
|
||||||
unitVis_c CBoard::get( const unsigned int c, const unsigned int r ) const
|
|
||||||
{
|
|
||||||
if ( (r >= rows) || (c >= cols) )
|
|
||||||
return square_invalid;
|
|
||||||
|
|
||||||
return board[r*c];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a square on the board
|
|
||||||
unitVis_c CBoard::set( const unsigned int c, const unsigned int r , const unitVis_c n )
|
|
||||||
{
|
|
||||||
if ( (r >= rows) || (c >= cols) )
|
|
||||||
return square_invalid;
|
|
||||||
|
|
||||||
unitVis_c old = board[r*c];
|
|
||||||
board[r*c] = n;
|
|
||||||
return old;
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
#ifndef _BOARD_H_
|
|
||||||
#define _BOARD_H_
|
|
||||||
|
|
||||||
#include "gametypes.h"
|
|
||||||
#include "mathtypes.h"
|
|
||||||
|
|
||||||
#include <limits> // std::numeric_limits
|
|
||||||
#include <vector> // std::vector
|
|
||||||
|
|
||||||
typedef std::vector< unitVis_c > vunitVis_c;
|
|
||||||
|
|
||||||
// Invalid value for the board square
|
|
||||||
constexpr unitVis_c square_invalid = std::numeric_limits<unitVis_c>::max();
|
|
||||||
constexpr unitVis_c square_empty = ' ';
|
|
||||||
|
|
||||||
// Class to store simple data about a board
|
|
||||||
class CBoard
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
const unsigned int cols; // Number of columns
|
|
||||||
const unsigned int rows; // Number of rows
|
|
||||||
const unsigned int total; // Total number of pieces
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
CBoard( unsigned int c, unsigned int r );
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
CBoard( unsigned int c, unsigned int r, vunitVis_c&& b );
|
|
||||||
|
|
||||||
// Default destructor
|
|
||||||
~CBoard() = default;
|
|
||||||
|
|
||||||
// clear the board
|
|
||||||
inline void clear() { fill(square_empty); }
|
|
||||||
|
|
||||||
// fill the board
|
|
||||||
inline void fill(unitVis_c v) { std::fill(board.begin(),board.end(),v); };
|
|
||||||
|
|
||||||
// Get a square on the board
|
|
||||||
unitVis_c get( const unsigned int c, const unsigned int r ) const;
|
|
||||||
|
|
||||||
// Get the full board
|
|
||||||
inline const vunitVis_c& get() const { return board; };
|
|
||||||
|
|
||||||
// Get a square on the board
|
|
||||||
unitVis_c set( const unsigned int c, const unsigned int r , const unitVis_c n );
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
vunitVis_c board; // Board data storage
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //_BOARD_H_
|
|
Loading…
Add table
Reference in a new issue