Halite icon indicating copy to clipboard operation
Halite copied to clipboard

Haskell [Final Steps]

Open truell20 opened this issue 9 years ago • 16 comments
trafficstars

truell20 avatar Nov 12 '16 21:11 truell20

Could you take a look at Haskell Alternative pull request? I would like to merge my implementation with current implementation, without replacing all of @jparoz work, but I am not sure I have used the right way to do that ( I am new to git ).

Kesanov avatar Nov 13 '16 11:11 Kesanov

Sure, @Josef-Vonasek. I'll close this for now.

truell20 avatar Nov 14 '16 19:11 truell20

Nevermind, I see that you are sending a PR for this branch.

truell20 avatar Nov 14 '16 19:11 truell20

Can we include #223?

jparoz avatar Nov 15 '16 06:11 jparoz

It's a bit off topic, but wasn't the infamous record problem solved in GHC 8.0 ? E.G. Do we need different names for location getters (currently siteLocation and moveLocation)?

Kesanov avatar Nov 15 '16 07:11 Kesanov

Yeah, with the DuplicateRecordFields extension. I personally never felt it was that big of a deal, and am still in the habit of prefixing.

I think the extension would work in the code. It would be only a few lines changed to implement, if we want to.

jparoz avatar Nov 15 '16 07:11 jparoz

Also, other starter packages provide some helper functions like inBounds, getDistance, getAngle, getLocation, getSite. Should we also provide them (e.g. in Halite.Logic) ? Also all of those methods take Map as parameter. Therefore I was playing with the idea of making Map a state monad, but I guess it probably wouldn't be worth the effort (maybe even contra productive). What is your opinion?

Kesanov avatar Nov 15 '16 07:11 Kesanov

From what I can tell, inBounds is nonsense, as the game map loops around at the edges.

The helper functions seem like nice additions. Perhaps we could name them as such: distanceTo, angleTo, intended to be called like: loc1 angleTo loc2? Not a huge deal.

If a user wants monadic composition for Map, they could just use the implementation in Control.Monad.State. This should be enough firepower for any use case I can think of.

jparoz avatar Nov 15 '16 07:11 jparoz

I have sent a PR #233. After that I think we are ready to go, unless there is some bug I didn't see.
( Maybe we could post a link on Haskell reddit when it is finished, I think this game can be a nice starting point for haskell intermediates, who are looking for project.)

Kesanov avatar Nov 16 '16 12:11 Kesanov

@jparoz Does this look good to you as well?

truell20 avatar Nov 16 '16 14:11 truell20

Great work from @Josef-Vonasek! Looks good to ship.

Just curious, why the change to rand?

jparoz avatar Nov 16 '16 16:11 jparoz

Thanks.

Because our Test instance uses modulo and as you know 0 <= mod x i < i but 0 <= randomR (0, i) <= i.

Kesanov avatar Nov 16 '16 17:11 Kesanov

That makes sense. 👍

jparoz avatar Nov 17 '16 04:11 jparoz

What do you need cabal for?

AnthonyJacob avatar Nov 24 '16 06:11 AnthonyJacob

@AnthonyJacob Having a bit of trouble installing stack in a docker container.

truell20 avatar Nov 24 '16 15:11 truell20

@truell20 I have no problem installing stack to docker image, please see #282

[wizzup@earth worker]$ docker run -it --rm mntruell/halite_sandbox
root@537b8acfc370:/# which stack
/usr/bin/stack
root@537b8acfc370:/# stack --version
Version 1.2.0, Git revision 241cd07d576d9c0c0e712e83d947e3dd64541c42 (4054 commits) x86_64 hpack-0.14.0
root@537b8acfc370:/# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.1 LTS
Release:	16.04
Codename:	xenial

Below is building log

./buildDocker.sh 
Sending build context to Docker daemon 4.096 kB
Step 1 : FROM ubuntu:latest
 ---> e4415b714b62
Step 2 : RUN apt-get update
 ---> Using cache
 ---> 41dddd49feae
Step 3 : RUN apt-get install -y sudo
 ---> Using cache
 ---> 8ba1811fca98
Step 4 : RUN apt-get install -y curl
 ---> Using cache
 ---> b17aab6deb26
Step 5 : RUN apt-get install -y libstdc++6
 ---> Using cache
 ---> 53aba3fc0d33
Step 6 : RUN apt-get install -y gcc
 ---> Using cache
 ---> efed9a872d77
Step 7 : RUN apt-get install -y g++
 ---> Using cache
 ---> 568df5e2914a
Step 8 : RUN apt-get install -y python3 python3-pip python3-dev python3-numpy
 ---> Using cache
 ---> e703bdd2c4d1
Step 9 : RUN curl -sSf https://static.rust-lang.org/rustup.sh | sh
 ---> Using cache
 ---> 69747f332a6b
Step 10 : RUN apt-get install -y python-software-properties
 ---> Using cache
 ---> 99b48c347294
Step 11 : RUN apt-get install -y software-properties-common
 ---> Using cache
 ---> f3e5c8ac622e
Step 12 : RUN apt-get install -y openjdk-8-jdk
 ---> Using cache
 ---> 08fbaa5db877
Step 13 : RUN apt-get install -y scala
 ---> Using cache
 ---> 9e6009db4071
Step 14 : RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
 ---> Using cache
 ---> f2aa565e8101
Step 15 : RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
 ---> Using cache
 ---> 7c9fc9d7aa47
Step 16 : RUN apt-get update
 ---> Using cache
 ---> a418020f2f37
Step 17 : RUN apt-get install -y mono-devel
 ---> Using cache
 ---> e30059e4c6ab
Step 18 : RUN apt-get install -y ruby
 ---> Using cache
 ---> df4d54cc9dcd
Step 19 : RUN gem install bundler
 ---> Using cache
 ---> 33bf74e92907
Step 20 : RUN apt-get install -y golang
 ---> Using cache
 ---> f4d4dd5128b2
Step 21 : RUN apt-get install -y php
 ---> Using cache
 ---> 18de3f4a5ed8
Step 22 : RUN apt-get install -y build-essential
 ---> Using cache
 ---> 7ae5c00c5094
Step 23 : RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
 ---> Using cache
 ---> 81ab2b0a9d21
Step 24 : RUN apt-get install -y nodejs
 ---> Using cache
 ---> d2250795c191
Step 25 : RUN apt-get install -y ocaml
 ---> Using cache
 ---> a7a1f231161e
Step 26 : RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 575159689BEFB442
 ---> Using cache
 ---> ae91af6daedb
Step 27 : RUN echo 'deb http://download.fpcomplete.com/ubuntu xenial main'|sudo tee /etc/apt/sources.list.d/fpco.list
 ---> Using cache
 ---> 511a99ad788f
Step 28 : RUN sudo apt-get update && sudo apt-get install stack -y
 ---> Using cache
 ---> a68d64428c48
Successfully built a68d64428c48

wizzup avatar Nov 29 '16 11:11 wizzup