View previous topic :: View next topic |
Author |
Message |
BHReach n00b
Joined: 24 Jan 2012 Posts: 40
|
Posted: Mon Dec 05, 2016 1:10 am Post subject: 1st Einstien Puzzle Game Always Same Solution |
|
|
games-puzzle/einstein
The 1st game always has the same solution. I remember enough of it to easily win it but I usually just click on Exit and start a new game.
Is this a bug? Is it related to the random number generator? Is it intentional?
It is annoying. |
|
Back to top |
|
|
rh n00b
Joined: 19 Sep 2006 Posts: 58
|
|
Back to top |
|
|
BHReach n00b
Joined: 24 Jan 2012 Posts: 40
|
Posted: Tue Dec 06, 2016 5:03 pm Post subject: |
|
|
That solves the problem. Thanks.
It took me a while to figure out how to apply the patch. It was a bit tricky because the ebuild does not call epatch_user.
These are the steps:
1. Create a file called 06_srand.patch (you can use any name but it must end in .patch to work) with the following contents:
Code: | --- einstein-2.0.orig/puzgen.cpp
+++ einstein-2.0/puzgen.cpp
@@ -313,6 +313,8 @@
void genPuzzle(SolvedPuzzle &puzzle, Rules &rules)
{
+ srand(time(NULL));
+
for (int i = 0; i < PUZZLE_SIZE; i++) {
for (int j = 0; j < PUZZLE_SIZE; j++)
puzzle[i][j] = j + 1; |
2. Put that file in /etc/portage/patches/games-puzzle/einstein/
You must create the sub-directories that do not exist.
3. Create a file called bashrc with the following contents:
Code: | pre_src_prepare() {
[[ ${EAPI:-0} == [012345] ]] || return
if ! type epatch_user > /dev/null 2>&1; then
local names="EPATCH_USER_SOURCE epatch_user epatch evar_push evar_push_set evar_pop estack_push estack_pop"
source <(awk "/^# @(FUNCTION|VARIABLE): / { p = 0 } /^# @(FUNCTION|VARIABLE): (${names// /|})\$/ { p = 1 } p { print }" ${PORTDIR}/eclass/eutils.eclass)
fi
epatch_user
for name in $names; do
unset $name
done
} |
and put it in /etc/portage/
4. Reinstall Einstein
Code: | emerge -av einstein |
|
|
Back to top |
|
|
|