Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't print full instructions #2

Open
JaseHadd opened this issue Mar 24, 2019 · 4 comments
Open

Doesn't print full instructions #2

JaseHadd opened this issue Mar 24, 2019 · 4 comments

Comments

@JaseHadd
Copy link

JaseHadd commented Mar 24, 2019

This is likely due mostly to my complete inexperience with lisp, but I can't make it print a full list of instructions for a deck.

The output looks like the following when running in SBCL on macOS Mojave.

0] (ps:solve (ps:string->card-list "4h Kd 3h 4c Tc 5s 7s 6c 8d Ah Js 7h 5d Kh 2s 6s Ts Jc 6d 9h 7d 5c Ac 2c 4d 3d 9d Ad 8h 7c 8s Th 8c 2h Td 3c 3s Ks 4s Jd Qs 9s Qc 6h Jh 2d Qh 5h Qd 9c Kc As"))

("Draw" "Draw" "Draw" ("3d" "Th") "Draw" "Draw" "Draw" "Draw" "Draw" ("Ks")
 ("9d" "4s") ("2c" "Jd") ...)

I've attempted to load the command-line package to access print-solution, but I've had no luck (unable to find package command-line, and can't run them directly with (cl:print-solution (ps:solve ... )).

@mchung94
Copy link
Owner

I just installed SBCL on macOS Mojave to try this out and it printed all the instructions, so the following is just speculation, please let me know if it helps or not:

Can you try typing *print-length* on the SBCL prompt and see if it prints NIL or a number? That controls how many elements are printed. NIL means it will print everything, if it's a number then that's the limit to how much it will print before printing the periods. For me it's NIL so it prints the whole list of things in the solution. If it's a number, this should work:

(let ((*print-length* nil))
  (ps:solve (ps:string->card-list "4h Kd 3h 4c Tc 5s 7s 6c 8d Ah Js 7h 5d Kh 2s 6s Ts Jc 6d 9h 7d 5c Ac 2c 4d 3d 9d Ad 8h 7c 8s Th 8c 2h Td 3c 3s Ks 4s Jd Qs 9s Qc 6h Jh 2d Qh 5h Qd 9c Kc As")))

Also, does this line below work at all? It's calling command-line::print-solution with two colons because the print-solution function isn't exported by the package.

(command-line::print-solution (ps:solve (ps:string->card-list "4h Kd 3h 4c Tc 5s 7s 6c 8d Ah Js 7h 5d Kh 2s 6s Ts Jc 6d 9h 7d 5c Ac 2c 4d 3d 9d Ad 8h 7c 8s Th 8c 2h Td 3c 3s Ks 4s Jd Qs 9s Qc 6h Jh 2d Qh 5h Qd 9c Kc As")))

Another thing that may help is:

(loop for step in (ps:solve (ps:string->card-list "4h Kd 3h 4c Tc 5s 7s 6c 8d Ah Js 7h 5d Kh 2s 6s Ts Jc 6d 9h 7d 5c Ac 2c 4d 3d 9d Ad 8h 7c 8s Th 8c 2h Td 3c 3s Ks 4s Jd Qs 9s Qc 6h Jh 2d Qh 5h Qd 9c Kc As"))
    do (format t "~A~%" step))

This is just iterating through each step in the solution and printing them one by one.

@JaseHadd
Copy link
Author

JaseHadd commented Mar 24, 2019

*print-length* was set to 12, but the command you provided didn't seem to change the output.

The other two commands never seem to finish running.

After your comment that it worked when you downloaded it, I downloaded the binary distribution from the SBCL website and it works in that distribution (my system install is from Homebrew, so probably just built with different options).

Thanks :)

Small update: After a successful solution, I tried another, but ran into an error (I believe because I didn't capitalize card symbols), and then started experiencing the previous error again. A restart fixes it but it's interesting behavior - maybe something wrong with the interpreter? The error seems to set *print-length* to 12, and setting it back as in the command you posted had no effect.

@mchung94
Copy link
Owner

mchung94 commented Mar 24, 2019

Yes, I had downloaded it from the SBCL website.

Ah I should have been more careful when posting the first one, it would need to be (setf *print-length* nil) followed by running the (ps:solve... to make it work. With the let, it's just temporarily setting it to NIL while running the solver and resets back to its previous value just before printing the result :)

I'm trying to figure out what's going on with it changing to 12...

@JaseHadd
Copy link
Author

In light of the discovery of it happening after errors in the version from their website, I tried again in the Homebrew version, being careful not to mistype anything and trigger an error, and it does work in that version as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants