Merge branch 'master' into challenge

* master:
  print ai moves
  add nginx and hosts config to the readme
  show more interresting current games
  mr "मरा" translation #2526. Author: गिरीश.
  nb "Norsk bokmål" translation #2524. Author: Anonymous.
  lv "latviešu valoda" translation #2523. Author: krauzand.
This commit is contained in:
Thibault Duplessis 2013-06-05 11:01:17 +02:00
commit c998ffff4c
9 changed files with 98 additions and 26 deletions

View file

@ -30,6 +30,68 @@ cp conf/application.conf.dist conf/application.conf
`application.conf` extends `base.conf` and can override any value.
Note that `application.conf` is excluded from git index.
Language subdomains
-------------------
When accessed from the root domaing (e.g. lichess.org),
the application will redirect to a language specific subdomaing (e.g. en.lichess.org).
Additionally, lichess will open websockets on the `socket.` subdomain (e.g. socket.en.lichess.org).
Here is my local nginx configuration for `l.org`, assuming lila is installed in `/home/thib/lila` and runs on port 9000.
```conf
# Websockets
server {
listen 80;
server_name ~^socket\.\w\w\.l\.org$;
location / {
include lila-proxy.conf;
proxy_read_timeout 5s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:9000/;
}
}
# Application
server {
listen 80;
server_name l.org ~^\w\w\.l\.org$;
location /assets {
alias /home/thib/lila/public;
}
location /serve {
alias /home/thib/lila/serve;
}
location /import {
proxy_set_header Host $http_host;
proxy_read_timeout 60s;
proxy_pass http://127.0.0.1:9000/import;
}
location / {
add_header "X-UA-Compatible" "IE=Edge,chrome=1";
proxy_set_header Host $http_host;
proxy_read_timeout 90s;
proxy_pass http://127.0.0.1:9000/;
}
}
```
And the `/etc/hosts` file looks like:
```
127.0.0.1 l.org
127.0.0.1 en.l.org
127.0.0.1 fr.l.org
127.0.0.1 socket.en.l.org
127.0.0.1 socket.fr.l.org
```
Run it
------
@ -40,4 +102,3 @@ bin/play
```
From here you can now run the application (`run`).
Open your web browser at `localhost:9000`.

View file

@ -28,9 +28,10 @@ object Game extends LilaController with BaseGame {
}
def realtime = Open { implicit ctx
GameRepo recentGames 9 zip makeListMenu map {
case (games, menu) html.game.realtime(games, menu)
}
GameRepo.featuredCandidates map lila.game.Featured.sort map (_ take 9) zip
makeListMenu map {
case (games, menu) html.game.realtime(games, menu)
}
}
def all(page: Int) = Open { implicit ctx

View file

@ -208,3 +208,5 @@ nbFollowers=%s sekotāji
nbFollowing=%s sekojamie
profile=Profils
more=Vairāk
memberSince=Dalībnieks kopš
lastLogin=Pēdējā pieslēgšanās

View file

@ -114,4 +114,20 @@ inbox=इनबॉक्स
chatRoom=गप्पांची खोली
composeMessage=संदेश लिहा
sentMessages=पाठवलेले संदेश
subject=विषय
recipient=प्राप्तकर्ता
send=पाठवा
incrementInSeconds=सेकंदांमध्ये वाढ
freeOnlineChess=विनामूल्य ऑनलाइन बुद्धिबळ
spectators=प्रेक्षक
nbWins=%s विजय
nbLosses=%s पराभव
nbDraws=%s अनिर्णीत
exportGames=खेळ निर्यात करा
color=रंग
eloRange=इलो श्रेणी
giveNbSeconds=%s सेकंद द्या
allPlayers=सर्व खेळाडू
thisPlayerUsesChessComputerAssistance=हा खेळाडू संगणकाची मदत घेतो.
opening=प्रारंभ
takeback=परत घ्या

View file

@ -47,6 +47,7 @@ replayAndAnalyse=Spill igjen og analysér
theComputerAnalysisYouRequestedIsNowAvailable=Datamaskin analysen du etterspurte er nå tilgjengelig
theComputerAnalysisHasFailed=Datamaskin analysen gikk feil
viewTheComputerAnalysis=Se datamaskin analysen
blunders=Blundere
mistakes=Feil
viewGameStats=Vis spillstatistikk
flipBoard=Snu brettet
@ -203,3 +204,4 @@ nbFollowers=%s følgere
nbFollowing=%s følger
profile=Profil
more=Mer
memberSince=Ble registrert

View file

@ -40,8 +40,8 @@ final class ActorFSM(
}
when(IsReady) {
case Event(Out("readyok"), doing: Doing) {
val lines = config go doing.current
lines.lastOption foreach display(doing.name)
val lines = config go doing.current
print(doing.fold(_ "a", _ "."))
lines foreach process.write
goto(Running)
}
@ -89,10 +89,6 @@ final class ActorFSM(
doing stay using doing
)
private def display(name: String)(msg: String) {
loginfo("[%s] %s".format(name, msg))
}
override def postStop() {
process.destroy()
process = null

View file

@ -37,7 +37,6 @@ object model {
def fold[A](todo: Todo A, doing: Doing A): A = doing(this)
def enqueue(task: Task) = copy(queue = queue :+ task)
def map(f: Task Task): Doing = copy(current = f(current))
def name = current.fold(_ "SFP", _ "SFA")
}
object play {

View file

@ -47,19 +47,19 @@ final class Featured(
private def valid(game: Game) = game.isBeingPlayed
private def feature: Option[Game] = Featured best {
private def feature: Option[Game] = Featured sort {
GameRepo.featuredCandidates.await filter valid
}
} lastOption
}))
}
object Featured {
case object GetOne
private case object GetOne
def best(games: List[Game]) = (games sortBy score).lastOption
def sort(games: List[Game]): List[Game] = games sortBy score
def score(game: Game): Float = heuristics map {
private def score(game: Game): Float = heuristics map {
case (fn, coefficient) heuristicBox(fn(game)) * coefficient
} sum
@ -75,16 +75,16 @@ object Featured {
speedHeuristic -> 1,
progressHeuristic -> 0.5f)
def eloHeuristic(color: Color): Heuristic = game
private def eloHeuristic(color: Color): Heuristic = game
eloBox(game.player(color).elo | 1100)
def speedHeuristic: Heuristic = game
private def speedHeuristic: Heuristic = game
1 - timeBox(game.estimateTotalTime)
def progressHeuristic: Heuristic = game
private def progressHeuristic: Heuristic = game
1 - turnBox(game.turns)
// boxes and reduce to 0..1 range
def box(in: Range.Inclusive)(v: Float): Float =
private def box(in: Range.Inclusive)(v: Float): Float =
(math.max(in.start, math.min(v, in.end)) - in.start) / (in.end - in.start).toFloat
}

View file

@ -142,18 +142,13 @@ object GameRepo {
)(_.asOpt[ID])
def featuredCandidates: Fu[List[Game]] = $find(
Query.playable ++ Query.clock(true) ++ Json.obj(
"t" -> $gt(1),
Query.playable ++ Query.clock(true) ++ Query.turnsGt(1) ++ Json.obj(
createdAt -> $gt($date(DateTime.now - 4.minutes)),
updatedAt -> $gt($date(DateTime.now - 15.seconds))
))
def count(query: Query.type JsObject): Fu[Int] = $count(query(Query))
def recentGames(limit: Int): Fu[List[Game]] = $find(
$query(Query.started ++ Query.turnsGt(1)) sort Query.sortCreated, limit
)
def nbPerDay(days: Int): Fu[List[Int]] =
((days to 1 by -1).toList map { day
val from = DateTime.now.withTimeAtStartOfDay - day.days