Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
1st Einstien Puzzle Game Always Same Solution
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
BHReach
n00b
n00b


Joined: 24 Jan 2012
Posts: 40

PostPosted: Mon Dec 05, 2016 1:10 am    Post subject: 1st Einstien Puzzle Game Always Same Solution Reply with quote

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
View user's profile Send private message
rh
n00b
n00b


Joined: 19 Sep 2006
Posts: 58

PostPosted: Tue Dec 06, 2016 8:47 am    Post subject: Reply with quote

Does this patch help?
https://github.com/lksj/einstein-puzzle/commit/d2dd24e1d090dee3025912942a6437a3a7821272
Back to top
View user's profile Send private message
BHReach
n00b
n00b


Joined: 24 Jan 2012
Posts: 40

PostPosted: Tue Dec 06, 2016 5:03 pm    Post subject: Reply with quote

rh wrote:
Does this patch help?
https://github.com/lksj/einstein-puzzle/commit/d2dd24e1d090dee3025912942a6437a3a7821272

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum