[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot INSTALL game/Makefile.am game/ai_percent....
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot INSTALL game/Makefile.am game/ai_percent.... |
Date: |
Sat, 19 Jan 2008 19:33:08 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 08/01/19 19:33:08
Modified files:
. : INSTALL
game : Makefile.am ai_percent.cpp game_factory.cpp
game_factory.h player.h training.cpp
utils : ncurses.cpp
Added files:
extras/contrib : Makefile
Log message:
- Players can now have a name
- Use player names in the ncurses interface
- In training mode, create the hidden player in the constructor, not
in start()
- When the AI has nothing to play, change the letters instead of
simply passing
- New Makefile to build the win32 dependencies automatically (INSTALL
file updated)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/INSTALL?cvsroot=eliot&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/eliot/extras/contrib/Makefile?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/game/Makefile.am?cvsroot=eliot&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/eliot/game/ai_percent.cpp?cvsroot=eliot&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game_factory.cpp?cvsroot=eliot&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game_factory.h?cvsroot=eliot&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/eliot/game/player.h?cvsroot=eliot&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/eliot/game/training.cpp?cvsroot=eliot&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/ncurses.cpp?cvsroot=eliot&r1=1.24&r2=1.25
Patches:
Index: INSTALL
===================================================================
RCS file: /cvsroot/eliot/eliot/INSTALL,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- INSTALL 8 Jan 2008 13:52:32 -0000 1.10
+++ INSTALL 19 Jan 2008 19:33:08 -0000 1.11
@@ -1,83 +1,86 @@
+Installation on Linux/Unix
+==========================
-Installation sous Linux (Un*x) (bien/facile)
-------------------------------
-* Pour installer à partir de l'archive CVS :
+In the following, do not forget that the ./configure command can take options.
+Run ./configure --help to have the list of available options.
+* If you build from a CVS snapshot, run the following commands:
./bootstrap
-
./configure
make
+
+Then, as root:
make install
-* Pour installer à partir de l'archive tar.gz
+No graphical interface is built by default, see below for more details.
+
+* If you build from a release tarball, run the following commands:
./configure
make
+
+Then, as root:
make install
+No graphical interface is built by default, see below for more details.
-Il existe en fait 3 versions d'eliot, une en mode texte, une avec une
-interface curses et une avec wxwidgets. Les modes peuvent être
-sélectionnés à l'aide de la commande configure lors de la compilation
-du programme.
-./configure --enable-text --enable-ncurses --enable-wxwidgets
+There are in fact several interfaces to Eliot:
+ - one in text mode: mostly useful to debug Eliot
+ - one using the ncursesw library: nice but not really graphical
+ - a wxWidgets interface: complete, but it does not allow multiplayer
+ modes, only training mode
+ - a Qt interface: currently under construction, it will replace the
+ wxWidgets interface when finished. It will support all Eliot features.
+These interfaces can be enabled or disabled at configuration time. Example:
+ ./configure --disable-text --enable-ncurses --disable-wxwidgets --enable-qt
-Installation pour Windows (moins bien/facile)
--------------------------
-Il y a 2 principales façons de procéder :
-* directement depuis Windows, en utilisant Cygwin (http://www.cygwin.com/).
-* depuis GNU/Linux, en utilisant le cross-compilateur Mingw32.
+Windows build
+=============
+There are 2 ways to proceed:
+* cross-compilation from a Linux host, using the mingw32 cross-compiler
+* directly on Windows, using Cygwin (http://www.cygwin.com/)
+Only the cross-compilation is officially supported (but adapting these
+instructions for Cygwin shouldn't be too hard; patches welcome!).
-Dans les 2 cas, les étapes sont les mêmes :
-* installation de l'environnement de compilation (cette étape n'est pas
- décrite ici, car elle ne rentre pas dans le cadre de ce document)
+Here are the steps for the cross-compilation:
-* compilation et installation des dépendances (même remarque):
+* install the build environment (this step is not documented here,
+ as it is out of the scope of this document)
- - wxWidgets (http://www.wxwidgets.org/), version 2.4.2 ou ultérieure, avec
- support de l'unicode
+* build and install dependencies:
+ The Makefile in the 'extras/contrib' directory should be able to do it for
you:
- - libiconv (http://www.gnu.org/software/libiconv/), de préférence
compilée
- en mode statique (--disable-shared --enable-static)
+ cd extras/contrib && make all
- - boost (http://www.boost.org/). Eliot n'utilise pas de librairie de Boost
- (uniquement des headers), donc il n'y a pas vraiment besoin de compiler
+ Eliot dependencies (libiconv, boost, wxWidgets and Qt) will be downloaded
+ and cross-compiled, except Qt, which is only downloaded. Install it with
+ Wine, ignoring the warning that mingw is not found.
+ The dependencies are installed in 'extras/contrib/inst'
-* compilation d'Eliot :
+* build Eliot:
- - si vous utilisez l'archive CVS, il faut générer le script 'configure'
- (aussi bien sous Cygwin que sous GNU/Linux) :
+ - if you don't have the 'configure' script, generate it:
./bootstrap
- - Ã cause d'un bug de gettext, il faut appliquer un patch aux fichiers
installés
- dans intl/ :
- - télécharger le patch ici (lien en haut à gauche) :
+ - because of a bug in gettext, you need to apply a little patch to the
files
+ installed in the 'intl' directory:
+ - download the patch here (link in the top-left-hand corner)
http://www.koders.com/noncode/fid46DF595700FEB564B6EF45BFF55067F95DCF0420.aspx
- - exécuter la commande suivante :
+ - apply the patch:
patch -p2 < gettext-win32.patch
- - avec Cygwin, configurer avec la ligne de commande suivante :
- CPPFLAGS=-I/path/to/installs/include
LDFLAGS=-L/path/to/installs/lib \
- CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin" \
- ./configure --enable-wxwidgets --with-wx-config=/path/to/wx-config
\
- --with-boost=/path/to/boost/installs
- en prenant soin de remplacer les différents chemins par les bonnes
valeurs.
- Ensuite, un simple 'make' suffit pour terminer la compilation,
- éventuellement suivi de 'make install'.
-
- - pour la cross-compilation depuis GNU/Linux, configurer avec la ligne
- de commande suivante :
- CPPFLAGS=-I/path/to/installs/include
LDFLAGS=-L/path/to/installs/lib \
+ - configure with the following command:
+ export INST=`pwd`/extras/contrib/inst && \
+ CPPFLAGS=-I${INST}/include LDFLAGS=-L${INST}/lib \
CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++ \
./configure --host=i586-mingw32msvc --build=i386-linux \
- --enable-wxwidgets --with-wx-config=/path/to/wx-config \
- --with-boost=/path/to/installs
- en prenant soin de remplacer les différents chemins par les bonnes
valeurs.
- Ensuite, un simple 'make' suffit pour terminer la compilation,
- éventuellement suivi de 'make install'.
+ --enable-wxwidgets --with-wx-config=${INST}/bin/wx-config \
+ --with-boost=${INST}
+
+ - to compile, run 'make', possibly followed with 'make install'
Index: game/Makefile.am
===================================================================
RCS file: /cvsroot/eliot/eliot/game/Makefile.am,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- game/Makefile.am 8 Jan 2008 16:09:08 -0000 1.15
+++ game/Makefile.am 19 Jan 2008 19:33:08 -0000 1.16
@@ -19,7 +19,7 @@
noinst_LIBRARIES = libgame.a
-AM_CPPFLAGS = -I$(top_srcdir)/dic
+AM_CPPFLAGS = -I$(top_srcdir)/dic -I../intl -I$(top_srcdir)/intl
libgame_a_SOURCES= \
ai_percent.cpp ai_percent.h \
Index: game/ai_percent.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/ai_percent.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- game/ai_percent.cpp 8 Jan 2008 13:52:37 -0000 1.6
+++ game/ai_percent.cpp 19 Jan 2008 19:33:08 -0000 1.7
@@ -53,9 +53,12 @@
{
if (m_results.size() == 0)
{
- // If there is no result, simply pass the turn
- // XXX: it is forbidden in duplicate mode, but well, what else to do?
- return Move(L"");
+ // If there is no result, change all the letters
+ // XXX: it is forbidden in duplicate mode (even passing is forbidden),
+ // but well, what else to do?
+ Rack rack;
+ getCurrentRack().getRack(rack);
+ return Move(rack.toString());
}
else
{
Index: game/game_factory.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game_factory.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- game/game_factory.cpp 8 Jan 2008 13:52:38 -0000 1.9
+++ game/game_factory.cpp 19 Jan 2008 19:33:08 -0000 1.10
@@ -26,18 +26,27 @@
#include <fstream>
#include <exception>
+#if ENABLE_NLS
+# include <libintl.h>
+# define _(String) gettext(String)
+#else
+# define _(String) String
+#endif
+
#include "game_factory.h"
#include "game.h"
#include "training.h"
#include "freegame.h"
#include "duplicate.h"
+#include "player.h"
#include "dic.h"
+#include "encoding.h"
GameFactory *GameFactory::m_factory = NULL;
-GameFactory::GameFactory(): m_dic(NULL), m_human(0), m_ai(0), m_joker(false)
+GameFactory::GameFactory(): m_dic(NULL), m_joker(false)
{
}
@@ -94,12 +103,12 @@
{"dictionary", required_argument, NULL, 'd'},
{"dict", required_argument, NULL, 'd'},
{"mode", required_argument, NULL, 'm'},
- {"human", no_argument, NULL, 300},
- {"ai", no_argument, NULL, 400},
+ {"human", required_argument, NULL, 'u'},
+ {"ai", required_argument, NULL, 'a'},
{"joker", no_argument, NULL, 500},
{0, 0, 0, 0}
};
- static char short_options[] = "hvd:m:";
+ static char short_options[] = "hvd:m:u:a:";
int option_index = 1;
int res;
@@ -126,11 +135,22 @@
m_modeStr = optarg;
found_m = true;
break;
- case 300:
- m_human++;
- break;
- case 400:
- m_ai++;
+ case 'u':
+ case 'a':
+ // Handle both types of players together
+ {
+ wstring name;
+ if (optarg == NULL)
+ {
+ // TODO: use Boost.Format
+ char s[200];
+ snprintf(s, 200, _("Player %u"), m_players.size() + 1);
+ name = convertToWc(s);
+ }
+ else
+ name = convertToWc(optarg);
+ m_players.push_back(make_pair<bool, wstring>(res == 'u',
name));
+ }
break;
case 500:
m_joker = true;
@@ -184,10 +204,15 @@
}
// 5) Add the players
- for (int i = 0; i < m_human; i++)
+ for (unsigned int i = 0; i < m_players.size(); ++i)
+ {
+ // Human?
+ if (m_players[i].first)
game->addHumanPlayer();
- for (int i = 0; i < m_ai; i++)
+ else
game->addAIPlayer();
+ const_cast<Player*>(&game->getPlayer(i))->setName(m_players[i].second);
+ }
// 6) Set the variant
if (m_joker)
@@ -225,9 +250,9 @@
<< " -v, --version Print version information and exit" <<
endl
<< " -m, --mode {duplicate,d,freegame,f,training,t}" << endl
<< " Choose game mode (mandatory)" << endl
- << " -d, --dict <string> Choose a dictionary (mandatory)" <<
endl
- << " --human Add a human player" << endl
- << " --ai Add a AI (Artificial Intelligence)
player" << endl
+ << " -d, --dict <path> Choose a dictionary (mandatory)" <<
endl
+ << " -u --human <name> Add a human player" << endl
+ << " -a --ai <name> Add a AI (Artificial Intelligence)
player" << endl
<< " --joker Play with the \"Joker game\" variant"
<< endl;
}
Index: game/game_factory.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game_factory.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- game/game_factory.h 8 Jan 2008 13:52:38 -0000 1.9
+++ game/game_factory.h 19 Jan 2008 19:33:08 -0000 1.10
@@ -22,8 +22,12 @@
#define _GAME_FACTORY_H_
#include <string>
+#include <vector>
using std::string;
+using std::wstring;
+using std::vector;
+using std::pair;
class Dictionary;
class Game;
@@ -85,15 +89,12 @@
/// Game mode
string m_modeStr;
- /// Number of human players
- int m_human;
-
- /// Number of AI players
- int m_ai;
-
/// Variant of the game
bool m_joker;
+ typedef pair<bool, wstring> PlayerDesc;
+ vector<PlayerDesc> m_players;
+
//@}
/// Print command-line usage
Index: game/player.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/player.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- game/player.h 8 Jan 2008 13:52:39 -0000 1.19
+++ game/player.h 19 Jan 2008 19:33:08 -0000 1.20
@@ -27,6 +27,8 @@
#include "pldrack.h"
#include "history.h"
+using std::wstring;
+
class Turn;
@@ -43,12 +45,17 @@
// Pseudo RTTI
virtual bool isHuman() const = 0;
+ /// Get the name of the player
+ const wstring & getName() const { return m_name; }
+ /// Set the name of the player
+ void setName(const wstring &iName) { m_name = iName; }
+
/**************************
* General getters
**************************/
- // Get the (possibly incomplete) rack of the player
+ /// Get the (possibly incomplete) rack of the player
const PlayedRack & getCurrentRack() const;
- // Get the previous rack
+ /// Get the previous rack
const PlayedRack & getLastRack() const;
/// Get the previous move (corresponding to the previous rack...)
const Move & getLastMove() const;
@@ -56,6 +63,7 @@
void setCurrentRack(const PlayedRack &iPld);
const History& getHistory() const { return m_history; }
+
/// Remove last turn
void removeLastTurn();
@@ -84,6 +92,9 @@
/// Score of the player
int m_score;
+ /// Name of the player
+ wstring m_name;
+
/// History of the racks and rounds for the player
History m_history;
};
Index: game/training.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/training.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- game/training.cpp 15 Jan 2008 14:56:38 -0000 1.19
+++ game/training.cpp 19 Jan 2008 19:33:08 -0000 1.20
@@ -21,6 +21,13 @@
#include <algorithm>
+#if ENABLE_NLS
+# include <libintl.h>
+# define _(String) gettext(String)
+#else
+# define _(String) String
+#endif
+
#include "dic.h"
#include "tile.h"
#include "rack.h"
@@ -37,6 +44,9 @@
Training::Training(const Dictionary &iDic)
: Game(iDic)
{
+ // Training mode implicitly uses 1 human player
+ Game::addHumanPlayer();
+ m_players[0]->setName(convertToWc(_("Training")));
}
@@ -124,8 +134,6 @@
if (getNPlayers() != 0)
return 1;
- // Training mode implicitly uses 1 human player
- Game::addHumanPlayer();
m_currPlayer = 0;
return 0;
}
Index: utils/ncurses.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/ncurses.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- utils/ncurses.cpp 9 Jan 2008 10:48:19 -0000 1.24
+++ utils/ncurses.cpp 19 Jan 2008 19:33:08 -0000 1.25
@@ -27,6 +27,7 @@
#include <ctype.h>
#include <fstream>
+#include <algorithm>
#include "ncurses.h"
#include "dic.h"
@@ -266,14 +267,27 @@
void CursesIntf::drawScoresRacks(WINDOW *win, int y, int x) const
{
+ // Compute the longest player name
+ unsigned int longest = 0;
+ for (unsigned int i = 0; i < m_game->getNPlayers(); i++)
+ {
+ longest = std::max(longest, m_game->getPlayer(i).getName().size());
+ }
+
Box box(win, y, x, m_game->getNPlayers() + 2, 25);
box.draw(_("Scores"));
+ // Magic formula to truncate too long names
+ unsigned int maxForScores =
+ std::min(longest,
+ box.getWidth() - strlen(_("%s: %d")) - 1);
for (unsigned int i = 0; i < m_game->getNPlayers(); i++)
{
if (m_game->getMode() != Game::kTRAINING && i == m_game->currPlayer())
attron(A_BOLD);
- mvwprintw(win, y + i + 1, x + 2,
- _("Player %d: %d"), i, m_game->getPlayer(i).getPoints());
+ mvwprintw(win, y + i + 1, x + 2, _("%s: %d"),
+ truncOrPad(convertToMb(m_game->getPlayer(i).getName()),
+ maxForScores).c_str(),
+ m_game->getPlayer(i).getPoints());
if (m_game->getMode() != Game::kTRAINING && i == m_game->currPlayer())
attroff(A_BOLD);
}
@@ -283,13 +297,19 @@
Box box2(win, y + yOff, x, m_game->getNPlayers() + 2, 25);
box2.draw(_("Racks"));
+ // Magic formula to truncate too long names
+ unsigned int maxForRacks =
+ std::min(longest,
+ box.getWidth() - strlen(_("%s: %ls")) - 4);
for (unsigned int i = 0; i < m_game->getNPlayers(); i++)
{
if (m_game->getMode() != Game::kTRAINING && i == m_game->currPlayer())
attron(A_BOLD);
wstring rack =
m_game->getPlayer(i).getCurrentRack().toString(PlayedRack::RACK_SIMPLE);
- mvwprintw(win, y + yOff + i + 1, x + 2,
- _("Player %d: %ls"), i, rack.c_str());
+ mvwprintw(win, y + yOff + i + 1, x + 2, _("%s: %ls"),
+ truncOrPad(convertToMb(m_game->getPlayer(i).getName()),
+ maxForRacks).c_str(),
+ rack.c_str());
if (m_game->getMode() != Game::kTRAINING && i == m_game->currPlayer())
attroff(A_BOLD);
// Force to refresh the whole rack
Index: extras/contrib/Makefile
===================================================================
RCS file: extras/contrib/Makefile
diff -N extras/contrib/Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extras/contrib/Makefile 19 Jan 2008 19:33:08 -0000 1.1
@@ -0,0 +1,85 @@
+ICONV_VERSION = 1.12
+WX_VERSION = 2.6.4
+BOOST_VERSION = 1_34_1
+QT_VERSION = 4.3.3
+
+PREFIX = $(shell pwd)/inst
+WGET = wget -c
+
+# XXX: Hardcoded for mingw on linux, at the moment
+CC = i586-mingw32msvc-gcc
+CXX = i586-mingw32msvc-g++
+CPPFLAGS += -I$(PREFIX)/include
+CONFIGURE = CC=$(CC) CXX=$(CXX) CPPFLAGS=$(CPPFLAGS) ./configure
--host=i586-mingw32msvc --build=i386-linux --prefix=$(PREFIX)
+
+.PHONY: help all
+
+help:
+ echo "Usage: make all"
+
+all: .iconv .wxWidgets .boost .qt
+
+
+### iconv ###
+
+ICONV_DIR = libiconv-$(ICONV_VERSION)
+ICONV_ARCHIVE = libiconv-$(ICONV_VERSION).tar.gz
+
+$(ICONV_DIR):
+ $(WGET) http://ftp.gnu.org/pub/gnu/libiconv/$(ICONV_ARCHIVE)
+ tar xzf $(ICONV_ARCHIVE)
+
+.iconv: $(ICONV_DIR)
+ (cd $< && $(CONFIGURE) --enable-static --disable-shared && make && make
install)
+ touch $@
+
+
+### wxWidgets ###
+
+WX_ARCHIVE = wxMSW-$(WX_VERSION).zip
+WX_DIR = wxWidgets-$(WX_VERSION)
+WX_DOS_FILES = config* *.sh install-sh mkinstalldirs
+
+$(WX_DIR):
+ $(WGET)
http://heanet.dl.sourceforge.net/sourceforge/wxwindows/$(WX_ARCHIVE)
+ unzip $(WX_ARCHIVE)
+
+.wxWidgets: $(WX_DIR)
+ (cd $< && dos2unix $(WX_DOS_FILES) && chmod +x $(WX_DOS_FILES))
+ (cd $< && $(CONFIGURE) --disable-shared --enable-optimise
--disable-debug --enable-unicode --without-libtiff --without-expat
--without-zlib --without-libpng --without-libjpeg --without-regex
--disable-mediactrl && make && make install)
+ dos2unix $(PREFIX)/bin/wx-config
+ touch $@
+
+
+### Boost ###
+
+BOOST_DIR = boost_$(BOOST_VERSION)
+BOOST_ARCHIVE = boost_$(BOOST_VERSION).tar.bz2
+
+$(BOOST_DIR):
+ $(WGET)
http://garr.dl.sourceforge.net/sourceforge/boost/$(BOOST_ARCHIVE)
+ tar xjf $(BOOST_ARCHIVE)
+
+# We don't build any library, because we don't need them (and it is really
+# hard to cross-compile with their crappy build system)
+.boost: $(BOOST_DIR)
+ #(cd $< && ./configure --prefix=$(PREFIX) &&
./tools/jam/src/bin.linuxx86/bjam --toolset=gcc --prefix=$(PREFIX)
--without-date_time --without-filesystem --without-graph --without-iostreams
--without-program_options --without-python --without-regex
--without-serialization --without-signals --without-test --without-thread
--without-wave install)
+ cp -r $</boost $(PREFIX)/include
+ touch $@
+
+
+
+### Qt ###
+
+# FIXME: No automated way at the moment :-(
+QT_ARCHIVE = qt-win-opensource-$(QT_VERSION)-mingw.exe
+
+$(QT_ARCHIVE):
+ $(WGET)
ftp://ftp.trolltech.com/qt/source/qt-win-opensource-4.3.3-mingw.exe
+
+.qt: $(QT_ARCHIVE)
+ @echo "=============== Important note ==============="
+ @echo "You need to install $(QT_ARCHIVE) yourself using wine!"
+ @echo "=============================================="
+ touch $@
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot INSTALL game/Makefile.am game/ai_percent....,
eliot-dev <=