Git Product home page Git Product logo

ticket2ride's Introduction

Ticket2ride project

Purpose

This project started as a mind exercise, when I asked myself what the largest theoretical score in this game could be. Before I started this, I read in a few places opinions about high score routes, but there was no evidence if these where the optimum solutions. So I told myself, this is a nice project to work on my programming skills in rust and in exploring algorithms for solving this.

Architecture

This is the first attempt and no specific algorithmic logic is used, only brute force, basically.

The user, when executing the cli program, can provide the starting city for the algorithm with the -c or --city option. If no city if provided or if the city provided is non existent, then Edinburgh is used by default.

The program execution consists of two steps. In the first step, all possible routes are explored, starting from the initial city. In the second step, all these possible routes are scored, and then the route with the highest score is found.

The correctness of the program is not certain. It seems to create valid routes and after fixing a logic bug, the score is correct, taking into account:

  • one of the big tickets
  • all small tickets that are covered
  • the score of the trains used to connect the route
  • the score of 10 for the express bonus
  • the score of 12 for three unused stations

Also, I guess because of the use of HashMaps, the maximum number of routes computed each time differs. My reasoning is that because HashMaps are not ordered and each time the way that are stored in memory is kind of arbitrary, the computed routes differ also. Maybe there is some bug in my logic there that I need to check.

One final consideration is that all routes start from the initial city and no route is created where the initial city is in the middle of a route.

Future considerations

This that I could do in the future:

  • Add color of routes
  • Experiment with different algorithms for traversing the network
  • Use stations for fulfilling more tickets

ticket2ride's People

Contributors

ktsiligkiris avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.