nneonneo / 2048-ai

AI for the 2048 game
MIT License
1.09k stars 279 forks source link

AI doesn't work on firefox and chrome. #44

Closed BitSec01 closed 8 years ago

BitSec01 commented 8 years ago

The AI gives and error message for chrome and for firefox it gets the board layout like

0 0 2 0 0 0 0 0 0 0 0 0 0 2 0 0

but it never sends keys it just exits out inmediatly. I have setup firefox correctly and it should be working. I even tried -k keyboard but that didn't work either.

nneonneo commented 8 years ago

What error(s) does it give you? What version of the remote control extension do you have installed? What version of Firefox did you try it with?

On Fri, Jan 1, 2016, 12:20 RamonRobben notifications@github.com wrote:

The AI gives and error message for chrome and for firefox it gets the board layout like

0 0 2 0 0 0 0 0 0 0 0 0 0 2 0 0

but it never sends keys it just exits out inmediatly I have setup firefox correctly and it should be working I even tried -k keyboard but that didn't work either

— Reply to this email directly or view it on GitHub https://github.com/nneonneo/2048-ai/issues/44.

BitSec01 commented 8 years ago

I'm using Firefox 43.0.1 with Remote Control 2.0.0.1-signed. Also on install i get this error log:

$ make
g++  -g -O2 -std=gnu++11 -O3 -Wall -Wextra -fPIC -c -o bin/2048.o 2048.cpp
2048.cpp:1:0: warning: -fPIC ignored for target (all code is position independen                                                                                                                                                                                               t)
 #include <ctype.h>
 ^
2048.cpp: In function ‘void init_tables()’:
2048.cpp:90:6: warning: ‘void init_tables()’ redeclared without dllimport attrib                                                                                                                                                                                               ute: previous dllimport ignored [-Wattributes]
 void init_tables() {
      ^
2048.cpp: In function ‘float score_toplevel_move(board_t, int)’:
2048.cpp:388:7: warning: ‘float score_toplevel_move(board_t, int)’ redeclared wi                                                                                                                                                                                               thout dllimport attribute: previous dllimport ignored [-Wattributes]
 float score_toplevel_move(board_t board, int move) {
       ^
2048.cpp: In function ‘int find_best_move(board_t)’:
2048.cpp:409:5: warning: ‘int find_best_move(board_t)’ redeclared without dllimp                                                                                                                                                                                               ort attribute: previous dllimport ignored [-Wattributes]
 int find_best_move(board_t board) {
     ^
2048.cpp: In function ‘int ask_for_move(board_t)’:
2048.cpp:429:5: warning: ‘int ask_for_move(board_t)’ redeclared without dllimpor                                                                                                                                                                                               t attribute: previous dllimport ignored [-Wattributes]
 int ask_for_move(board_t board) {
     ^
2048.cpp: In function ‘void play_game(get_move_func_t)’:
2048.cpp:488:6: warning: ‘void play_game(get_move_func_t)’ redeclared without dl                                                                                                                                                                                               limport attribute: previous dllimport ignored [-Wattributes]
 void play_game(get_move_func_t get_move) {
      ^
g++ -g -O2 -std=gnu++11 -O3 -Wall -Wextra -fPIC  bin/2048.o  -o bin/2048.exe
g++ -g -O2 -std=gnu++11 -O3 -Wall -Wextra -fPIC -shared  bin/2048.o  -o bin/2048                                                                                                                                                                                               .so
rm bin/2048.o    

And the error it gives me when i try to run the program with cygwin terminal:

$ python 2048.py -b firefox -k keyboard
Traceback (most recent call last):
  File "2048.py", line 149, in <module>
    exit(main(sys.argv[1:]))
  File "2048.py", line 125, in main
    ctrl = FirefoxRemoteControl(args.port)
  File "/cygdrive/d/users/ramon/desktop/2048-ai-master/ffctrl.py", line 8, in __init__
    self.sock.connect(('localhost', port))
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused    
nneonneo commented 8 years ago

The connection refused error means that the remote control extension isn't running or active. Make sure it's turned on and that the port is set to 32000 (or specify the port to 2048.py otherwise).

On Fri, Jan 1, 2016, 12:53 RamonRobben notifications@github.com wrote:

I'm using Firefox 43.0.1 with Remote Control 2.0.0.1-signed. Also on install i get this error log:

$ make g++ -g -O2 -std=gnu++11 -O3 -Wall -Wextra -fPIC -c -o bin/2048.o 2048.cpp 2048.cpp:1:0: warning: -fPIC ignored for target (all code is position independen t)

include

^ 2048.cpp: In function ‘void init_tables()’: 2048.cpp:90:6: warning: ‘void init_tables()’ redeclared without dllimport attrib ute: previous dllimport ignored [-Wattributes] void init_tables() { ^ 2048.cpp: In function ‘float score_toplevel_move(board_t, int)’: 2048.cpp:388:7: warning: ‘float score_toplevel_move(board_t, int)’ redeclared wi thout dllimport attribute: previous dllimport ignored [-Wattributes] float score_toplevel_move(board_t board, int move) { ^ 2048.cpp: In function ‘int find_best_move(board_t)’: 2048.cpp:409:5: warning: ‘int find_best_move(board_t)’ redeclared without dllimp ort attribute: previous dllimport ignored [-Wattributes] int find_best_move(board_t board) { ^ 2048.cpp: In function ‘int ask_for_move(board_t)’: 2048.cpp:429:5: warning: ‘int ask_for_move(board_t)’ redeclared without dllimpor t attribute: previous dllimport ignored [-Wattributes] int ask_for_move(board_t board) { ^ 2048.cpp: In function ‘void play_game(get_move_func_t)’: 2048.cpp:488:6: warning: ‘void play_game(get_move_func_t)’ redeclared without dl limport attribute: previous dllimport ignored [-Wattributes] void play_game(get_move_func_t get_move) { ^ g++ -g -O2 -std=gnu++11 -O3 -Wall -Wextra -fPIC bin/2048.o -o bin/2048.exe g++ -g -O2 -std=gnu++11 -O3 -Wall -Wextra -fPIC -shared bin/2048.o -o bin/2048 .so rm bin/2048.o

And the error it gives me when i try to run the program with cygwin terminal:

$ python 2048.py -b firefox -k keyboard Traceback (most recent call last): File "2048.py", line 149, in exit(main(sys.argv[1:])) File "2048.py", line 125, in main ctrl = FirefoxRemoteControl(args.port) File "/cygdrive/d/users/ramon/desktop/2048-ai-master/ffctrl.py", line 8, in init self.sock.connect(('localhost', port)) File "/usr/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 111] Connection refused

— Reply to this email directly or view it on GitHub https://github.com/nneonneo/2048-ai/issues/44#issuecomment-168332044.

BitSec01 commented 8 years ago

Ah I did a full reinstall of Firefox and the remote control and that seemed to do the job for me. Also is there by any chance a possibility to set a timout so that the actions are easily to follow with the eye because as for now it goes pretty quick.

BitSec01 commented 8 years ago

nevermind found it already. at the execute_move function just add a time.sleep at the top